Skip to content

Commit

Permalink
Disable Home and End keys in Command Palette search box (#8194)
Browse files Browse the repository at this point in the history
Home/End will only navigate the command palette list when the user holds down Ctrl.

Closes #8191
  • Loading branch information
kaihugo authored Nov 30, 2020
1 parent b1e1c7c commit 9cffe27
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/cascadia/TerminalApp/CommandPalette.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,24 @@ namespace winrt::TerminalApp::implementation
e.Handled(true);
}
}
else if (key == VirtualKey::Home)
{
auto const state = CoreWindow::GetForCurrentThread().GetKeyState(winrt::Windows::System::VirtualKey::Control);
if (WI_IsFlagSet(state, CoreVirtualKeyStates::Down))
{
ScrollToTop();
e.Handled(true);
}
}
else if (key == VirtualKey::End)
{
auto const state = CoreWindow::GetForCurrentThread().GetKeyState(winrt::Windows::System::VirtualKey::Control);
if (WI_IsFlagSet(state, CoreVirtualKeyStates::Down))
{
ScrollToBottom();
e.Handled(true);
}
}
}

// Method Description:
Expand All @@ -265,6 +283,7 @@ namespace winrt::TerminalApp::implementation
Windows::UI::Xaml::Input::KeyRoutedEventArgs const& e)
{
auto key = e.OriginalKey();
auto const ctrlDown = WI_IsFlagSet(CoreWindow::GetForCurrentThread().GetKeyState(winrt::Windows::System::VirtualKey::Control), CoreVirtualKeyStates::Down);

if (key == VirtualKey::Up)
{
Expand All @@ -290,18 +309,6 @@ namespace winrt::TerminalApp::implementation
ScrollPageDown();
e.Handled(true);
}
else if (key == VirtualKey::Home)
{
// Action Mode: Move focus to the first item in the list.
ScrollToTop();
e.Handled(true);
}
else if (key == VirtualKey::End)
{
// Action Mode: Move focus to the last item in the list.
ScrollToBottom();
e.Handled(true);
}
else if (key == VirtualKey::Enter)
{
const auto selectedCommand = _filteredActionsView().SelectedItem();
Expand Down

0 comments on commit 9cffe27

Please sign in to comment.