fix: always repaint prompt after fzf exits in fish widget

Previously, `repaint` only ran inside the `best_match` and `candidate`
branches, so cancelling out of navi (Ctrl+C / Esc) without selecting
a snippet would leave the terminal in a clobbered state. Multi-line
prompts (e.g. tide with ╭─/╰─ borders) would lose their border
characters because fzf overwrites the terminal output and no repaint
was triggered to restore it.

Move `repaint` to the end of the function so it always runs regardless
of whether a selection was made, the user cancelled, or no matches
were found. Remove the early `return` from the `best_match` branch
and gate the `candidate` fallback with `test -z "$best_match"` instead.
This commit is contained in:
Lam Chau 2026-03-06 02:24:50 -08:00
parent ec04fa91b4
commit aa87ad49cd

View file

@ -28,21 +28,21 @@ function _navi_smart_replace
# boundaries and flattens multi-line snippets into a single line
commandline --replace -- "$best_match"
commandline --function end-of-line
if test "$force_repaint" = true
commandline --function repaint
end
return
end
end
set --local candidate (navi --print --query "$query")
if test -n "$candidate"
commandline --replace -- "$candidate"
commandline --function end-of-line
if test "$force_repaint" = true
commandline --function repaint
if test -z "$best_match"
set --local candidate (navi --print --query "$query")
if test -n "$candidate"
commandline --replace -- "$candidate"
commandline --function end-of-line
end
end
# always repaint to restore the prompt after fzf clobbers the terminal
if test "$force_repaint" = true
commandline --function repaint
end
end
bind \cg _navi_smart_replace