Skip to content

Commit

Permalink
Merge pull request #82072 from IllusionMH/pcre2-for-whole-word-82071
Browse files Browse the repository at this point in the history
Fallback to PCRE2 if match whole word used with regexp
  • Loading branch information
roblourens authored Oct 8, 2019
2 parents 4332203 + 10545c3 commit 8f3b739
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -425,13 +425,14 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[]
args.push('--pcre2');
}

// Allow $ to match /r/n
args.push('--crlf');

if (query.isRegExp) {
query.pattern = unicodeEscapesToPCRE2(query.pattern);
args.push('--auto-hybrid-regex');
}

// Allow $ to match /r/n
args.push('--crlf');

let searchPatternAfterDoubleDashes: Maybe<string>;
if (query.isWordMatch) {
const regexp = createRegExp(query.pattern, !!query.isRegExp, { wholeWord: query.isWordMatch });
Expand All @@ -441,7 +442,6 @@ function getRgArgs(query: TextSearchQuery, options: TextSearchOptions): string[]
let fixedRegexpQuery = fixRegexNewline(query.pattern);
fixedRegexpQuery = fixNewline(fixedRegexpQuery);
args.push('--regexp', fixedRegexpQuery);
args.push('--auto-hybrid-regex');
} else {
searchPatternAfterDoubleDashes = query.pattern;
args.push('--fixed-strings');
Expand Down

0 comments on commit 8f3b739

Please sign in to comment.