Skip to content

Commit

Permalink
REPLCompletions: allow completions for import Mod.xxx (#54691)
Browse files Browse the repository at this point in the history
  • Loading branch information
aviatesk authored Jun 6, 2024
1 parent b946b94 commit fc6acc7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,10 @@ function complete_identifiers!(suggestions::Vector{Completion},
end
isexpr(ex, :incomplete) && (ex = nothing)
elseif isexpr(ex, (:using, :import))
if isexpr(ex, :import)
# allow completion for `import Mod.name` (where `name` is not a module)
complete_modules_only = false
end
arglast = ex.args[end] # focus on completion to the last argument
if isexpr(arglast, :.)
# We come here for cases like:
Expand Down
15 changes: 15 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2308,3 +2308,18 @@ let s = "TestImplicitUsing.@asse"
@test res
@test "@assert" in c
end

# JuliaLang/julia#23374: completion for `import Mod.name`
module Issue23374
global v23374 = nothing
end
let s = "import .Issue23374.v"
c, r, res = test_complete_context(s)
@test res
@test "v23374" in c
end
let s = "using .Issue23374.v"
c, r, res = test_complete_context(s)
@test res
@test isempty(c)
end

0 comments on commit fc6acc7

Please sign in to comment.