From 9017e297417bc20c89e1e7c9ce47f1c2fbbfd5fc Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Sat, 12 Sep 2015 11:00:30 +0900 Subject: [PATCH] Make it possible to unquote the term in extended-exact mode Close #338 --- README.md | 3 ++- src/pattern.go | 3 +++ src/pattern_test.go | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2bbdff7..6ec5fbc 100644 --- a/README.md +++ b/README.md @@ -125,7 +125,8 @@ such as: `^music .mp3$ sbtrkt !rmx` | `!'fire` | Items that do not include `fire` | inverse-exact-match | If you don't need fuzzy matching and do not wish to "quote" every word, start -fzf with `-e` or `--extended-exact` option. +fzf with `-e` or `--extended-exact` option. Note that in `--extended-exact` +mode, `'`-prefix "unquotes" the term. #### Environment variables diff --git a/src/pattern.go b/src/pattern.go index f83861e..cfeb68d 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -151,6 +151,9 @@ func parseTerms(mode Mode, caseMode Case, str string) []term { if mode == ModeExtended { typ = termExact text = text[1:] + } else if mode == ModeExtendedExact { + typ = termFuzzy + text = text[1:] } } else if strings.HasPrefix(text, "^") { if strings.HasSuffix(text, "$") { diff --git a/src/pattern_test.go b/src/pattern_test.go index c7f5414..66f5d41 100644 --- a/src/pattern_test.go +++ b/src/pattern_test.go @@ -37,11 +37,11 @@ func TestParseTermsExtendedExact(t *testing.T) { "aaa 'bbb ^ccc ddd$ !eee !'fff !^ggg !hhh$") if len(terms) != 8 || terms[0].typ != termExact || terms[0].inv || len(terms[0].text) != 3 || - terms[1].typ != termExact || terms[1].inv || len(terms[1].text) != 4 || + terms[1].typ != termFuzzy || terms[1].inv || len(terms[1].text) != 3 || terms[2].typ != termPrefix || terms[2].inv || len(terms[2].text) != 3 || terms[3].typ != termSuffix || terms[3].inv || len(terms[3].text) != 3 || terms[4].typ != termExact || !terms[4].inv || len(terms[4].text) != 3 || - terms[5].typ != termExact || !terms[5].inv || len(terms[5].text) != 4 || + terms[5].typ != termFuzzy || !terms[5].inv || len(terms[5].text) != 3 || terms[6].typ != termPrefix || !terms[6].inv || len(terms[6].text) != 3 || terms[7].typ != termSuffix || !terms[7].inv || len(terms[7].text) != 3 { t.Errorf("%s", terms)