Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor match (specifically the "suffix-exact-match") doesn't seems to be working as expected! #3983

Open
5 of 10 tasks
CodesOfRishi opened this issue Aug 31, 2024 · 3 comments
Labels

Comments

@CodesOfRishi
Copy link

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.55.0 (fc69308)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Suppose I have a file named jj containing the below data.

1725128905:/home/rishi:33:3.5262450218
1725129754:/home/rishi/testing:25:3.2580965380
1725116690:/home/rishi/.config/kitty:20:3.0429883472
1725120058:/home/rishi/.bashrc.d:12:2.5639900558
1725105557:/home/rishi/dotfiles:8:2.1951743677
1725128911:/etc:4:1.6093855692
1725105539:/home/rishi/dotfiles/Git:3:1.3849998610
1725093469:/home/rishi/Downloads:3:1.3843550671
1725115026:/home/rishi/testing/ddd:1:.6927534393

Considering : as a delimiter here, the directory paths in the file should be the 2nd column.

Using ^ search syntax

  • Searching with ^ works as expected.
  • Command ran - cat jj | fzf --delimiter=":" --nth=2 --height 40%

Example-1:

image

Example-2:

image

Using $ search syntax

  • However, searching with $ doesn't seems to be working as expected.
  • Command ran - cat jj | fzf --delimiter=":" --nth=2 --height 20%

Example-1:

image

Example:-2:

image

I hope I am not missing anything.

@CodesOfRishi
Copy link
Author

Also, I don't use FZF on shells or operating systems other than Bash and Linux. Therefore, I'm unsure if it behaves the same way on other platforms or not.

@junegunn
Copy link
Owner

junegunn commented Sep 1, 2024

Each token keeps its trailing non-whitespace delimiter. It was an early decision to make --with-nth work better with tabular data, but admittedly it doesn't work well with anchored matches with --nth as you have noticed. We may change this in the future, but for now, it is how it is, and you have to include the delimiter in your search term. i.e. kitty:$

fzf --delimiter=":" --nth=2 --query 'kitty:$' << EOF
1725128905:/home/rishi:33:3.5262450218
1725129754:/home/rishi/testing:25:3.2580965380
1725116690:/home/rishi/.config/kitty:20:3.0429883472
1725120058:/home/rishi/.bashrc.d:12:2.5639900558
1725105557:/home/rishi/dotfiles:8:2.1951743677
1725128911:/etc:4:1.6093855692
1725105539:/home/rishi/dotfiles/Git:3:1.3849998610
1725093469:/home/rishi/Downloads:3:1.3843550671
1725115026:/home/rishi/testing/ddd:1:.6927534393
EOF

However, fzf does ignore whitespace delimiters when matching so this should work as expected.

tr ':' ' ' << EOF | column -t | fzf --nth=2 --query 'kitty$'
1725128905:/home/rishi:33:3.5262450218
1725129754:/home/rishi/testing:25:3.2580965380
1725116690:/home/rishi/.config/kitty:20:3.0429883472
1725120058:/home/rishi/.bashrc.d:12:2.5639900558
1725105557:/home/rishi/dotfiles:8:2.1951743677
1725128911:/etc:4:1.6093855692
1725105539:/home/rishi/dotfiles/Git:3:1.3849998610
1725093469:/home/rishi/Downloads:3:1.3843550671
1725115026:/home/rishi/testing/ddd:1:.6927534393
EOF

@CodesOfRishi
Copy link
Author

Ok, thanks for the clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants