From 1cc83769f64c86be15d0c24e9aa02335a67d460e Mon Sep 17 00:00:00 2001 From: Vladislav Annenkov Date: Tue, 6 Dec 2022 01:37:02 +0300 Subject: [PATCH] Wait for debugger capabilities initialization before breakpoint update (#11607) --- packages/debug/src/browser/debug-session.tsx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/debug/src/browser/debug-session.tsx b/packages/debug/src/browser/debug-session.tsx index fbf9dfc238db4..130885be8d19b 100644 --- a/packages/debug/src/browser/debug-session.tsx +++ b/packages/debug/src/browser/debug-session.tsx @@ -40,7 +40,7 @@ import { TerminalWidgetOptions, TerminalWidget } from '@theia/terminal/lib/brows import { DebugFunctionBreakpoint } from './model/debug-function-breakpoint'; import { FileService } from '@theia/filesystem/lib/browser/file-service'; import { DebugContribution } from './debug-contribution'; -import { waitForEvent } from '@theia/core/lib/common/promise-util'; +import { Deferred, waitForEvent } from '@theia/core/lib/common/promise-util'; import { WorkspaceService } from '@theia/workspace/lib/browser'; import { DebugInstructionBreakpoint } from './model/debug-instruction-breakpoint'; @@ -53,6 +53,8 @@ export enum DebugState { // FIXME: make injectable to allow easily inject services export class DebugSession implements CompositeTreeElement { + protected readonly deferredOnDidConfigureCapabilities = new Deferred(); + protected readonly onDidChangeEmitter = new Emitter(); readonly onDidChange: Event = this.onDidChangeEmitter.event; protected fireDidChange(): void { @@ -501,6 +503,7 @@ export class DebugSession implements CompositeTreeElement { protected updateCapabilities(capabilities: DebugProtocol.Capabilities): void { Object.assign(this._capabilities, capabilities); + this.deferredOnDidConfigureCapabilities.resolve(); } protected readonly _breakpoints = new Map(); @@ -628,6 +631,7 @@ export class DebugSession implements CompositeTreeElement { return; } const { uri, sourceModified } = options; + await this.deferredOnDidConfigureCapabilities.promise; for (const affectedUri of this.getAffectedUris(uri)) { if (affectedUri.toString() === BreakpointManager.EXCEPTION_URI.toString()) { await this.sendExceptionBreakpoints();