Skip to content

Commit

Permalink
don't complete string and command macros when the input matches the i…
Browse files Browse the repository at this point in the history
…nternal name like `r_` to `r"`
  • Loading branch information
IanButterworth committed Oct 20, 2024
1 parent e08280a commit da440fd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
8 changes: 8 additions & 0 deletions stdlib/REPL/src/REPLCompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,14 @@ 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
!in(split(String(m), "@" * name)[2], ("str", "cmd"))
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
6 changes: 6 additions & 0 deletions stdlib/REPL/test/replcompletions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1515,6 +1515,12 @@ 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.testcmd_")
@test isempty(c)
end

@testset "Keyword-argument completion" begin
Expand Down

0 comments on commit da440fd

Please sign in to comment.