junegunn / fzf

:cherry_blossom: A command-line fuzzy finder
https://junegunn.github.io/fzf/
MIT License
64.25k stars 2.38k forks source link

Question: What's the expected behavior with --nth and --with-nth together? #3873

Closed malkomalko closed 3 months ago

malkomalko commented 3 months ago

Checklist

Output of fzf --version

0.52.1 (brew)

OS

Shell

Problem / Steps to reproduce

Hi There,

After reading the man page, my expectation would be that I can control which fields are displayed in the list (--with-nth) and which fields can be used to search over (--nth). However, If I had something like --nth=1,4.. --with-nth=4.. I can not use the 1st column to search and filter the list since it's not displayed.

Thanks

LangLangBart commented 3 months ago

What's the expected behavior with --nth and --with-nth together?

Initially, I assumed that any values assigned to either flag would reflect the original data. However, --nth applies solely to what remains visible after the transformation by --with-nth.

Thus, one must anticipate the structure after the transformation and accordingly assign the --nth flag.

printf "%s\n" {1..9} | xargs -n 3
# 1 2 3
# 4 5 6
# 7 8 9

❌ No results for the commands below, as 1 is not visible, and 5 is excluded because of --nth 2...

printf "%s\n" {1..9} | xargs -n 3 | fzf --with-nth 2.. --nth 2.. --filter="1"
printf "%s\n" {1..9} | xargs -n 3 | fzf --with-nth 2.. --nth 2.. --filter="5"

✅ Result found

printf "%s\n" {1..9} | xargs -n 3 | fzf --with-nth 2.. --nth 2.. --filter="9"
# 7 8 9
junegunn commented 3 months ago

What @LangLangBart described is correct. --nth is applied after --with-nth transformation is done, and fzf doesn't allow searching against hidden parts. I thought this was mentioned somewhere in the manual page, but it doesn't seem to be.