Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,19 @@ function append_filtered_mod_names!(ffunc::Function, suggestions::Vector{Complet
ssyms = names(mod; all=true, imported, usings)
filter!(ffunc, ssyms)
macros = filter(x -> startswith(String(x), "@" * name), ssyms)

# don't complete string and command macros when the input matches the internal name like `r_` to `r"`
if !startswith(name, "@")
filter!(macros) do m
s = String(m)
if endswith(s, "_str") || endswith(s, "_cmd")
occursin(name, first(s, length(s)-4))
else
true
end
end
end

syms = String[sprint((io,s)->Base.show_sym(io, s; allow_macroname=true), s) for s in ssyms if completes_global(String(s), name)]
appendmacro!(syms, macros, "_str", "\"")
appendmacro!(syms, macros, "_cmd", "`")
Expand Down
10 changes: 10 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,16 @@ end
@test "testcmd`" in c
c, r, res = test_complete("CompletionFoo.tϵsτc")
@test "tϵsτcmδ`" in c

# Issue #56071: don't complete string and command macros when the input matches the internal name like `r_` to `r"`
c, r, res = test_complete("CompletionFoo.teststr_")
@test isempty(c)
c, r, res = test_complete("CompletionFoo.teststr_s")
@test isempty(c)
c, r, res = test_complete("CompletionFoo.testcmd_")
@test isempty(c)
c, r, res = test_complete("CompletionFoo.testcmd_c")
@test isempty(c)
end

@testset "Keyword-argument completion" begin
Expand Down
Loading