mirror of
https://github.com/junegunn/fzf.git
synced 2026-02-05 01:17:53 +08:00
Fix --accept-nth being ignored in filter mode (#4636)
The --accept-nth option was not being respected when using --filter mode. This caused fzf to output entire lines instead of only the specified fields. Added buildItemTransformer() helper function to consistently apply field transformations across filter mode (both streaming and non-streaming) and select1/exit0 modes. Fixes #4615
This commit is contained in:
committed by
GitHub
parent
775129367a
commit
8d688521fe
@@ -312,4 +312,18 @@ class TestFilter < TestBase
|
||||
assert_equal expected, result
|
||||
end
|
||||
end
|
||||
|
||||
def test_accept_nth
|
||||
# Single field selection
|
||||
assert_equal 'three', `echo 'one two three' | #{FZF} -d' ' --with-nth 1 --accept-nth -1 -f one`.chomp
|
||||
|
||||
# Multiple field selection
|
||||
writelines(['ID001:John:Developer', 'ID002:Jane:Manager', 'ID003:Bob:Designer'])
|
||||
assert_equal 'ID001', `#{FZF} -d: --with-nth 2 --accept-nth 1 -f John < #{tempname}`.chomp
|
||||
assert_equal "ID002:Manager", `#{FZF} -d: --with-nth 2 --accept-nth 1,3 -f Jane < #{tempname}`.chomp
|
||||
|
||||
# Test with different delimiters
|
||||
writelines(['emp001 Alice Engineering', 'emp002 Bob Marketing'])
|
||||
assert_equal 'emp001', `#{FZF} -d' ' --with-nth 2 --accept-nth 1 -f Alice < #{tempname}`.chomp
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user