Skip to content

Commit 60b5bb5

Browse files
don't complete string and command macros when the input matches the internal name like r_ to r"
1 parent e08280a commit 60b5bb5

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

stdlib/REPL/src/REPLCompletions.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ function append_filtered_mod_names!(ffunc::Function, suggestions::Vector{Complet
141141
ssyms = names(mod; all=true, imported, usings)
142142
filter!(ffunc, ssyms)
143143
macros = filter(x -> startswith(String(x), "@" * name), ssyms)
144+
145+
# don't complete string and command macros when the input matches the internal name like `r_` to `r"`
146+
if !startswith(name, "@")
147+
filter!(macros) do m
148+
s = String(m)
149+
if endswith(s, "_str") || endswith(s, "_cmd")
150+
occursin(name, s[1:end-4])
151+
else
152+
true
153+
end
154+
end
155+
end
156+
144157
syms = String[sprint((io,s)->Base.show_sym(io, s; allow_macroname=true), s) for s in ssyms if completes_global(String(s), name)]
145158
appendmacro!(syms, macros, "_str", "\"")
146159
appendmacro!(syms, macros, "_cmd", "`")

stdlib/REPL/test/replcompletions.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,6 +1515,16 @@ end
15151515
@test "testcmd`" in c
15161516
c, r, res = test_complete("CompletionFoo.tϵsτc")
15171517
@test "tϵsτcmδ`" in c
1518+
1519+
# Issue #56071: don't complete string and command macros when the input matches the internal name like `r_` to `r"`
1520+
c, r, res = test_complete("CompletionFoo.teststr_")
1521+
@test isempty(c)
1522+
c, r, res = test_complete("CompletionFoo.teststr_s")
1523+
@test isempty(c)
1524+
c, r, res = test_complete("CompletionFoo.testcmd_")
1525+
@test isempty(c)
1526+
c, r, res = test_complete("CompletionFoo.testcmd_c")
1527+
@test isempty(c)
15181528
end
15191529

15201530
@testset "Keyword-argument completion" begin

0 commit comments

Comments
 (0)