Skip to content

Commit

Permalink
Don't give public but unexported symbols as repl completions in an un…
Browse files Browse the repository at this point in the history
…qualified context (#51345)
  • Loading branch information
LilithHafner authored Sep 17, 2023
1 parent ebe1a37 commit 26ceebf
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ end

function filtered_mod_names(ffunc::Function, mod::Module, name::AbstractString, all::Bool = false, imported::Bool = false)
ssyms = names(mod, all = all, imported = imported)
all || filter!(Base.Fix1(Base.isexported, mod), ssyms)
filter!(ffunc, ssyms)
macros = filter(x -> startswith(String(x), "@" * name), ssyms)
syms = String[sprint((io,s)->Base.show_sym(io, s; allow_macroname=true), s) for s in ssyms if completes_global(String(s), name)]
Expand Down
14 changes: 14 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1896,3 +1896,17 @@ let s = "Issue49892(fal"
@test n in c
end
end

@testset "public but non-exported symbols only complete qualified (#51331)" begin
c, r, res = test_complete("ispub")
@test res
@test "ispublic" c

c, r, res = test_complete("Base.ispub")
@test res
@test "ispublic" c

@test Base.ispublic(Base, :ispublic)
# If this last test starts failing, that's okay, just pick a new example symbol:
@test !Base.isexported(Base, :ispublic)
end

0 comments on commit 26ceebf

Please sign in to comment.