Skip to content

Fix --accept-nth being ignored in filter mode#4636

Merged
junegunn merged 2 commits into
junegunn:masterfrom
charemma:fix/accept-nth-filter-mode-4615
Dec 19, 2025
Merged

Fix --accept-nth being ignored in filter mode#4636
junegunn merged 2 commits into
junegunn:masterfrom
charemma:fix/accept-nth-filter-mode-4615

Conversation

@charemma

@charemma charemma commented Dec 16, 2025

Copy link
Copy Markdown
Contributor

The --accept-nth option wasn't working with --filter mode. It would just ignore the field selection and print the whole line instead of the specified fields.

I ran into this when trying to use filter mode in a script where I wanted to filter by one field but output another (like showing names but returning IDs). Turns out filter mode just wasn't applying the field transformer at all - it was only working in interactive mode.

Fixed it by adding a buildItemTransformer() helper function that's now used consistently across filter mode (both streaming and non-streaming paths) and the select1/exit0 modes.

Tested with various delimiter and field configs, all the go tests still pass.

Examples that now work:

$ echo 'one two three' | fzf -d ' ' --with-nth 1 --accept-nth -1 -f one
three

$ echo 'ID001:John:Developer' | fzf -d ':' --with-nth 2 --accept-nth 1 -f John
ID001

Fixes #4615

@charemma charemma force-pushed the fix/accept-nth-filter-mode-4615 branch from c77e233 to 6b6531c Compare December 16, 2025 14:53
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 junegunn#4615
@charemma charemma force-pushed the fix/accept-nth-filter-mode-4615 branch from 6b6531c to 0843c67 Compare December 16, 2025 14:53
@junegunn

Copy link
Copy Markdown
Owner

Thanks, could you add a test case for this in https://github.com/junegunn/fzf/blob/master/test/test_filter.rb?

@charemma

Copy link
Copy Markdown
Contributor Author

Added a test case in test_filter.rb that covers single field selection, multiple fields, and different delimiters.

@charemma charemma force-pushed the fix/accept-nth-filter-mode-4615 branch from 85fb8fd to d861bc8 Compare December 17, 2025 09:33
@junegunn junegunn merged commit 8d68852 into junegunn:master Dec 19, 2025
5 checks passed
@junegunn

Copy link
Copy Markdown
Owner

Merged, thanks!

@charemma charemma deleted the fix/accept-nth-filter-mode-4615 branch December 19, 2025 15:30
eli-percepto pushed a commit to eli-percepto/fzf that referenced this pull request Feb 3, 2026
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 junegunn#4615
tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Feb 25, 2026
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [junegunn/fzf](https://github.com/junegunn/fzf) | minor | `v0.67.0` → `v0.68.0` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>junegunn/fzf (junegunn/fzf)</summary>

### [`v0.68.0`](https://github.com/junegunn/fzf/releases/tag/v0.68.0): 0.68.0

[Compare Source](junegunn/fzf@v0.67.0...v0.68.0)

<https://github.com/user-attachments/assets/8d9e6e29-1bde-49d3-b580-c560da394a5d>

- Implemented word wrapping in the list section
  - Added `--wrap=word` (or `--wrap-word`) option and `toggle-wrap-word` action for word-level line wrapping in the list section
  - Changed default binding of `ctrl-/` and `alt-/` from `toggle-wrap` to `toggle-wrap-word`
  ```sh
  fzf --wrap=word
  ```
- Implemented word wrapping in the preview window
  - Added `wrap-word` flag for `--preview-window` to enable word-level wrapping
  - Added `toggle-preview-wrap-word` action
  ```sh
  fzf --preview 'bat --style=plain --color=always {}' \
      --preview-window wrap-word \
      --bind space:toggle-preview-wrap-word
  ```
- Added support for underline style variants in `--color`: `underline-double`, `underline-curly`, `underline-dotted`, `underline-dashed`
  ```sh
  fzf --color 'fg:underline-curly,current-fg:underline-dashed'
  ```
- Added support for underline styles (`4:N`) and underline colors (SGR 58/59)
  ```sh
  # In the list section
  printf '\e[4:3;58;2;255;0;0mRed curly underline\e[0m\n' | fzf --ansi

  # In the preview window
  fzf --preview "printf '\e[4:3;58;2;255;0;0mRed curly underline\e[0m\n'"
  ```
- Added `--preview-wrap-sign` to set a different wrap indicator for the preview window
- Added `alt-gutter` color option ([#&#8203;4602](junegunn/fzf#4602)) ([@&#8203;hedgieinsocks](https://github.com/hedgieinsocks))
- Added `$FZF_WRAP` environment variable to child processes (`char` or `word` when wrapping is enabled) ([#&#8203;4672](junegunn/fzf#4672)) ([@&#8203;bitraid](https://github.com/bitraid))
- fish: Improved command history (CTRL-R) ([#&#8203;4672](junegunn/fzf#4672)) ([@&#8203;bitraid](https://github.com/bitraid))
  - Enabled syntax highlighting in the list on fish 4.3.3+
  - Added syntax-highlighted preview window that auto-shows for long or multi-line commands
  - Added `ALT-ENTER` to reformat and insert selected commands
  - Improved handling of bulk deletion of selected history entries (`SHIFT-DELETE`)
- Added fish completion support ([#&#8203;4605](junegunn/fzf#4605)) ([@&#8203;lalvarezt](https://github.com/lalvarezt))
- zsh: Handle multi-line history selection ([#&#8203;4595](junegunn/fzf#4595)) ([@&#8203;LangLangBart](https://github.com/LangLangBart))
- Bug fixes
  - Fixed `_fzf_compgen_{path,dir}` to respect `FZF_COMPLETION_{PATH,DIR}_OPTS` ([#&#8203;4592](junegunn/fzf#4592)) ([@&#8203;shtse8](https://github.com/shtse8), [@&#8203;LangLangBart](https://github.com/LangLangBart))
  - Fixed `--preview-window follow` not working correctly with wrapping ([#&#8203;3243](junegunn/fzf#3243), [#&#8203;4258](junegunn/fzf#4258))
  - Fixed symlinks to directories being returned as files ([#&#8203;4676](junegunn/fzf#4676)) ([@&#8203;skk64](https://github.com/skk64))
  - Fixed SIGHUP signal handling ([#&#8203;4668](junegunn/fzf#4668)) ([@&#8203;LangLangBart](https://github.com/LangLangBart))
  - Fixed preview process not killed on exit ([#&#8203;4667](junegunn/fzf#4667))
  - Fixed coloring of items with zero-width characters ([#&#8203;4620](junegunn/fzf#4620))
  - Fixed `track-current` unset after a combined movement action ([#&#8203;4649](junegunn/fzf#4649))
  - Fixed `--accept-nth` being ignored in filter mode ([#&#8203;4636](junegunn/fzf#4636)) ([@&#8203;charemma](https://github.com/charemma))
  - Fixed display width calculation with `maxWidth` ([#&#8203;4596](junegunn/fzf#4596)) ([@&#8203;LangLangBart](https://github.com/LangLangBart))
  - Fixed clearing of the rest of the current line on start ([#&#8203;4652](junegunn/fzf#4652))
  - Fixed `x-api-key` header not required for GET requests ([#&#8203;4627](junegunn/fzf#4627))
  - Fixed key reading not cancelled when `execute` triggered via a server request ([#&#8203;4653](junegunn/fzf#4653))
  - Fixed rebind of readline command `redraw-current-line` ([#&#8203;4635](junegunn/fzf#4635)) ([@&#8203;jameslazo](https://github.com/jameslazo))
  - Fixed `fzf-tmux` `TERM` quoting and added `mktemp` usage ([#&#8203;4664](junegunn/fzf#4664)) ([@&#8203;Goofygiraffe06](https://github.com/Goofygiraffe06))
  - Do not allow very long queries in `FuzzyMatchV2` ([#&#8203;4608](junegunn/fzf#4608))

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4yNS44IiwidXBkYXRlZEluVmVyIjoiNDMuMjYuNCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiUmVub3ZhdGUgQm90IiwiYXV0b21hdGlvbjpib3QtYXV0aG9yZWQiLCJkZXBlbmRlbmN5LXR5cGU6Om1pbm9yIl19-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--accept-nth ignored with --filter

2 participants