mirror of
https://github.com/Llewellynvdm/fzf.git
synced 2024-11-26 23:06:34 +00:00
Use exact match by default for inverse search term
This is a breaking change, but I believe it makes much more sense. It is almost impossible to predict which entries will be filtered out due to a fuzzy inverse term. You can still perform inverse-fuzzy-match by prepending `!'` to the term. | Token | Match type | Description | | -------- | -------------------------- | --------------------------------- | | `sbtrkt` | fuzzy-match | Items that match `sbtrkt` | | `^music` | prefix-exact-match | Items that start with `music` | | `.mp3$` | suffix-exact-match | Items that end with `.mp3` | | `'wild` | exact-match (quoted) | Items that include `wild` | | `!fire` | inverse-exact-match | Items that do not include `fire` | | `!.mp3$` | inverse-suffix-exact-match | Items that do not end with `.mp3` |
This commit is contained in:
parent
154cf22ffa
commit
aeb957a285
@ -163,12 +163,13 @@ func parseTerms(fuzzy bool, caseMode Case, str string) []termSet {
|
||||
|
||||
if strings.HasPrefix(text, "!") {
|
||||
inv = true
|
||||
typ = termExact
|
||||
text = text[1:]
|
||||
}
|
||||
|
||||
if strings.HasPrefix(text, "'") {
|
||||
// Flip exactness
|
||||
if fuzzy {
|
||||
if fuzzy && !inv {
|
||||
typ = termExact
|
||||
text = text[1:]
|
||||
} else {
|
||||
|
@ -22,15 +22,15 @@ func TestParseTermsExtended(t *testing.T) {
|
||||
terms[1][0].typ != termExact || terms[1][0].inv ||
|
||||
terms[2][0].typ != termPrefix || terms[2][0].inv ||
|
||||
terms[3][0].typ != termSuffix || terms[3][0].inv ||
|
||||
terms[4][0].typ != termFuzzy || !terms[4][0].inv ||
|
||||
terms[5][0].typ != termExact || !terms[5][0].inv ||
|
||||
terms[4][0].typ != termExact || !terms[4][0].inv ||
|
||||
terms[5][0].typ != termFuzzy || !terms[5][0].inv ||
|
||||
terms[6][0].typ != termPrefix || !terms[6][0].inv ||
|
||||
terms[7][0].typ != termSuffix || !terms[7][0].inv ||
|
||||
terms[7][1].typ != termEqual || terms[7][1].inv ||
|
||||
terms[8][0].typ != termPrefix || terms[8][0].inv ||
|
||||
terms[8][1].typ != termExact || terms[8][1].inv ||
|
||||
terms[8][2].typ != termSuffix || terms[8][2].inv ||
|
||||
terms[8][3].typ != termFuzzy || !terms[8][3].inv {
|
||||
terms[8][3].typ != termExact || !terms[8][3].inv {
|
||||
t.Errorf("%s", terms)
|
||||
}
|
||||
for idx, termSet := range terms[:8] {
|
||||
|
Loading…
Reference in New Issue
Block a user