From aa87ad49cd8ccbbce2dff1621883844353623606 Mon Sep 17 00:00:00 2001 From: Lam Chau Date: Fri, 6 Mar 2026 02:24:50 -0800 Subject: [PATCH] fix: always repaint prompt after fzf exits in fish widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- shell/navi.plugin.fish | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/shell/navi.plugin.fish b/shell/navi.plugin.fish index 7a26e77..4351ea5 100644 --- a/shell/navi.plugin.fish +++ b/shell/navi.plugin.fish @@ -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