Skip to content

Commit

Permalink
Add validation for debug session status
Browse files Browse the repository at this point in the history
  • Loading branch information
radurentea committed Aug 2, 2024
1 parent 9588ad6 commit c396701
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/espIdf/monitor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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") {
Expand Down Expand Up @@ -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;
}
}

0 comments on commit c396701

Please sign in to comment.