Skip to content

Retain editor focus after Run In Terminal #3303

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andyw8
Copy link
Contributor

@andyw8 andyw8 commented Mar 16, 2025

I discovered that you can trigger a Code Lens with a keybinding, which is useful for Run In Terminal.

But currently the focus stays with the terminal so you need to focus back to the editor after doing so. This PR changes it to switch back automatically.

This does impact the current flow. For example, if someone is used to triggering a breakpoint with binding.b, they will now need to focus on the Terminal panel before doing anything. I expect the majority of uses for Run In Terminal are likely not doing that though, so overall it should be an improvement.

(Note: There is another change needed after this for the keyboard functionality to fully work).

Copy link

graphite-app bot commented Mar 16, 2025

How to use the Graphite Merge Queue

Add the label graphite-merge to this PR to add it to the merge queue.

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

this.terminal.show();
this.terminal.sendText(command);
if (activeEditor) {
setTimeout(() => {
Copy link
Contributor Author

@andyw8 andyw8 Mar 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without a delay here it fails. I'm unsure what would be a better way.

@andyw8 andyw8 marked this pull request as ready for review March 20, 2025 15:47
@andyw8 andyw8 requested a review from a team as a code owner March 20, 2025 15:47
@st0012
Copy link
Member

st0012 commented Mar 20, 2025

Do you mind recording demo vids for before/after comparison? I ran this branch but the behaviour seems to be the same (focus moves and stays at terminal).

@andyw8
Copy link
Contributor Author

andyw8 commented Mar 21, 2025

Sure, here's how it is on the current release. Notice that the cursor in the terminal is a solid block after the test finishes since it has focus.

main.mov

And here it is on the branch, where focus returns to the editor window:

branch.mov

Copy link
Contributor

This pull request is being marked as stale because there was no activity in the last 2 months

@github-actions github-actions bot added the Stale label May 21, 2025
@vinistock vinistock added vscode This pull request should be included in the VS Code extension's release notes other Changes that aren't bugfixes, enhancements or breaking changes and removed Stale labels May 21, 2025
@vinistock
Copy link
Member

Just FYI: we're trying to collect feedback about dev's expectations related to this. This change makes the focus more consistent with other explorer actions, but run in terminal has been the most popular actions for a long time and no one has ever brought up that they would rather not focus on the terminal.

That is to say, it's unclear if the majority of devs will prefer this over the current experience and we're trying to assess that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
other Changes that aren't bugfixes, enhancements or breaking changes vscode This pull request should be included in the VS Code extension's release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants