@@ -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
@@ -583,13 +580,9 @@ function completions(string, pos, context_module=Main)::Completions
583
580
# if completing a key in a Dict
584
581
identifier, partial_key, loc = dict_identifier_key (partial,inc_tag)
585
582
if identifier != = nothing
586
- if partial_key != = nothing
587
- matches = find_dict_matches (identifier, partial_key)
588
- length (matches)== 1 && (length (string) <= pos || string[pos+ 1 ] != ' ]' ) && (matches[1 ]*= " ]" )
589
- length (matches)> 0 && return [DictCompletion (identifier, match) for match in sort! (matches)], loc: pos, true
590
- else
591
- return Completion[], 0 : - 1 , false
592
- end
583
+ matches = find_dict_matches (identifier, partial_key)
584
+ length (matches)== 1 && (lastindex (string) <= pos || string[nextind (string,pos)] != ' ]' ) && (matches[1 ]*= ' ]' )
585
+ length (matches)> 0 && return [DictCompletion (identifier, match) for match in sort! (matches)], loc: pos, true
593
586
end
594
587
595
588
# otherwise...
@@ -607,7 +600,7 @@ function completions(string, pos, context_module=Main)::Completions
607
600
length (paths) == 1 && # Only close if there's a single choice,
608
601
! isdir (expanduser (replace (string[startpos: prevind (string, first (r))] * paths[1 ]. path,
609
602
r" \\ " => " " ))) && # except if it's a directory
610
- (length (string) <= pos ||
603
+ (lastindex (string) <= pos ||
611
604
string[nextind (string,pos)] != ' "' ) # or there's already a " at the cursor.
612
605
paths[1 ] = PathCompletion (paths[1 ]. path * " \" " )
613
606
end
0 commit comments