-
Notifications
You must be signed in to change notification settings - Fork 37.7k
Clear promptInput's value onCommandFinished #287139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
| 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 = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if it will be good idea to fire an empty _onDidChangeInput here, because we havent started the "new" input yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're changing the value, let's fire it to be consistent and see if there are any problems.
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.