@@ -519,14 +519,11 @@ function dict_identifier_key(str,tag)
519519 sym = Symbol (name)
520520 isdefined (obj, sym) || return (nothing , nothing , nothing )
521521 obj = getfield (obj, sym)
522- # Avoid `isdefined(::Array, ::Symbol)`
523- isa (obj, Array) && return (nothing , nothing , nothing )
524522 end
525- begin_of_key = first (something (findnext (r" \S " , str, nextind (str, end_of_identifier) + 1 ), 1 )) # 1 for [
526- begin_of_key== 0 && return (true , nothing , nothing )
527- partial_key = str[begin_of_key: end ]
528- (isa (obj, AbstractDict) && length (obj) < 1e6 ) || return (true , nothing , nothing )
529- return (obj, partial_key, begin_of_key)
523+ (isa (obj, AbstractDict) && length (obj) < 1_000_000 ) || return (nothing , nothing , nothing )
524+ begin_of_key = something (findnext (! isspace, str, nextind (str, end_of_identifier) + 1 ), # +1 for [
525+ lastindex (str)+ 1 )
526+ return (obj, str[begin_of_key: end ], begin_of_key)
530527end
531528
532529# This needs to be a separate non-inlined function, see #19441
@@ -572,13 +569,9 @@ function completions(string, pos, context_module=Main)::Completions
572569 # if completing a key in a Dict
573570 identifier, partial_key, loc = dict_identifier_key (partial,inc_tag)
574571 if identifier != = nothing
575- if partial_key != = nothing
576- matches = find_dict_matches (identifier, partial_key)
577- length (matches)== 1 && (length (string) <= pos || string[pos+ 1 ] != ' ]' ) && (matches[1 ]*= " ]" )
578- length (matches)> 0 && return [DictCompletion (identifier, match) for match in sort! (matches)], loc: pos, true
579- else
580- return Completion[], 0 : - 1 , false
581- end
572+ matches = find_dict_matches (identifier, partial_key)
573+ length (matches)== 1 && (lastindex (string) <= pos || string[nextind (string,pos)] != ' ]' ) && (matches[1 ]*= ' ]' )
574+ length (matches)> 0 && return [DictCompletion (identifier, match) for match in sort! (matches)], loc: pos, true
582575 end
583576
584577 # otherwise...
@@ -596,7 +589,7 @@ function completions(string, pos, context_module=Main)::Completions
596589 length (paths) == 1 && # Only close if there's a single choice,
597590 ! isdir (expanduser (replace (string[startpos: prevind (string, first (r))] * paths[1 ]. path,
598591 r" \\ " => " " ))) && # except if it's a directory
599- (length (string) <= pos ||
592+ (lastindex (string) <= pos ||
600593 string[nextind (string,pos)] != ' "' ) # or there's already a " at the cursor.
601594 paths[1 ] = PathCompletion (paths[1 ]. path * " \" " )
602595 end
0 commit comments