Skip to content
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
23 changes: 16 additions & 7 deletions src/InteractiveCodeSearch.jl
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ struct Recursive <: SearchPolicy end

mutable struct SearchConfig # CONFIG
open
interactive_matcher::Cmd
interactive_matcher::Union{Nothing,Cmd}
auto_open::Bool
trigger_key::Union{Nothing,Char}
end
Expand Down Expand Up @@ -188,8 +188,7 @@ function parse_loc(line)
end

function run_matcher(input)
maybe_warn_matcher()
return String(read_stdout(input, CONFIG.interactive_matcher))
return String(read_stdout(input, get_interactive_matcher()))
end

choose_method(methods::T) where T =
Expand Down Expand Up @@ -284,7 +283,7 @@ using InteractiveCodeSearch
"""
const CONFIG = SearchConfig(
edit, # open
`peco`, # interactive_matcher
nothing, # interactive_matcher
true, # auto_open
')', # trigger_key
)
Expand Down Expand Up @@ -553,14 +552,24 @@ function maybe_warn_matcher(cmd = CONFIG.interactive_matcher)
end
end

function get_interactive_matcher()
cmd = CONFIG.interactive_matcher
if cmd === nothing
CONFIG.interactive_matcher = cmd = choose_interactive_matcher()
end
cmd::Cmd
maybe_warn_matcher(cmd)
return cmd
end

function __init__()
CONFIG.interactive_matcher = choose_interactive_matcher()
setup_keybinds()
end

include("taskmanager.jl")
include("history.jl")
include("return.jl")
include("keybinds.jl")
if VERSION < v"1.2"
include("return.jl")
end

end # module
2 changes: 2 additions & 0 deletions src/return.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ export @searchreturn

using Base: unwrap_unionall

include("taskmanager.jl")

struct CallableFinder{P <: SearchPolicy}
modules::AbstractVector{Module}
sp::P
Expand Down