Skip to content

Commit

Permalink
REPLCompletions: allow module completions for using with multiple args
Browse files Browse the repository at this point in the history
E.g. completes `using Base.Sort, Base.Th|` to
`using Base.Sort, Base.Threads`.

- fixes #53999
  • Loading branch information
aviatesk committed May 31, 2024
1 parent 8d3b905 commit fe73861
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1109,8 +1109,8 @@ function complete_identifiers!(suggestions::Vector{Completion}, @nospecialize(ff
end
isexpr(ex, :incomplete) && (ex = nothing)
elseif isexpr(ex, (:using, :import))
arg1 = ex.args[1]
if isexpr(arg1, :.)
arglast = ex.args[end] # focus on completion to the last argument
if isexpr(arglast, :.)
# We come here for cases like:
# - `string`: "using Mod1.Mod2.M"
# - `ex`: :(using Mod1.Mod2)
Expand All @@ -1120,7 +1120,7 @@ function complete_identifiers!(suggestions::Vector{Completion}, @nospecialize(ff
# Note that `ffunc` is set to `module_filter` within `completions`
ex = nothing
firstdot = true
for arg = arg1.args
for arg = arglast.args
if arg === :.
# override `context_module` if multiple `.` accessors are used
if firstdot
Expand Down
12 changes: 6 additions & 6 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2219,6 +2219,12 @@ let s = "using Base."
@test res
@test "BinaryPlatforms" in c
end
# JuliaLang/julia#53999
let s = "using Base.Sort, Base.Th"
c, r, res = test_complete_context(s)
@test res
@test "Threads" in c
end
# test cases with the `.` accessor
module Issue52922
module Inner1
Expand Down Expand Up @@ -2302,9 +2308,3 @@ let s = "TestImplicitUsing.@asse"
@test res
@test "@assert" in c
end
# JuliaLang/julia#53999
let s = "using Base.Thre"
c, r, res = test_complete_context(s)
@test res
@test "Threads" in c
end

0 comments on commit fe73861

Please sign in to comment.