@@ -530,14 +530,11 @@ function dict_identifier_key(str,tag)
530
530
sym = Symbol (name)
531
531
isdefined (obj, sym) || return (nothing , nothing , nothing )
532
532
obj = getfield (obj, sym)
533
- # Avoid `isdefined(::Array, ::Symbol)`
534
- isa (obj, Array) && return (nothing , nothing , nothing )
535
533
end
536
- begin_of_key = first (something (findnext (r" \S " , str, nextind (str, end_of_identifier) + 1 ), 1 )) # 1 for [
537
- begin_of_key== 0 && return (true , nothing , nothing )
538
- partial_key = str[begin_of_key: end ]
539
- (isa (obj, AbstractDict) && length (obj) < 1e6 ) || return (true , nothing , nothing )
540
- return (obj, partial_key, begin_of_key)
534
+ (isa (obj, AbstractDict) && length (obj) < 1_000_000 ) || return (nothing , nothing , nothing )
535
+ begin_of_key = something (findnext (! isspace, str, nextind (str, end_of_identifier) + 1 ), # +1 for [
536
+ lastindex (str)+ 1 )
537
+ return (obj, str[begin_of_key: end ], begin_of_key)
541
538
end
542
539
543
540
# This needs to be a separate non-inlined function, see #19441
@@ -581,13 +578,9 @@ function completions(string, pos, context_module=Main)::Completions
581
578
# if completing a key in a Dict
582
579
identifier, partial_key, loc = dict_identifier_key (partial,inc_tag)
583
580
if identifier != = nothing
584
- if partial_key != = nothing
585
- matches = find_dict_matches (identifier, partial_key)
586
- length (matches)== 1 && (length (string) <= pos || string[pos+ 1 ] != ' ]' ) && (matches[1 ]*= " ]" )
587
- length (matches)> 0 && return [DictCompletion (identifier, match) for match in sort! (matches)], loc: pos, true
588
- else
589
- return Completion[], 0 : - 1 , false
590
- end
581
+ matches = find_dict_matches (identifier, partial_key)
582
+ length (matches)== 1 && (lastindex (string) <= pos || string[nextind (string,pos)] != ' ]' ) && (matches[1 ]*= ' ]' )
583
+ length (matches)> 0 && return [DictCompletion (identifier, match) for match in sort! (matches)], loc: pos, true
591
584
end
592
585
593
586
# otherwise...
@@ -605,7 +598,7 @@ function completions(string, pos, context_module=Main)::Completions
605
598
length (paths) == 1 && # Only close if there's a single choice,
606
599
! isdir (expanduser (replace (string[startpos: prevind (string, first (r))] * paths[1 ]. path,
607
600
r" \\ " => " " ))) && # except if it's a directory
608
- (length (string) <= pos ||
601
+ (lastindex (string) <= pos ||
609
602
string[nextind (string,pos)] != ' "' ) # or there's already a " at the cursor.
610
603
paths[1 ] = PathCompletion (paths[1 ]. path * " \" " )
611
604
end
0 commit comments