From e85a8a68d0248a6edfb6ef63c5edb4bcbe18f954 Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Wed, 9 Aug 2017 23:25:32 +0900 Subject: Allow escaping meta characters with backslashes One can escape meta characters in extended-search mode with backslashes. Prefixes: \' \! \^ Suffix: \$ Term separator: \ To keep things simple, we are not going to support escaping of escaped sequences (e.g. \\') for matching them literally. Since this is a breaking change, we will bump the minor version. Close #444 --- src/pattern_test.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/pattern_test.go') diff --git a/src/pattern_test.go b/src/pattern_test.go index 9d56ff9f..efb1ef2d 100644 --- a/src/pattern_test.go +++ b/src/pattern_test.go @@ -165,15 +165,15 @@ func TestCacheKey(t *testing.T) { t.Errorf("Expected: %s, actual: %s", expected, pat.CacheKey()) } if pat.cacheable != cacheable { - t.Errorf("Expected: %s, actual: %s (%s)", cacheable, pat.cacheable, patStr) + t.Errorf("Expected: %t, actual: %t (%s)", cacheable, pat.cacheable, patStr) } clearPatternCache() } test(false, "foo !bar", "foo !bar", true) test(false, "foo | bar !baz", "foo | bar !baz", true) - test(true, "foo bar baz", "foo bar baz", true) + test(true, "foo bar baz", "foo\tbar\tbaz", true) test(true, "foo !bar", "foo", false) - test(true, "foo !bar baz", "foo baz", false) + test(true, "foo !bar baz", "foo\tbaz", false) test(true, "foo | bar baz", "baz", false) test(true, "foo | bar | baz", "", false) test(true, "foo | bar !baz", "", false) @@ -192,11 +192,11 @@ func TestCacheable(t *testing.T) { } clearPatternCache() } - test(true, "foo bar", "foo bar", true) - test(true, "foo 'bar", "foo bar", false) + test(true, "foo bar", "foo\tbar", true) + test(true, "foo 'bar", "foo\tbar", false) test(true, "foo !bar", "foo", false) - test(false, "foo bar", "foo bar", true) + test(false, "foo bar", "foo\tbar", true) test(false, "foo 'bar", "foo", false) test(false, "foo '", "foo", true) test(false, "foo 'bar", "foo", false) -- cgit v1.2.3