Skip to content

Manually focus panes after swapping them #19024

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

Merged
merged 1 commit into from
Jun 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/cascadia/TerminalApp/Pane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -697,12 +697,24 @@ bool Pane::SwapPanes(std::shared_ptr<Pane> first, std::shared_ptr<Pane> second)
// Refocus the last pane if there was a pane focused
if (const auto focus = first->GetActivePane())
{
focus->_Focus();
// GH#18184: manually focus the pane and content.
// _Focus() results in no-op because the pane was _lastActive
focus->GotFocus.raise(focus, FocusState::Programmatic);
if (const auto& lastContent{ focus->GetLastFocusedContent() })
{
lastContent.Focus(FocusState::Programmatic);
}
}

if (const auto focus = second->GetActivePane())
{
focus->_Focus();
// GH#18184: manually focus the pane and content.
// _Focus() results in no-op because the pane was _lastActive
focus->GotFocus.raise(focus, FocusState::Programmatic);
if (const auto& lastContent{ focus->GetLastFocusedContent() })
{
lastContent.Focus(FocusState::Programmatic);
}
}

return true;
Expand Down