From 9d64a3be869c8fee828455339f3e15c1715166c6 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Wed, 20 Mar 2019 23:04:47 -0700 Subject: [PATCH] Fix #27636 - in matchesWords filtering, split words on punctuation marks as well as whitespace (#70868) --- src/vs/base/common/filters.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/vs/base/common/filters.ts b/src/vs/base/common/filters.ts index ef1df908741..76bb974d567 100644 --- a/src/vs/base/common/filters.ts +++ b/src/vs/base/common/filters.ts @@ -119,6 +119,15 @@ function isWhitespace(code: number): boolean { ); } +const wordSeparators = new Set(); +'`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?' + .split('') + .forEach(s => wordSeparators.add(s.charCodeAt(0))); + +function isWordSeparator(code: number): boolean { + return wordSeparators.has(code); +} + function isAlphanumeric(code: number): boolean { return isLower(code) || isUpper(code) || isNumber(code); } @@ -308,7 +317,8 @@ function _matchesWords(word: string, target: string, i: number, j: number, conti function nextWord(word: string, start: number): number { for (let i = start; i < word.length; i++) { const c = word.charCodeAt(i); - if (isWhitespace(c) || (i > 0 && isWhitespace(word.charCodeAt(i - 1)))) { + if (isWhitespace(c) || (i > 0 && isWhitespace(word.charCodeAt(i - 1))) || + isWordSeparator(c) || (i > 0 && isWordSeparator(word.charCodeAt(i - 1)))) { return i; } } -- GitLab