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

Fix an infinite loop when pressing alt #15253

Merged
merged 3 commits into from
May 11, 2023
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
13 changes: 11 additions & 2 deletions src/cascadia/TerminalApp/TerminalWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,10 +870,19 @@ namespace winrt::TerminalApp::implementation
{
focusedObject = winrt::Windows::UI::Xaml::Media::VisualTreeHelper::GetParent(focusedElement);

// We were unable to find a focused object. Default to the xaml root so that the alt+space menu still works.
// We were unable to find a focused object. Give the
// TerminalPage one last chance to let the alt+space
// menu still work.
//
// We return always, because the TerminalPage handler
// will return false for just a bare `alt` press, and
// don't want to go around the loop again.
if (!focusedObject)
{
focusedObject = _root.try_as<IInspectable>();
if (auto keyListener{ _root.try_as<IDirectKeyListener>() })
{
return keyListener.OnDirectKeyEvent(vkey, scanCode, down);
}
}
Comment on lines 880 to 886
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it would make more sense, but technically you can put this fallback outside the loop, at the end of this function. I guess it would make some sense, given that it only accesses _root and has nothing to do with the actual UI tree anymore.

}
}
Expand Down