From af0014aba8bc49f6acb35f96cb9642bf3d163edd Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sun, 3 Aug 2025 00:28:50 +0900 Subject: [PATCH] Fix a bug where you cannot unset the default `--nth` using `change-nth` --- CHANGELOG.md | 1 + src/terminal.go | 2 +- test/test_core.rb | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca524250..5d344de6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ CHANGELOG 0.65.1 ------ - Fixed incorrect `$FZF_CLICK_HEADER_WORD` and `$FZF_CLICK_FOOTER_WORD` when the header or footer contains ANSI escape sequences and tab characters. +- Fixed a bug where you cannot unset the default `--nth` using `change-nth` action. 0.65.0 ------ diff --git a/src/terminal.go b/src/terminal.go index 9c34eca0..0fd5d006 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -5726,7 +5726,7 @@ func (t *Terminal) Loop() error { capture(true, func(expr string) { // Split nth expression tokens := strings.Split(expr, "|") - if nth, err := splitNth(tokens[0]); err == nil { + if nth, err := splitNth(tokens[0]); err == nil || len(expr) == 0 { // Changed newNth = &nth } else { diff --git a/test/test_core.rb b/test/test_core.rb index 17578baf..d77bbcce 100644 --- a/test/test_core.rb +++ b/test/test_core.rb @@ -2045,4 +2045,19 @@ class TestCore < TestInteractive tmux.send_keys :b tmux.until { |lines| assert_includes lines, '> 9' } end + + def test_change_nth_unset_default + tmux.send_keys %(echo foo bar | #{FZF} --nth 2 --query fb --bind space:change-nth:), :Enter + tmux.until do + assert_equal 1, it.item_count + assert_equal 0, it.match_count + end + + tmux.send_keys :Space + + tmux.until do + assert_equal 1, it.item_count + assert_equal 1, it.match_count + end + end end