Clear promptInput's value onCommandFinished #287139
Merged
anthonykim1 merged 4 commits intomainfrom Jan 14, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds support for clearing the prompt input model's value when a command finishes executing. This change prevents the runCommand API from detecting leftover text from a previous command and unnecessarily sending a ^C interrupt signal.
Changes:
- Added
onCommandFinishedevent subscription toPromptInputModelto clear the input value after command completion - Updated the constructor and test setup to wire the new event handler
- Added test coverage to verify the value is cleared when a command finishes
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.
| File | Description |
|---|---|
| src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts | Added onCommandFinished event parameter and _handleCommandFinished method to clear prompt input value |
| src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts | Updated PromptInputModel instantiation to pass onCommandFinished event |
| src/vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test.ts | Added test setup for onCommandFinished emitter and test case to verify value clearing behavior |
src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts
Show resolved
Hide resolved
src/vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test.ts
Show resolved
Hide resolved
src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts
Show resolved
Hide resolved
src/vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test.ts
Show resolved
Hide resolved
src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts
Show resolved
Hide resolved
src/vs/platform/terminal/test/common/capabilities/commandDetection/promptInputModel.test.ts
Show resolved
Hide resolved
anthonykim1
commented
Jan 12, 2026
| private _handleCommandFinished() { | ||
| // Clear the prompt input value when command finishes to prepare for the next command | ||
| // This prevents runCommand from detecting leftover text and sending ^C unnecessarily | ||
| this._value = ''; |
Contributor
Author
There was a problem hiding this comment.
I'm not sure if it will be good idea to fire an empty _onDidChangeInput here, because we havent started the "new" input yet.
Member
There was a problem hiding this comment.
Since we're changing the value, let's fire it to be consistent and see if there are any problems.
anthonykim1
commented
Jan 12, 2026
src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts
Show resolved
Hide resolved
Tyriar
approved these changes
Jan 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves: microsoft/vscode-python-environments#640
Coming from: microsoft/vscode-python-environments#1093 (comment)
From: microsoft/vscode-python-environments#1093 (comment)
I couldnt seem to repro ^C to show up on Python file run on Mac, but only on Windows.
This is happening because we have some extra polling happening before onCommandStarted event gets fired:
vscode/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts
Line 727 in 86db4eb
We need the promptInputModel's value to be empty and state to be not execute in order to not cause ^C upon executeCommand run:
vscode/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
Line 1010 in 86db4eb
So in that meantime before we clear the value of promptInput to empty string, the state will be execute and value of it will point to activation script. Which will lead to ^C.
Flow from env extension:
Send activate command -> wait for
onDidEndShellExecution-> send file execution.The ctrl^c came from second arrow.