From 8108f2226227beac45d09f01e60c34dcd9920c08 Mon Sep 17 00:00:00 2001 From: Mike Griese Date: Wed, 10 May 2023 22:20:24 -0500 Subject: [PATCH] Fix an infinite loop when pressing `alt` (#15253) As discussed in https://github.com/microsoft/terminal/issues/14051#issuecomment-1517973776 regressed in #15189 (cherry picked from commit 0553f3ebf185b4c1354cd70e6f4eaf79db0698fd) Service-Card-Id: 89031966 Service-Version: 1.17 --- src/cascadia/TerminalApp/AppLogic.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/cascadia/TerminalApp/AppLogic.cpp b/src/cascadia/TerminalApp/AppLogic.cpp index fa9e8da9bca..518edc6113e 100644 --- a/src/cascadia/TerminalApp/AppLogic.cpp +++ b/src/cascadia/TerminalApp/AppLogic.cpp @@ -1185,10 +1185,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(); + if (auto keyListener{ _root.try_as() }) + { + return keyListener.OnDirectKeyEvent(vkey, scanCode, down); + } } } }