From c396701c263350a79ecc578bc2b1ae99eb2daf11 Mon Sep 17 00:00:00 2001 From: Radu Date: Fri, 2 Aug 2024 13:33:18 +0300 Subject: [PATCH] Add validation for debug session status --- src/espIdf/monitor/index.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/espIdf/monitor/index.ts b/src/espIdf/monitor/index.ts index e14c1f812..3a8a1a906 100644 --- a/src/espIdf/monitor/index.ts +++ b/src/espIdf/monitor/index.ts @@ -18,7 +18,7 @@ import { ESP } from "../../config"; import { appendIdfAndToolsToPath, getUserShell } from "../../utils"; -import { window, Terminal, Uri, env } from "vscode"; +import { window, Terminal, Uri, env, debug } from "vscode"; export interface MonitorConfig { baudRate: string; @@ -88,7 +88,10 @@ export class IDFMonitor { "--toolchain-prefix", this.config.toolchainPrefix, ]; - if (this.config.noReset && this.config.idfVersion >= "5.0") { + if ( + this.isDebugSessionActive() || + (this.config.noReset && this.config.idfVersion >= "5.0") + ) { args.splice(2, 0, "--no-reset"); } if (this.config.enableTimestamps && this.config.idfVersion >= "4.4") { @@ -126,10 +129,15 @@ export class IDFMonitor { return this.terminal; } + async dispose() { try { this.terminal.sendText(ESP.CTRL_RBRACKET); this.terminal.sendText(`exit`); } catch (error) {} } + + private isDebugSessionActive(): boolean { + return debug.activeDebugSession !== undefined; + } }