@@ -584,7 +584,7 @@ namespace winrt::TerminalApp::implementation
584
584
automationPeer.RaiseNotificationEvent (
585
585
Automation::Peers::AutomationNotificationKind::ActionCompleted,
586
586
Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent,
587
- fmt::format (std::wstring_view{ RS_ (L" CommandPalette_NestedCommandAnnouncement " ) }, ParentCommandName ()),
587
+ fmt::format (std::wstring_view{ RS_ (L" SuggestionsControl_NestedCommandAnnouncement " ) }, ParentCommandName ()),
588
588
L" SuggestionsControlNestingLevelChanged" /* unique name for this notification category */ );
589
589
}
590
590
}
@@ -725,10 +725,12 @@ namespace winrt::TerminalApp::implementation
725
725
// here will ensure that we can check this case appropriately.
726
726
_lastFilterTextWasEmpty = _searchBox ().Text ().empty ();
727
727
728
+ const auto lastSelectedIndex = _filteredActionsView ().SelectedIndex ();
729
+
728
730
_updateFilteredActions ();
729
731
730
732
// In the command line mode we want the user to explicitly select the command
731
- _filteredActionsView ().SelectedIndex (0 );
733
+ _filteredActionsView ().SelectedIndex (std::min< int32_t >(lastSelectedIndex, _filteredActionsView (). Items (). Size () - 1 ) );
732
734
733
735
const auto currentNeedleHasResults{ _filteredActions.Size () > 0 };
734
736
_noMatchesText ().Visibility (currentNeedleHasResults ? Visibility::Collapsed : Visibility::Visible);
@@ -738,7 +740,7 @@ namespace winrt::TerminalApp::implementation
738
740
Automation::Peers::AutomationNotificationKind::ActionCompleted,
739
741
Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
740
742
currentNeedleHasResults ?
741
- winrt::hstring{ fmt::format (std::wstring_view{ RS_ (L" CommandPalette_MatchesAvailable " ) }, _filteredActions.Size ()) } :
743
+ winrt::hstring{ fmt::format (std::wstring_view{ RS_ (L" SuggestionsControl_MatchesAvailable " ) }, _filteredActions.Size ()) } :
742
744
NoMatchesText (), // what to announce if results were found
743
745
L" SuggestionsControlResultAnnouncement" /* unique name for this group of notifications */ );
744
746
}
@@ -781,9 +783,6 @@ namespace winrt::TerminalApp::implementation
781
783
782
784
void SuggestionsControl::_switchToMode ()
783
785
{
784
- const auto currentlyVisible{ Visibility () == Visibility::Visible };
785
-
786
- auto modeAnnouncementResourceKey{ USES_RESOURCE (L" CommandPaletteModeAnnouncement_ActionMode" ) };
787
786
ParsedCommandLineText (L" " );
788
787
_searchBox ().Text (L" " );
789
788
_searchBox ().Select (_searchBox ().Text ().size (), 0 );
@@ -795,23 +794,9 @@ namespace winrt::TerminalApp::implementation
795
794
// guarantees that the correct text is shown for the mode
796
795
// whenever _switchToMode is called.
797
796
798
- SearchBoxPlaceholderText (RS_ (L" CommandPalette_SearchBox/PlaceholderText" ));
799
- NoMatchesText (RS_ (L" CommandPalette_NoMatchesText/Text" ));
800
- ControlName (RS_ (L" CommandPaletteControlName" ));
801
- // modeAnnouncementResourceKey is already set to _ActionMode
802
- // We did this above to deduce the type (and make it easier on ourselves later).
803
-
804
- if (currentlyVisible)
805
- {
806
- if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement (_searchBox ()) })
807
- {
808
- automationPeer.RaiseNotificationEvent (
809
- Automation::Peers::AutomationNotificationKind::ActionCompleted,
810
- Automation::Peers::AutomationNotificationProcessing::CurrentThenMostRecent,
811
- GetLibraryResourceString (modeAnnouncementResourceKey),
812
- L" SuggestionsControlModeSwitch" /* unique ID for this notification */ );
813
- }
814
- }
797
+ SearchBoxPlaceholderText (RS_ (L" SuggestionsControl_SearchBox/PlaceholderText" ));
798
+ NoMatchesText (RS_ (L" SuggestionsControl_NoMatchesText/Text" ));
799
+ ControlName (RS_ (L" SuggestionsControlName" ));
815
800
816
801
// The smooth remove/add animations that happen during
817
802
// UpdateFilteredActions don't work very well when switching between
@@ -1004,7 +989,7 @@ namespace winrt::TerminalApp::implementation
1004
989
1005
990
if (dataTemplate == _itemTemplateSelector.NestedItemTemplate ())
1006
991
{
1007
- const auto helpText = winrt::box_value (RS_ (L" CommandPalette_MoreOptions /[using:Windows.UI.Xaml.Automation]AutomationProperties/HelpText" ));
992
+ const auto helpText = winrt::box_value (RS_ (L" SuggestionsControl_MoreOptions /[using:Windows.UI.Xaml.Automation]AutomationProperties/HelpText" ));
1008
993
listViewItem.SetValue (Automation::AutomationProperties::HelpTextProperty (), helpText);
1009
994
}
1010
995
@@ -1104,6 +1089,19 @@ namespace winrt::TerminalApp::implementation
1104
1089
Margin (newMargin);
1105
1090
1106
1091
_searchBox ().Text (filter);
1092
+
1093
+ // If we're in bottom-up mode, make sure to re-select the _last_ item in
1094
+ // the list, so that it's like we're starting with the most recent one
1095
+ // selected.
1096
+ if (_direction == TerminalApp::SuggestionsDirection::BottomUp)
1097
+ {
1098
+ const auto last = _filteredActionsView ().Items ().Size () - 1 ;
1099
+ _filteredActionsView ().SelectedIndex (last);
1100
+ }
1101
+ // Move the cursor to the very last position, so it starts immediately
1102
+ // after the text. This is apparently done by starting a 0-wide
1103
+ // selection starting at the end of the string.
1104
+ _searchBox ().Select (filter.size (), 0 );
1107
1105
}
1108
1106
1109
1107
}
0 commit comments