提交 b40e5ce7 编写于 作者: J Jackson Kearl

Add `matchienessHeuristic` to delay some regex searches. Fixes #88539.

上级 b6fcbb1b
......@@ -499,7 +499,31 @@ export class SearchWidget extends Widget {
this.temporarilySkipSearchOnChange = false;
} else {
this._onSearchCancel.fire({ focus: false });
this._searchDelayer.trigger((() => this.submitSearch(true)), this.searchConfiguration.searchOnTypeDebouncePeriod);
if (this.searchInput.getRegex()) {
try {
const regex = new RegExp(this.searchInput.getValue(), 'ug');
const matchienessHeuristic = `
~!@#$%^&*()_+
\`1234567890-=
qwertyuiop[]\\
QWERTYUIOP{}|
asdfghjkl;'
ASDFGHJKL:"
zxcvbnm,./
ZXCVBNM<>? `.match(regex)?.length ?? 0;
const delayMultiplier =
matchienessHeuristic < 50 ? 1 :
matchienessHeuristic < 100 ? 5 : // expressions like `.` or `\w`
10; // only things matching empty string
this._searchDelayer.trigger((() => this.submitSearch(true)), this.searchConfiguration.searchOnTypeDebouncePeriod * delayMultiplier);
} catch {
// pass
}
} else {
this._searchDelayer.trigger((() => this.submitSearch(true)), this.searchConfiguration.searchOnTypeDebouncePeriod);
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册