Skip to content

Commit f238305

Browse files
adamintCopilot
andauthored
Clear terminal input buffer before sending Aspire commands (#15863)
* 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. * Update extension/src/utils/AspireTerminalProvider.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Use platform-specific clear sequence: Escape on Windows, Ctrl+U on Unix --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent c726c3a commit f238305

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

extension/src/utils/AspireTerminalProvider.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,15 @@ export class AspireTerminalProvider implements vscode.Disposable {
9797

9898
const aspireTerminal = this.getAspireTerminal();
9999
extensionLogOutputChannel.info(`Sending command to Aspire terminal: ${command}`);
100+
101+
// Clear any pre-existing text in the terminal input buffer before sending the command.
102+
// Unix (bash/zsh): Ctrl+U (\x15) clears the current line via unix-line-discard.
103+
// Windows (PowerShell): Escape (\x1b) clears the current line in PSReadLine's default Windows edit mode.
104+
// Sending \x1b alone (without a trailing bracket sequence) via a separate sendText call is safe —
105+
// PSReadLine's escape-sequence timeout ensures it is processed as a standalone Escape keypress.
106+
const clearSequence = process.platform === 'win32' ? '\x1b' : '\x15';
107+
aspireTerminal.terminal.sendText(clearSequence, false);
108+
100109
aspireTerminal.terminal.sendText(command);
101110
if (showTerminal) {
102111
aspireTerminal.terminal.show();

0 commit comments

Comments
 (0)