diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2017-08-10 23:59:40 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2017-08-10 23:59:52 +0900 |
commit | 02a7b96f33036192abb5816b5860e546e6b4e64e (patch) | |
tree | ac1e1ecbbd08db5c7df0979ca08209437857b35d | |
parent | e55e029ae8002c46e117d55bdfcc725b69bc21ef (diff) |
Treat $ as proper search query
When $ is the leading character in a query, it's probably not meant to
be an anchor.
-rw-r--r-- | src/pattern.go | 2 | ||||
-rw-r--r-- | src/pattern_test.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/pattern.go b/src/pattern.go index 35a2f33c..8029fd0c 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -175,7 +175,7 @@ func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet text = text[1:] } - if strings.HasSuffix(text, "$") { + if text != "$" && strings.HasSuffix(text, "$") { if strings.HasSuffix(text, "\\$") { text = text[:len(text)-2] + "$" } else { diff --git a/src/pattern_test.go b/src/pattern_test.go index efb1ef2d..7adc51db 100644 --- a/src/pattern_test.go +++ b/src/pattern_test.go @@ -58,7 +58,7 @@ func TestParseTermsExtendedExact(t *testing.T) { } func TestParseTermsEmpty(t *testing.T) { - terms := parseTerms(true, CaseSmart, false, "' $ ^ !' !^ !$") + terms := parseTerms(true, CaseSmart, false, "' ^ !' !^") if len(terms) != 0 { t.Errorf("%s", terms) } |