fix: add version check for fish v4+

This commit is contained in:
Lam Chau 2025-06-06 13:24:02 -07:00
parent 023e52d1fb
commit 0076018ada

View file

@ -1,11 +1,24 @@
function _navi_smart_replace
set --local query (commandline --current-process | string trim)
set --local version_parts ""
if test -n "$version"
set version_parts (string split '.' $version)
else
set version_parts (string split '.' (string match -r '\d+\.\d+\.\d+' (fish --version)))
end
set --local force_repaint false
if test $version_parts[1] -ge 4
set force_repaint true
end
if test -n "$query"
set --local best_match (navi --print --query "$query" --best-match)
if test -n "$best_match"
commandline --current-process $best_match
commandline -f repaint
if test "$force_repaint" = true
commandline -f repaint
end
return
end
end
@ -13,7 +26,9 @@ function _navi_smart_replace
set --local candidate (navi --print --query "$query")
if test -n "$candidate"
commandline --current-process $candidate
commandline -f repaint
if test "$force_repaint" = true
commandline -f repaint
end
end
end