[PR #10978] Only focus the active pane once initialization is complete #28343

Closed
opened 2026-01-31 09:27:54 +00:00 by claunia · 0 comments
Owner

Original Pull Request: https://github.com/microsoft/terminal/pull/10978

State: closed
Merged: Yes


Summary of the Pull Request

Since the days immemorial of the Terminal, the TermControl has auto-focused itself when it finalizes its layout. This has led to the problem that wt ; sp ; sp ; sp... ends up focusing one of these panes at random.

This PR fixes this issue by getting rid of the auto-focusing. Panes now manually get focused when created. We manually focus the active pane when a commandline is dispatched. since we're internally tracking "active" separate from "focused", this ends up working as you'd hope.

References

PR Checklist

Detailed Description of the Pull Request / Additional comments

I also had to turn the cursor off by default. Most TermControls would never get the LostFocus event, so their cursors would get left On, and that's not right.

Validation Steps Performed

I've run the following things a bunch of times to make sure they work:

  • wtd sp ; sp ; sp
  • wtd sp ; sp ; sp ; fp -t 0
  • newTab
  • splitPane
  • use the command palette to do the above as well

Where the result used to be random (cases 1 & 2), the result is exactly what you'd expect now.

It doesn't work at all for

wtd sp ; sp ; sp ; mf left

Presumably because we can't move-focus directionally during startup. However, that doesn't work today either, so it's not making it worse. Just highlights that single scenario doesn't work right.

**Original Pull Request:** https://github.com/microsoft/terminal/pull/10978 **State:** closed **Merged:** Yes --- ## Summary of the Pull Request Since the days immemorial of the Terminal, the TermControl has auto-focused itself when it finalizes its layout. This has led to the problem that `wt ; sp ; sp ; sp...` ends up focusing one of these panes at random. This PR fixes this issue by getting rid of the auto-focusing. Panes now manually get focused when created. We manually focus the active pane when a commandline is dispatched. since we're internally tracking "active" separate from "focused", this ends up working as you'd hope. ## References ## PR Checklist * [x] Closes #6586 * [x] I work here * [ ] Tests added/passed * [n/a] Requires documentation to be updated ## Detailed Description of the Pull Request / Additional comments I also had to turn the cursor off by default. Most `TermControl`s would never get the `LostFocus` event, so their cursors would get left `On`, and that's not right. ## Validation Steps Performed I've run the following things a bunch of times to make sure they work: * `wtd sp ; sp ; sp` * `wtd sp ; sp ; sp ; fp -t 0` * `newTab` * `splitPane` * use the command palette to do the above as well Where the result used to be random (cases 1 & 2), the result is exactly what you'd expect now. It doesn't work at all for ``` wtd sp ; sp ; sp ; mf left ``` Presumably because we can't `move-focus` directionally during startup. However, that doesn't work _today_ either, so it's not making it worse. Just highlights that single scenario doesn't work right.
claunia added the pull-request label 2026-01-31 09:27:54 +00:00
Sign in to join this conversation.
No Label pull-request
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#28343