Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

strip preceding ! operator #358

Merged
merged 2 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/eval.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
12 changes: 11 additions & 1 deletion src/goto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -154,7 +155,16 @@ gen_new_cache() = PathItemsMap()
function toplevelgotoitems(word, mod, path, text)
key = string(mod)
pathitemsmap = if haskey(SYMBOLSCACHE, key)
SYMBOLSCACHE[key]
if haskey(SYMBOLSCACHE[key], path)
SYMBOLSCACHE[key]
else
orig = SYMBOLSCACHE[key]
maybe = collecttoplevelitems(mod, path, text)
if maybe !== nothing
merge!(orig, maybe)
end
orig
end
else
maybe = collecttoplevelitems(mod, path, text)
if maybe === nothing
Expand Down
15 changes: 15 additions & 0 deletions test/goto.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down