Add small timeout to avoid ctrl+c on Windows after activation #1093
Add small timeout to avoid ctrl+c on Windows after activation #1093anthonykim1 wants to merge 1 commit intomainfrom
Conversation
| // Since we have extra polliing on Windows that could lead to race stale promptInputModel value, | ||
| // temporarily add small timeout to avoid ^C. | ||
| // TODO: Consider removing when we clean up polling with newer conpty: https://github.com/microsoft/vscode/issues/224488 | ||
| await timeout(50); |
There was a problem hiding this comment.
A timeout like this will always be flaky unfortunately.
Have you considered awaiting the activate call if triggered via executeCommand, and queuing any further commands until that resolves?
There was a problem hiding this comment.
@Tyriar We actually do await for the activate call when activating with executeCommand
vscode-python-environments/src/features/pythonApi.ts
Lines 303 to 307 in 2693262
which goes to:
- then waiting for activated terminal
- Eventually where we wait until
vscode-python-environments/src/features/terminal/terminalActivationState.ts
Lines 265 to 267 in 2693262
onDidEndShellExecutionis called
Maybe the better fix is to move where https://github.com/microsoft/vscode/blob/86db4eb05dbfd82dc9b4ea022883494257ac3d63/src/vs/platform/terminal/common/capabilities/commandDetection/promptInputModel.ts#L213 happens, to after execution in core?
There was a problem hiding this comment.
Clearing the command when onCommandFinished fires makes sense (in addition to onCommandStart just in case?)
Resolves: #640
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
onCommandStartedevent gets fired: https://github.com/microsoft/vscode/blob/86db4eb05dbfd82dc9b4ea022883494257ac3d63/src/vs/platform/terminal/common/capabilities/commandDetectionCapability.ts#L727 Which is what leads to resetting the value of promptInputModel:We need the promptInputModel's value to be empty and state to be not
executein order to not cause ^C uponexecuteCommandrun: https://github.com/microsoft/vscode/blob/86db4eb05dbfd82dc9b4ea022883494257ac3d63/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L1010So in that meantime before we clear the value of promptInput to empty string, the state will be
executeand value of it will point to activation script. Which will lead to ^C.I think we'd have better chance when we remove some Windows specific heuristics in command detection, after rolling out newer conpty as default.