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

Add optional substring matching for picker #5114

Merged
merged 1 commit into from Feb 2, 2023

Conversation

pascalkuthe
Copy link
Member

This PR implements common syntax that allows matching substrings instead of fuzzy matching.
I will quote the fzf README here for an explanation what exactly this does:

Token Match type Description
sbtrkt fuzzy-match Items that match sbtrkt
'wild exact-match (quoted) Items that include wild
^music prefix-exact-match Items that start with music
.mp3$ suffix-exact-match Items that end with .mp3
!fire inverse-exact-match Items that do not include fire
!^music inverse-prefix-exact-match Items that do not start with music
!.mp3$ inverse-suffix-exact-match Items that do not end with .mp3

All of these can be escaped by inserting a backslash \!, \^, \' and \$ (not mentioned in the README but tested in practice).
The implementation here closely matches the behavior of both fzf and skim (which behave identical)

I found myself needing these recently.
In particular, I found myself missing the inverse matches.
I work on a circuit simulator (ngspice) which has some core code and then some device models (also just c code).
When I was refactoring core parts of the simulator I wanted to use gr to find all references.
However, this was polluted by thousands of references in the device models (all of which are inside the devices folder).
So just being able to add ^devices in the picker was invaluable.

While looking into this I found myself warming up to the other options as well, for example with #5110 ^E can be used to filter only errors or !^H can be used to ignore hints.

@pascalkuthe pascalkuthe added C-enhancement Category: Improvements A-helix-term Area: Helix term improvements S-waiting-on-review Status: Awaiting review from a maintainer. labels Dec 10, 2022
@pascalkuthe pascalkuthe force-pushed the exact_match branch 2 times, most recently from dd0cdcd to 0fcdb71 Compare December 13, 2022 13:34
@archseer archseer merged commit f0c2e89 into helix-editor:master Feb 2, 2023
@LeoniePhiline
Copy link
Contributor

@pascalkuthe Love your example. Wildfire by sbtrkt is truly awesome! :)

@pascalkuthe pascalkuthe deleted the exact_match branch February 2, 2023 20:00
@pascalkuthe
Copy link
Member Author

pascalkuthe commented Feb 2, 2023

@pascalkuthe Love your example. Wildfire by sbtrkt is truly awesome! :)

I had no idea what that was until you brough it up 😅 The examples are from the FZF README as I am mirroring the fzf/skim syntax here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-enhancement Category: Improvements S-waiting-on-review Status: Awaiting review from a maintainer.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants