Skip to content

Commit 743785b

Browse files
committed
feat(vscode): adjust reactivity visualization update interval
1 parent ce82fac commit 743785b

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

extensions/vscode/lib/reactivityVisualization.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ export function activate(
2626
context: vscode.ExtensionContext,
2727
selector: vscode.DocumentSelector,
2828
) {
29+
const documentUpdateVersions = new WeakMap<vscode.TextDocument, number>();
30+
2931
let timeout: ReturnType<typeof setTimeout> | undefined;
3032

3133
for (const editor of vscode.window.visibleTextEditors) {
@@ -42,11 +44,23 @@ export function activate(
4244
const editor = vscode.window.activeTextEditor;
4345
if (editor) {
4446
clearTimeout(timeout);
45-
timeout = setTimeout(() => updateDecorations(editor), 250);
47+
timeout = setTimeout(
48+
() => updateDecorations(editor),
49+
getUpdateInterval(editor.document),
50+
);
4651
}
4752
}),
4853
);
4954

55+
function getUpdateInterval(document: vscode.TextDocument) {
56+
const prevVersion = documentUpdateVersions.get(document);
57+
if (prevVersion !== document.version) {
58+
documentUpdateVersions.set(document, document.version);
59+
return 250;
60+
}
61+
return 100;
62+
}
63+
5064
async function updateDecorations(editor: vscode.TextEditor) {
5165
const { document } = editor;
5266
if (document.uri.scheme !== 'file') {

0 commit comments

Comments
 (0)