From 7f182c40a991d22e64be500663522b3e0d9ea71f Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 18 Sep 2019 12:34:19 +0200 Subject: [PATCH] debug brekpoints: polish inline breakpoint decorations --- .../browser/breakpointEditorContribution.ts | 20 +++++++++---------- .../contrib/debug/browser/debugSession.ts | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts b/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts index 4515fd4dfdd..d905e63ad14 100644 --- a/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts +++ b/src/vs/workbench/contrib/debug/browser/breakpointEditorContribution.ts @@ -68,7 +68,7 @@ async function createCandidateDecorations(model: ITextModel, lineNumbers: number const result: { range: Range; options: IModelDecorationOptions; }[] = []; const session = debugService.getViewModel().focusedSession; if (session && session.capabilities.supportsBreakpointLocationsRequest) { - lineNumbers.forEach(async lineNumber => { + await Promise.all(lineNumbers.map(async lineNumber => { const positions = await session.breakpointsLocations(model.uri, lineNumber); positions.forEach(p => { result.push({ @@ -79,7 +79,7 @@ async function createCandidateDecorations(model: ITextModel, lineNumbers: number } }); }); - }); + })); } return result; @@ -114,7 +114,7 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { private breakpointWidgetVisible: IContextKey; private toDispose: IDisposable[] = []; private ignoreDecorationsChangedEvent = false; - private ignoreFirstBreakpointsChangeEvent = false; + private ignoreBreakpointsChangeEvent = false; private breakpointDecorations: IBreakpointDecoration[] = []; private candidateDecoraions: { decorationId: string, inlineWidget: InlineBreakpointWidget }[] = []; @@ -222,11 +222,9 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { await this.setDecorations(); })); this.toDispose.push(this.debugService.getModel().onDidChangeBreakpoints(async () => { - if (this.ignoreFirstBreakpointsChangeEvent) { - this.ignoreFirstBreakpointsChangeEvent = false; - return; + if (!this.ignoreBreakpointsChangeEvent) { + await this.setDecorations(); } - await this.setDecorations(); })); this.toDispose.push(this.editor.onDidChangeModelDecorations(() => this.onModelDecorationsChanged())); } @@ -298,7 +296,7 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { nls.localize('addLogPoint', "Add Logpoint..."), undefined, true, - () => Promise.resolve(this.showBreakpointWidget(lineNumber, BreakpointWidgetContext.LOG_MESSAGE)) + () => Promise.resolve(this.showBreakpointWidget(lineNumber, column, BreakpointWidgetContext.LOG_MESSAGE)) )); } @@ -378,7 +376,7 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { const lineNumbers = distinct(this.breakpointDecorations.map(bpd => bpd.range.startLineNumber)); let desiredCandidateDecorations = await createCandidateDecorations(this.editor.getModel(), lineNumbers, this.debugService); desiredCandidateDecorations = desiredCandidateDecorations.filter(dbd => { - const breakpointDecorationAlreadyAtCandidateLocation = this.breakpointDecorations.filter(bd => bd.range.equalsRange(dbd.range)).length >= 0; + const breakpointDecorationAlreadyAtCandidateLocation = this.breakpointDecorations.filter(bd => bd.range.equalsRange(dbd.range)).length > 0; return !breakpointDecorationAlreadyAtCandidateLocation; }); const candidateDecorationids = this.editor.deltaDecorations(this.candidateDecoraions.map(c => c.decorationId), desiredCandidateDecorations); @@ -436,10 +434,10 @@ class BreakpointEditorContribution implements IBreakpointEditorContribution { } try { - this.ignoreFirstBreakpointsChangeEvent = true; + this.ignoreBreakpointsChangeEvent = true; await this.debugService.updateBreakpoints(model.uri, data, true); } finally { - this.ignoreFirstBreakpointsChangeEvent = false; + this.ignoreBreakpointsChangeEvent = false; } } diff --git a/src/vs/workbench/contrib/debug/browser/debugSession.ts b/src/vs/workbench/contrib/debug/browser/debugSession.ts index 0f53246d206..928e9d322ed 100644 --- a/src/vs/workbench/contrib/debug/browser/debugSession.ts +++ b/src/vs/workbench/contrib/debug/browser/debugSession.ts @@ -376,7 +376,7 @@ export class DebugSession implements IDebugSession { const response = await this.raw.breakpointLocations({ source, line: lineNumber }); const positions = response.body.breakpoints.map(bp => ({ lineNumber: bp.line, column: bp.column || 1 })); - return distinct(positions, p => p.toString()); + return distinct(positions, p => `${p.lineNumber}:${p.column}`); } return Promise.reject(new Error('no debug adapter')); } -- GitLab