From f425ce7d440bc9da7361553e9894b122679740fa Mon Sep 17 00:00:00 2001 From: Moelf Date: Tue, 5 Jan 2021 17:28:25 -0500 Subject: [PATCH 1/2] improve str macro doc help --- stdlib/REPL/src/docview.jl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/stdlib/REPL/src/docview.jl b/stdlib/REPL/src/docview.jl index 9394c7f22ba68..e34c271c8bec3 100644 --- a/stdlib/REPL/src/docview.jl +++ b/stdlib/REPL/src/docview.jl @@ -645,7 +645,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)) From 9b9d89195c21f9062ffe1e8f0c1dc4a550358db0 Mon Sep 17 00:00:00 2001 From: Moelf Date: Mon, 22 Feb 2021 16:14:35 -0500 Subject: [PATCH 2/2] add string macro search result --- stdlib/REPL/test/docview.jl | 9 +++++++++ stdlib/REPL/test/replcompletions.jl | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/stdlib/REPL/test/docview.jl b/stdlib/REPL/test/docview.jl index a5935a0426434..0a0137e952fc8 100644 --- a/stdlib/REPL/test/docview.jl +++ b/stdlib/REPL/test/docview.jl @@ -27,3 +27,12 @@ end # https://github.com/JuliaLang/julia/issues/37757 @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 diff --git a/stdlib/REPL/test/replcompletions.jl b/stdlib/REPL/test/replcompletions.jl index 2478ca3c77720..826490d3a9b04 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