Skip to content

Commit

Permalink
Small fzf search QOL update. (#347)
Browse files Browse the repository at this point in the history
Uses the current REPL line as the initial query string for fzf. If fzf returns an empty result, inserts the initial line instead of the empty string.
  • Loading branch information
curtd authored Jun 29, 2024
1 parent 2670a0a commit 091b2b7
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/repl.jl
Original file line number Diff line number Diff line change
Expand Up @@ -267,12 +267,15 @@ function create_keybindings()
#replace search with Fzf fuzzy search
D["^R"] = function (s, data, c)
if VERSION >= v"1.3" && OhMyREPL.ENABLE_FZF[]
JLFzf = OhMyREPL.JLFzf
withenv("FZF_DEFAULT_OPTS" => nothing) do
current_line = LineEdit.input_string(s)
if !isempty(current_line)
line = JLFzf.inter_fzf(JLFzf.read_repl_hist(), "-m", "--read0", "--tiebreak=index", "--height=80%", "--query=$current_line");
else
line = JLFzf.inter_fzf(JLFzf.read_repl_hist(), "-m", "--read0", "--tiebreak=index", "--height=80%");
JLFzf.insert_history_to_repl(s, line)
end
rewrite_with_ANSI(s)
if isempty(line)
line = current_line
end
else
p = Base.active_repl.interface.modes[4]
LineEdit.enter_search(s, p, true)
Expand Down

0 comments on commit 091b2b7

Please sign in to comment.