From 8ddb2dd582a4b868686b419a72b8d4af1216fba1 Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Fri, 3 Apr 2026 18:05:07 -0400 Subject: [PATCH 1/3] Clear terminal input buffer before sending Aspire commands Fixes #15587. When the user has pre-existing text in the Aspire terminal input buffer, stop/restart/start commands get appended to it, making the resulting command invalid. Send a line-clearing control sequence (Ctrl+U on Unix, Escape on Windows) before each command to discard any buffered input. --- extension/src/utils/AspireTerminalProvider.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/extension/src/utils/AspireTerminalProvider.ts b/extension/src/utils/AspireTerminalProvider.ts index e91ce4a2c04..ae451e855ce 100644 --- a/extension/src/utils/AspireTerminalProvider.ts +++ b/extension/src/utils/AspireTerminalProvider.ts @@ -97,6 +97,12 @@ export class AspireTerminalProvider implements vscode.Disposable { const aspireTerminal = this.getAspireTerminal(); extensionLogOutputChannel.info(`Sending command to Aspire terminal: ${command}`); + + // Clear any pre-existing text in the terminal input buffer before sending the command. + // Ctrl+U clears the current line in bash/zsh; Escape clears it in PowerShell. + const clearSequence = process.platform === 'win32' ? '\x1b' : '\x15'; + aspireTerminal.terminal.sendText(clearSequence, false); + aspireTerminal.terminal.sendText(command); if (showTerminal) { aspireTerminal.terminal.show(); From 577d0bfe10a4aab41f0e70481387246d5cc51a49 Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Fri, 3 Apr 2026 18:15:27 -0400 Subject: [PATCH 2/3] Update extension/src/utils/AspireTerminalProvider.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- extension/src/utils/AspireTerminalProvider.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extension/src/utils/AspireTerminalProvider.ts b/extension/src/utils/AspireTerminalProvider.ts index ae451e855ce..4f8086abc5f 100644 --- a/extension/src/utils/AspireTerminalProvider.ts +++ b/extension/src/utils/AspireTerminalProvider.ts @@ -99,8 +99,9 @@ export class AspireTerminalProvider implements vscode.Disposable { extensionLogOutputChannel.info(`Sending command to Aspire terminal: ${command}`); // Clear any pre-existing text in the terminal input buffer before sending the command. - // Ctrl+U clears the current line in bash/zsh; Escape clears it in PowerShell. - const clearSequence = process.platform === 'win32' ? '\x1b' : '\x15'; + // Use Ctrl+U to clear the current line without sending an ESC prefix that can alter + // how the following command text is interpreted by Windows line editors. + const clearSequence = '\x15'; aspireTerminal.terminal.sendText(clearSequence, false); aspireTerminal.terminal.sendText(command); From 5e386678a8863ce61f3bd13fbd337ae9ca83d97a Mon Sep 17 00:00:00 2001 From: Adam Ratzman Date: Sun, 5 Apr 2026 23:04:18 -0400 Subject: [PATCH 3/3] Use platform-specific clear sequence: Escape on Windows, Ctrl+U on Unix --- extension/src/utils/AspireTerminalProvider.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/extension/src/utils/AspireTerminalProvider.ts b/extension/src/utils/AspireTerminalProvider.ts index 4f8086abc5f..1962d7aaf33 100644 --- a/extension/src/utils/AspireTerminalProvider.ts +++ b/extension/src/utils/AspireTerminalProvider.ts @@ -99,9 +99,11 @@ export class AspireTerminalProvider implements vscode.Disposable { extensionLogOutputChannel.info(`Sending command to Aspire terminal: ${command}`); // Clear any pre-existing text in the terminal input buffer before sending the command. - // Use Ctrl+U to clear the current line without sending an ESC prefix that can alter - // how the following command text is interpreted by Windows line editors. - const clearSequence = '\x15'; + // Unix (bash/zsh): Ctrl+U (\x15) clears the current line via unix-line-discard. + // Windows (PowerShell): Escape (\x1b) clears the current line in PSReadLine's default Windows edit mode. + // Sending \x1b alone (without a trailing bracket sequence) via a separate sendText call is safe — + // PSReadLine's escape-sequence timeout ensures it is processed as a standalone Escape keypress. + const clearSequence = process.platform === 'win32' ? '\x1b' : '\x15'; aspireTerminal.terminal.sendText(clearSequence, false); aspireTerminal.terminal.sendText(command);