提交 9d64a3be 编写于 作者: R Rob Lourens 提交者: Benjamin Pasero

Fix #27636 - in matchesWords filtering, split words on punctuation marks as...

Fix #27636 - in matchesWords filtering, split words on punctuation marks as well as whitespace (#70868)
上级 edd2c737
......@@ -119,6 +119,15 @@ function isWhitespace(code: number): boolean {
);
}
const wordSeparators = new Set<number>();
'`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?'
.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;
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册