Skip to content

Commit fc6acc7

Browse files
authored
REPLCompletions: allow completions for import Mod.xxx (#54691)
1 parent b946b94 commit fc6acc7

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1132,6 +1132,10 @@ function complete_identifiers!(suggestions::Vector{Completion},
11321132
end
11331133
isexpr(ex, :incomplete) && (ex = nothing)
11341134
elseif isexpr(ex, (:using, :import))
1135+
if isexpr(ex, :import)
1136+
# allow completion for `import Mod.name` (where `name` is not a module)
1137+
complete_modules_only = false
1138+
end
11351139
arglast = ex.args[end] # focus on completion to the last argument
11361140
if isexpr(arglast, :.)
11371141
# We come here for cases like:

stdlib/REPL/test/replcompletions.jl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2308,3 +2308,18 @@ let s = "TestImplicitUsing.@asse"
23082308
@test res
23092309
@test "@assert" in c
23102310
end
2311+
2312+
# JuliaLang/julia#23374: completion for `import Mod.name`
2313+
module Issue23374
2314+
global v23374 = nothing
2315+
end
2316+
let s = "import .Issue23374.v"
2317+
c, r, res = test_complete_context(s)
2318+
@test res
2319+
@test "v23374" in c
2320+
end
2321+
let s = "using .Issue23374.v"
2322+
c, r, res = test_complete_context(s)
2323+
@test res
2324+
@test isempty(c)
2325+
end

0 commit comments

Comments
 (0)