From f09006846b91daf862f3288246ce69095a8c12dc Mon Sep 17 00:00:00 2001 From: rootiest Date: Mon, 18 May 2026 21:47:20 -0400 Subject: [PATCH] fix(fzf): drop focus/resize bind entirely on older fzf builds Older fzf (pre-0.62) does not support the focus and resize events in bind actions, causing a startup error when --fish or the bundled integration is sourced. Split the FZF_DEFAULT_OPTS preview block into an if/else: newer fzf gets the dynamic bg-transform bind with wrap-word; older fzf gets a static preview window with plain wrap and no event bind. --- integrations/fzf.fish | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/integrations/fzf.fish b/integrations/fzf.fish index b3ee476..8bd410a 100644 --- a/integrations/fzf.fish +++ b/integrations/fzf.fish @@ -221,13 +221,18 @@ function fzf_key_bindings end # Prepend the options to allow user customizations - # wrap-word requires the same newer fzf as bg-transform; fall back to plain wrap - set -l _fzf_wrap_opt wrap - test "$_fzf_transform_action" = bg-transform; and set _fzf_wrap_opt wrap-word - set -p -- FZF_DEFAULT_OPTS \ - '--bind="focus,resize:'$_fzf_transform_action':if test \\"$FZF_COLUMNS\\" -gt 100 -a \\\\( \\"$FZF_SELECT_COUNT\\" -gt 0 -o \\\\( -z \\"$FZF_WRAP\\" -a (string length -- {}) -gt (math $FZF_COLUMNS - 4) \\\\) -o (string collect -- {2..} | fish_indent | count) -gt 1 \\\\); echo show-preview; else echo hide-preview; end"' \ - '--preview="string collect -- (test \\"$FZF_SELECT_COUNT\\" -gt 0; and string collect -- {+2..}) \\"\\n# \\"'$date_cmd' {2..} | fish_indent --ansi"' \ - '--preview-window="right,50%,'$_fzf_wrap_opt',follow,info,hidden"' + if test "$_fzf_transform_action" = bg-transform + # Newer fzf: dynamic show/hide preview based on terminal width + set -p -- FZF_DEFAULT_OPTS \ + '--bind="focus,resize:bg-transform:if test \\"$FZF_COLUMNS\\" -gt 100 -a \\\\( \\"$FZF_SELECT_COUNT\\" -gt 0 -o \\\\( -z \\"$FZF_WRAP\\" -a (string length -- {}) -gt (math $FZF_COLUMNS - 4) \\\\) -o (string collect -- {2..} | fish_indent | count) -gt 1 \\\\); echo show-preview; else echo hide-preview; end"' \ + '--preview="string collect -- (test \\"$FZF_SELECT_COUNT\\" -gt 0; and string collect -- {+2..}) \\"\\n# \\"'$date_cmd' {2..} | fish_indent --ansi"' \ + '--preview-window="right,50%,wrap-word,follow,info,hidden"' + else + # Older fzf: static preview; focus/resize events not reliably supported + set -p -- FZF_DEFAULT_OPTS \ + '--preview="string collect -- (test \\"$FZF_SELECT_COUNT\\" -gt 0; and string collect -- {+2..}) \\"\\n# \\"'$date_cmd' {2..} | fish_indent --ansi"' \ + '--preview-window="right,50%,wrap,follow,info"' + end end set -lx FZF_DEFAULT_OPTS_FILE