Skip to content
Myr

Treat | as proper query when it can't be an OR operator

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Junegunn Choi · committed by Junegunn Choi · parent 02a7b96 · Browse files · 2 files+7 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−3 removed

  • other:+7 added−3 removed

2 files+7 added−3 removed

modified:src/pattern_test.go+3 added-2 removed
14 unmodified lines
15}1617func TestParseTermsExtended(t *testing.T) {18 terms := parseTerms(true, CaseSmart, false,19 "| aaa 'bbb ^ccc ddd$ !eee !'fff !^ggg !hhh$ | ^iii$ ^xxx | 'yyy | | zzz$ | !ZZZ |")19 "aaa 'bbb ^ccc ddd$ !eee !'fff !^ggg !hhh$ | ^iii$ ^xxx | 'yyy | zzz$ | !ZZZ |")20 if len(terms) != 9 ||21 terms[0][0].typ != termFuzzy || terms[0][0].inv ||22 terms[1][0].typ != termExact || terms[1][0].inv ||23 terms[2][0].typ != termPrefix || terms[2][0].inv ||
152 unmodified lines
176 test(true, "foo !bar baz", "foo\tbaz", false)177 test(true, "foo | bar baz", "baz", false)178 test(true, "foo | bar | baz", "", false)179 test(true, "foo | bar !baz", "", false)180 test(true, "| | | foo", "foo", true)180 test(true, "| | foo", "", false)181 test(true, "| | | foo", "foo", false)182}183184func TestCacheable(t *testing.T) {185 test := func(fuzzy bool, str string, expected string, cacheable bool) {
20 unmodified lines
modified:src/pattern.go+4 added-1 removed
150 unmodified lines
151 tokens := _splitRegex.Split(str, -1)152 sets := []termSet{}153 set := termSet{}154 switchSet := false155 afterBar := false156 for _, token := range tokens {157 typ, inv, text := termFuzzy, false, strings.Replace(token, "\t", " ", -1)158 lowerText := strings.ToLower(text)159 caseSensitive := caseMode == CaseRespect ||
4 unmodified lines
164 if !fuzzy {165 typ = termExact166 }167167 if text == "|" {168 if len(set) > 0 && !afterBar && text == "|" {169 switchSet = false170 afterBar = true171 continue172 }173 afterBar = false174175 if strings.HasPrefix(text, "!") {176 inv = true177 typ = termExact
233 unmodified lines