From a0942e56725f657b72a25426f1fa066604002d28 Mon Sep 17 00:00:00 2001 From: Shuhei Kadowaki Date: Wed, 18 Nov 2020 23:22:53 +0900 Subject: [PATCH] strip preceding ! operator --- src/eval.jl | 1 + src/goto.jl | 1 + test/goto.jl | 15 +++++++++++++++ 3 files changed, 17 insertions(+) diff --git a/src/eval.jl b/src/eval.jl index a0a7c181..0e4b7c9a 100644 --- a/src/eval.jl +++ b/src/eval.jl @@ -205,6 +205,7 @@ handle("docs") do data end function docs(word, mod = "Main") + word = replace(word, r"\!+([^=\(]+)" => s"\1") # strip preceding ! operator docstring = @errs getdocs(mod, word) docstring isa EvalError && return Dict(:error => true) diff --git a/src/goto.jl b/src/goto.jl index 7cedf841..867fa2da 100644 --- a/src/goto.jl +++ b/src/goto.jl @@ -26,6 +26,7 @@ function gotosymbol( # module context mod = "Main", text = "" ) + word = replace(word, r"\!+([^=\(]+)" => s"\1") # strip preceding ! operator try # local goto if !onlyglobal diff --git a/test/goto.jl b/test/goto.jl index c0e57396..553b9a95 100644 --- a/test/goto.jl +++ b/test/goto.jl @@ -45,6 +45,21 @@ @test (Atom.localgotoitem("word", nothing, 1, 1, 0, ""); true) end + @testset "strip preceding ! operator" begin + using Atom: gotosymbol + let + ret = gotosymbol("!isnothing") + @test isdefined(ret, :items) + @test !isempty(ret.items) + end + + let + ret = gotosymbol("!") + @test isdefined(ret, :items) + @test !isempty(ret.items) + end + end + @testset "goto global symbols" begin using Atom: globalgotoitems, toplevelgotoitems, SYMBOLSCACHE, updatesymbols, clearsymbols, regeneratesymbols, methodgotoitems