Skip to content
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

Change Create New Terminal to focus accordingly to the terminal location #237404

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Abrifq
Copy link
Contributor

@Abrifq Abrifq commented Jan 7, 2025

Solves #237192 by using focusActiveTerminal.

I am not familliar with the codebase, so, please review if the else block is still needed.

run: async (c) => {
if (c.service.isProcessSupportRegistered) {
const instance = await c.service.createTerminal({ location: c.service.defaultLocation });
if (!instance) {
return;
}
c.service.setActiveInstance(instance);
await focusActiveTerminal(instance, c);
}
else {
await c.groupService.showPanel(true);
}
}

Have a nice day!

I'll undraft the PR as soon as it compiles on my machine and I verify it's working nicely.

@Abrifq Abrifq force-pushed the abrifq/create-new-terminal-does-not-honor-defaultLocation branch from 9ded0d7 to e00c8eb Compare January 7, 2025 15:07
@meganrogge
Copy link
Contributor

Hi, thanks for working on this. From the code, I'm not sure it will work.

@Abrifq
Copy link
Contributor Author

Abrifq commented Jan 7, 2025

Hi! Thanks for replying.

It seems to work, feel free to test & review when you have time.

Also, should I update the branch when it's ready for review or when it's on merge queue? Doing so sounds like it will waste CI time.

@Abrifq Abrifq marked this pull request as ready for review January 7, 2025 15:52
@meganrogge
Copy link
Contributor

meganrogge commented Jan 7, 2025

shouldn't we be checking the location of the terminal to determine if we should focus the panel, vs doing so only when process support is not registered?

if (c.service.isProcessSupportRegistered) {

or perhaps the call to show panel is no longer needed?

@Abrifq
Copy link
Contributor Author

Abrifq commented Jan 7, 2025

shouldn't we be checking the location of the terminal to determine if we should focus the panel

focusActiveTerminal() does that already. I was going to write the same code myself but saw it's being used in commands like TerminalCommandId.New already and decided to use what's already here.

async function focusActiveTerminal(instance: ITerminalInstance, c: ITerminalServicesCollection): Promise<void> {
if (instance.target === TerminalLocation.Editor) {
await c.editorService.revealActiveEditor();
await instance.focusWhenReady(true);
} else {
await c.groupService.showPanel(true);
}
}

or perhaps the call to show panel is no longer needed?

That's why I wanted you to check, I'm not familliar with the codebase and I didn't research what's isProcessSupportRegistered implying.
Since I'm not familliar with what was on the mind when the function was writter and since focusActiveTerminal() already calls showPanel() when needed, I took it to an else clause.

(tl;dr: i don't know much better but it should be logically same while not annoying me when it spawns a terminal on editor area)

Abrifq and others added 2 commits January 7, 2025 23:01
in "Create New Terminal (In Active Workspace)"

Co-authored-by: Megan Rogge <[email protected]>
@Abrifq Abrifq force-pushed the abrifq/create-new-terminal-does-not-honor-defaultLocation branch from e00c8eb to fad4abf Compare January 7, 2025 20:02
Copy link
Contributor

@meganrogge meganrogge left a comment

Choose a reason for hiding this comment

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

Thanks!

@meganrogge meganrogge requested a review from Tyriar January 7, 2025 20:55
@meganrogge meganrogge enabled auto-merge (squash) January 7, 2025 20:56
@vs-code-engineering vs-code-engineering bot added this to the January 2025 milestone Jan 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants