Allow suffix match on --nth with custom --delimiter

When --nth is used with a custom --delimiter, the last delimiter was
included in the search scope, forcing you to write the delimiter in
a suffix-match query. This commit removes the last delimiter from the
search scope.

  # No need to write 'bar,$'
  echo foo,bar,baz | fzf --delimiter , --nth 2 --filter 'bar$'

This can be seen as a breaking change, but I'm gonna say it's a bug fix.

Fix #3983
This commit is contained in:
Junegunn Choi
2025-02-12 20:50:01 +09:00
parent 84e2262ad6
commit 9abf2c8c9c
3 changed files with 18 additions and 2 deletions

View File

@@ -52,6 +52,12 @@ class TestFilter < TestBase
`find . -print0 | #{FZF} --read0 -e -f "^#{lines.last}$"`.chomp
end
def test_nth_suffix_match
assert_equal \
'foo,bar,baz',
`echo foo,bar,baz | #{FZF} -d, -f'bar$' -n2`.chomp
end
def test_with_nth_basic
writelines(['hello world ', 'byebye'])
assert_equal \