diff --git a/stdlib/REPL/src/REPLCompletions.jl b/stdlib/REPL/src/REPLCompletions.jl index fc84bd2b8d3b2..5cd1e5b310087 100644 --- a/stdlib/REPL/src/REPLCompletions.jl +++ b/stdlib/REPL/src/REPLCompletions.jl @@ -527,7 +527,7 @@ function dict_identifier_key(str,tag) # Avoid `isdefined(::Array, ::Symbol)` isa(obj, Array) && return (nothing, nothing, nothing) end - begin_of_key = first(findnext(r"\S", str, nextind(str, end_of_identifier) + 1)) # 1 for [ + begin_of_key = first(something(findnext(r"\S", str, nextind(str, end_of_identifier) + 1), 1)) # 1 for [ begin_of_key==0 && return (true, nothing, nothing) partial_key = str[begin_of_key:end] (isa(obj, AbstractDict) && length(obj) < 1e6) || return (true, nothing, nothing) diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index accd6b8107295..8187150114c7a 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -905,6 +905,9 @@ function test_dict_completion(dict_name) s = "$dict_name[:α" c, r = test_complete(s) @test c == Any[":α]"] + s = "$dict_name[" + c, r = test_complete(s) + @test !isempty(c) end test_dict_completion("CompletionFoo.test_dict") test_dict_completion("CompletionFoo.test_customdict")