From d32733ff9cc8cf1ac6776f0dd9aa9cb4fa950eb1 Mon Sep 17 00:00:00 2001 From: Megan Rogge Date: Thu, 18 Dec 2025 13:32:15 -0600 Subject: [PATCH] fix bug with inserting code block into terminal (#284132) fixes #275345 --- .../workbench/contrib/terminal/browser/terminalInstance.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts index 4a51c8603b9..25a2116801e 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts @@ -960,10 +960,9 @@ export class TerminalInstance extends Disposable implements ITerminalInstance { await this._processManager.setNextCommandId(commandLine, commandId); } - // Determine whether to send ETX (ctrl+c) before running the command. This should always - // happen unless command detection can reliably say that a command is being entered and - // there is no content in the prompt - if (!commandDetection || commandDetection.promptInputModel.value.length > 0) { + // Determine whether to send ETX (ctrl+c) before running the command. Only do this when the + // command will be executed immediately or when command detection shows the prompt contains text. + if (shouldExecute && (!commandDetection || commandDetection.promptInputModel.value.length > 0)) { await this.sendText('\x03', false); // Wait a little before running the command to avoid the sequences being echoed while the ^C // is being evaluated