From c9625d49392a3bca19ca00dae558a1c647a17340 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Tue, 12 May 2020 23:08:32 +0200 Subject: [PATCH] Fixes a bug that it does not track a debug session if the debug visualizer is initialized after the debugging has started. --- extension/src/VsCodeDebugger.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/extension/src/VsCodeDebugger.ts b/extension/src/VsCodeDebugger.ts index 9628544..05a68fe 100644 --- a/extension/src/VsCodeDebugger.ts +++ b/extension/src/VsCodeDebugger.ts @@ -2,7 +2,7 @@ import { Disposable } from "@hediet/std/disposable"; import { debug, DebugSession } from "vscode"; import { EventEmitter } from "@hediet/std/events"; import { CompletionItem } from "./contract"; -import { observable, runInAction } from "mobx"; +import { observable, runInAction, action } from "mobx"; export class VsCodeDebugger { public readonly dispose = Disposable.fn(); @@ -193,17 +193,19 @@ export class VsCodeDebuggerView { constructor(private vsCodeDebugger: VsCodeDebugger) { this.dispose.track( debug.onDidChangeActiveDebugSession(activeSession => { - runInAction("Update active debug session", () => { - if (!activeSession) { - this._activeDebugSession = undefined; - } else { - const s = this.vsCodeDebugger.getDebugSession( - activeSession - ); - this._activeDebugSession = s; - } - }); + this.updateActiveDebugSession(activeSession); }) ); + this.updateActiveDebugSession(debug.activeDebugSession); + } + + @action + private updateActiveDebugSession(activeSession: DebugSession | undefined) { + if (!activeSession) { + this._activeDebugSession = undefined; + } else { + const s = this.vsCodeDebugger.getDebugSession(activeSession); + this._activeDebugSession = s; + } } }