Merge pull request #535 from memeplex/main

Don't delay decorations on editor activation
This commit is contained in:
Alexandru Dima
2021-12-03 19:04:19 +01:00
committed by GitHub

View File

@ -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);