Skip to content

Clear the current line when activating in terminal#1462

Closed
edvilme wants to merge 2 commits intomainfrom
terminal-activation-clear-line
Closed

Clear the current line when activating in terminal#1462
edvilme wants to merge 2 commits intomainfrom
terminal-activation-clear-line

Conversation

@edvilme
Copy link
Copy Markdown
Contributor

@edvilme edvilme commented Apr 15, 2026

Ensures that the current terminal line is cleared before the command for activation is passed to the terminal. Before, it would interrupt user input, resulting in corrupted commands like: git pu\n, which not only produces the wrong command, but can lead to unsafe execution.

This occurs on the legacy (de)activation, due to users:

  • Having setting erminal.integrated.shellIntegration.enabled = false
  • Using a shell that does not support shell integration
  • Using slower machines, or remote SSH, and the shell integration timeout elapsing before the handshake.

Ensures that the current terminal line is cleared before the command for activation is passed to the terminal. Before, it would interrupt user input, resulting in corrupted commands like: git pu<activation command>\\n, which not only produces the wrong command, but can lead to unsafe execution.

This occurs on the legacy (de)activation, due to users:
- Having setting 	erminal.integrated.shellIntegration.enabled = false
- Using a shell that does not support shell integration
- Using slower machines, or remote SSH, and the shell integration timeout elapsing before the handshake.
@edvilme edvilme force-pushed the terminal-activation-clear-line branch from 1e91f4f to 2ab9f20 Compare April 15, 2026 20:05
@edvilme
Copy link
Copy Markdown
Contributor Author

edvilme commented Apr 15, 2026

Ref #1375

@edvilme
Copy link
Copy Markdown
Contributor Author

edvilme commented Apr 15, 2026

Would be superseded by #962 but this consider the case for using the legacy activation

@edvilme edvilme requested a review from eleanorjboyd April 15, 2026 20:10
@edvilme edvilme added the bug Issue identified by VS Code Team member as probable bug label Apr 15, 2026
@eleanorjboyd
Copy link
Copy Markdown
Member

going to defer this to @anthonykim1 to make a decision since this is his area of expertise. I am inclined to say we hold on this as we get the terminal experiments out and the stuff anthony has been working on since that should address the same problem

@edvilme edvilme requested a review from anthonykim1 April 15, 2026 22:32
@anthonykim1
Copy link
Copy Markdown
Contributor

anthonykim1 commented Apr 23, 2026

Thanks for the PR :)

I don't think we should do this, as clearing line is pretty aggressive compared to ^c keyboard interrupt which is part of shell integration's executeCommand.
Even with the keyboard interrupt there has been much complains about how "aggressive" the behavior is.

Big downside of clearing line is that user may be typing something but clearing before the explicit activation command would result in that typing experience "disappearing".
Aside from user typing, we would also have to assume that other extensions may be trying to send command upon launch of terminal so clearing would be effectively "undo"-ing their behavior as well.

Keyboard interrupt behavior is more expected as it shows what user was typing (or extension sending command) before the ^C is inserted.

As far as shell integration, majority of our users are on it, and it's been the default ever since its introduction.
It's what also powers copilot terminal experience, so we'd want to focus on shell integration enabled experience.

In case auto-injection fails, we do provide way for manual installation here : https://code.visualstudio.com/docs/terminal/shell-integration#_manual-installation

It's great that you called out #962 since we're planning roll shell startup as the default once env extension is fully rolled out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue identified by VS Code Team member as probable bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants