From 02a7b96f33036192abb5816b5860e546e6b4e64e Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Thu, 10 Aug 2017 23:59:40 +0900 Subject: [PATCH] Treat $ as proper search query When $ is the leading character in a query, it's probably not meant to be an anchor. --- src/pattern.go | 2 +- 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) }