From 608a45e2e0a2069b3f954c97f9eff65e96b8ff7d Mon Sep 17 00:00:00 2001 From: Radu Date: Fri, 25 Oct 2024 18:51:53 +0300 Subject: [PATCH] [VSC-1412] Add validation for debug session status for monitor start with no reset flag (#1270) * Add validation for debug session status * Made function static --- src/espIdf/monitor/index.ts | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/espIdf/monitor/index.ts b/src/espIdf/monitor/index.ts index 91c523533..07ceb9d43 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; @@ -97,7 +97,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") { @@ -144,4 +147,8 @@ export class IDFMonitor { this.terminal.sendText(`exit`); } catch (error) {} } + + private static isDebugSessionActive(): boolean { + return debug.activeDebugSession !== undefined; + } }