From 2098ec09733ceb66342ccf72dd1ac128efda741a Mon Sep 17 00:00:00 2001 From: Carlos Pita Date: Tue, 30 Nov 2021 13:48:48 -0300 Subject: [PATCH] Don't delay decorations on editor activation --- decorator-sample/src/extension.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/decorator-sample/src/extension.ts b/decorator-sample/src/extension.ts index ad251f3a..5652d0d9 100644 --- a/decorator-sample/src/extension.ts +++ b/decorator-sample/src/extension.ts @@ -55,12 +55,16 @@ export function activate(context: vscode.ExtensionContext) { activeEditor.setDecorations(largeNumberDecorationType, largeNumbers); } - function triggerUpdateDecorations() { + function triggerUpdateDecorations(throttle: boolean = false) { if (timeout) { clearTimeout(timeout); timeout = undefined; } - timeout = setTimeout(updateDecorations, 500); + if (throttle) { + timeout = setTimeout(updateDecorations, 500); + } else { + updateDecorations(); + } } if (activeEditor) { @@ -76,7 +80,7 @@ export function activate(context: vscode.ExtensionContext) { vscode.workspace.onDidChangeTextDocument(event => { if (activeEditor && event.document === activeEditor.document) { - triggerUpdateDecorations(); + triggerUpdateDecorations(true); } }, null, context.subscriptions);