diff --git a/stdlib/REPL/src/docview.jl b/stdlib/REPL/src/docview.jl index 66f2aba86384d..73c8addc05eb7 100644 --- a/stdlib/REPL/src/docview.jl +++ b/stdlib/REPL/src/docview.jl @@ -720,7 +720,19 @@ accessible(mod::Module) = map(names, moduleusings(mod))...; collect(keys(Base.Docs.keywords))] |> unique |> filtervalid -doc_completions(name) = fuzzysort(name, accessible(Main)) +function doc_completions(name) + res = fuzzysort(name, accessible(Main)) + + # to insert an entry like `raw""` for `"@raw_str"` in `res` + ms = match.(r"^@(.*?)_str$", res) + idxs = findall(!isnothing, ms) + + # avoid messing up the order while inserting + for i in reverse(idxs) + insert!(res, i, "$(only(ms[i].captures))\"\"") + end + res +end doc_completions(name::Symbol) = doc_completions(string(name)) diff --git a/stdlib/REPL/test/docview.jl b/stdlib/REPL/test/docview.jl index 15b0c5d7babfe..22701ead7883d 100644 --- a/stdlib/REPL/test/docview.jl +++ b/stdlib/REPL/test/docview.jl @@ -42,6 +42,14 @@ end @test REPL.insert_hlines(IOBuffer(), nothing) === nothing end +@testset "Check @var_str also completes to var\"\" in REPL.doc_completions()" begin + checks = ["var", "raw", "r"] + symbols = "@" .* checks .* "_str" + results = checks .* "\"\"" + for (i,r) in zip(symbols,results) + @test r ∈ REPL.doc_completions(i) + end +end @testset "fuzzy score" begin # https://github.com/JunoLab/FuzzyCompletions.jl/issues/7 # shouldn't throw when there is a space in a middle of query diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 1d59b6e057882..f156100b1df47 100644 --- a/stdlib/REPL/test/replcompletions.jl +++ b/stdlib/REPL/test/replcompletions.jl @@ -7,7 +7,7 @@ using REPL @testset "Check symbols previously not shown by REPL.doc_completions()" begin symbols = ["?","=","[]","[","]","{}","{","}",";","","'","&&","||","julia","Julia","new","@var_str"] for i in symbols - @test REPL.doc_completions(i)[1]==i + @test i ∈ REPL.doc_completions(i) end end let ex = quote