From 6c76d8cd1cf52a277221bc2f9c6e7762a6360129 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 11 Aug 2017 13:09:33 +0900 Subject: Disallow escaping of meta characters except for spaces https://github.com/junegunn/fzf/issues/444#issuecomment-321719604 --- src/pattern.go | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'src/pattern.go') diff --git a/src/pattern.go b/src/pattern.go index dbb3983f..8de15b98 100644 --- a/src/pattern.go +++ b/src/pattern.go @@ -54,15 +54,13 @@ type Pattern struct { } var ( - _patternCache map[string]*Pattern - _splitRegex *regexp.Regexp - _escapedPrefixRegex *regexp.Regexp - _cache ChunkCache + _patternCache map[string]*Pattern + _splitRegex *regexp.Regexp + _cache ChunkCache ) func init() { _splitRegex = regexp.MustCompile(" +") - _escapedPrefixRegex = regexp.MustCompile("^\\\\['!^|]") clearPatternCache() clearChunkCache() } @@ -179,17 +177,11 @@ func parseTerms(fuzzy bool, caseMode Case, normalize bool, str string) []termSet } if text != "$" && strings.HasSuffix(text, "$") { - if strings.HasSuffix(text, "\\$") { - text = text[:len(text)-2] + "$" - } else { - typ = termSuffix - text = text[:len(text)-1] - } + typ = termSuffix + text = text[:len(text)-1] } - if _escapedPrefixRegex.MatchString(text) { - text = text[1:] - } else if strings.HasPrefix(text, "'") { + if strings.HasPrefix(text, "'") { // Flip exactness if fuzzy && !inv { typ = termExact -- cgit v1.2.3