Skip to content

Commit bba0e91

Browse files
committed
testing: reduce decoration work
- Skip syncing on files with no decorations - Accumulate events to avoid forcing refreshes eagerly Fixes microsoft#165833
1 parent c9ce188 commit bba0e91

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/vs/workbench/contrib/testing/browser/testingDecorations.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -356,19 +356,25 @@ export class TestingDecorations extends Disposable implements IEditorContributio
356356
}
357357
}
358358
}));
359-
this._register(this.editor.onDidChangeModelContent(e => {
359+
this._register(Event.accumulate(this.editor.onDidChangeModelContent, 0, this._store)(evts => {
360360
const model = editor.getModel();
361361
if (!this.currentUri || !model) {
362362
return;
363363
}
364364

365365
const currentDecorations = decorations.syncDecorations(this.currentUri);
366-
for (const change of e.changes) {
367-
const modelDecorations = model.getLinesDecorations(change.range.startLineNumber, change.range.endLineNumber);
368-
for (const { id } of modelDecorations) {
369-
const decoration = currentDecorations.get(id);
370-
if (decoration instanceof TestMessageDecoration) {
371-
decorations.invalidateResultMessage(decoration.testMessage);
366+
if (!currentDecorations.size) {
367+
return;
368+
}
369+
370+
for (const e of evts) {
371+
for (const change of e.changes) {
372+
const modelDecorations = model.getLinesDecorations(change.range.startLineNumber, change.range.endLineNumber);
373+
for (const { id } of modelDecorations) {
374+
const decoration = currentDecorations.get(id);
375+
if (decoration instanceof TestMessageDecoration) {
376+
decorations.invalidateResultMessage(decoration.testMessage);
377+
}
372378
}
373379
}
374380
}

0 commit comments

Comments
 (0)