breakpoints: update decorations with a minor timeout to react once to multiple nearby events

This commit is contained in:
isidor
2019-09-18 12:57:34 +02:00
parent 7f182c40a9
commit a0e65a532d

View File

@@ -29,6 +29,7 @@ import { generateUuid } from 'vs/base/common/uuid';
import { memoize } from 'vs/base/common/decorators';
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { distinct } from 'vs/base/common/arrays';
import { RunOnceScheduler } from 'vs/base/common/async';
const $ = dom.$;
@@ -117,6 +118,7 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution {
private ignoreBreakpointsChangeEvent = false;
private breakpointDecorations: IBreakpointDecoration[] = [];
private candidateDecoraions: { decorationId: string, inlineWidget: InlineBreakpointWidget }[] = [];
private setDecorationsScheduler: RunOnceScheduler;
constructor(
private readonly editor: ICodeEditor,
@@ -128,6 +130,7 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution {
) {
this.breakpointWidgetVisible = CONTEXT_BREAKPOINT_WIDGET_VISIBLE.bindTo(contextKeyService);
this.registerListeners();
this.setDecorationsScheduler = new RunOnceScheduler(() => this.setDecorations(), 30);
}
getId(): string {
@@ -222,8 +225,8 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution {
await this.setDecorations();
}));
this.toDispose.push(this.debugService.getModel().onDidChangeBreakpoints(async () => {
if (!this.ignoreBreakpointsChangeEvent) {
await this.setDecorations();
if (!this.ignoreBreakpointsChangeEvent && !this.setDecorationsScheduler.isScheduled()) {
this.setDecorationsScheduler.schedule();
}
}));
this.toDispose.push(this.editor.onDidChangeModelDecorations(() => this.onModelDecorationsChanged()));