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.
`commandline --current-process` treats newlines as process (pipe)
boundaries, which flattens multi-line snippets into a single line.
For example, a snippet like:
ffmpeg \
-i <input> \
-preset slow \
-codec:a aac
would be inserted as:
ffmpeg \ -i <input> \ -preset slow \ -codec:a aac
Replace with `commandline --replace` which operates on the full
buffer and preserves newlines. Add `end-of-line` to position the
cursor at the end after replacement. Quote variables and add `--`
to prevent snippets starting with `-` from being interpreted as
flags.
In the bash widget readline code make sure that bash's `patsub_replacement` is temporarily unset to avoid having ${input}_NAVIEND in the final command when the expanded $replacement contains `&`
fish v4 introduced new multiline prompt rendering behavior that breaks
when interactive commands like `navi` are injected via keybindings. this
resulted in partial prefix symbols (e.g. from a prompt's newline
component) being left on screen and improperly rendering the expanded
command (e.g. `gzgzip` instead of `gzip`).
this forces a full redraw so it's cosmetically identical to running
`navi` (as a command without insertion)
Moved the plugin as a module in order to have the Invoke-NaviWidget function defined in every session
Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com>
This commit updates the legacy assignment and lambda syntax from the Elvish widget so it works on v0.17 without deprecation errors. This commit also refactors some of the code so it's cleaner.