Repository: microsoft/terminal
File: src/cascadia/TerminalApp/SuggestionsControl.cpp (C++)

Code before:
        const auto currentNeedleHasResults{ _filteredActions.Size() > 0 };
        _noMatchesText().Visibility(currentNeedleHasResults ? Visibility::Collapsed : Visibility::Visible);
        if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(_searchBox()) })
        {
            automationPeer.RaiseNotificationEvent(
                Automation::Peers::AutomationNotificationKind::ActionCompleted,
                Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
                currentNeedleHasResults ?
                    winrt::hstring{ fmt::format(std::wstring_view{ RS_(L"SuggestionsControl_MatchesAvailable") }, _filteredActions.Size()) } :
                    NoMatchesText(), // what to announce if results were found
                L"SuggestionsControlResultAnnouncement" /* unique name for this group of notifications */);
        }
    }

    Collections::IObservableVector<winrt::TerminalApp::FilteredCommand> SuggestionsControl::FilteredActions()
    {
        return _filteredActions;
    }

    void SuggestionsControl::SetCommands(const Collections::IVector<Command>& actions)
    {
        _allCommands.Clear();
        for (const auto& action : actions)
        {
            // key chords aren't relevant in the suggestions control, so make the palette item with just the command and no keys
            auto actionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action, L"") };
            auto filteredCommand{ winrt::make<FilteredCommand>(actionPaletteItem) };
            _allCommands.Append(filteredCommand);
        }

        if (Visibility() == Visibility::Visible)
        {
            _updateFilteredActions();
        }
        else // THIS BRANCH IS NEW
        {
            auto actions = _collectFilteredActions();
            _filteredActions.Clear();
            for (const auto& action : actions)
            {
                _filteredActions.Append(action);
            }
        }
    }

    void SuggestionsControl::_switchToMode()
    {
        ParsedCommandLineText(L"");
        _searchBox().Text(L"");
        _searchBox().Select(_searchBox().Text().size(), 0);


Review comment (suggestion):
```suggestion
            auto actionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action, {}) };
```

Code after:
        const auto currentNeedleHasResults{ _filteredActions.Size() > 0 };
        _noMatchesText().Visibility(currentNeedleHasResults ? Visibility::Collapsed : Visibility::Visible);
        if (auto automationPeer{ Automation::Peers::FrameworkElementAutomationPeer::FromElement(_searchBox()) })
        {
            automationPeer.RaiseNotificationEvent(
                Automation::Peers::AutomationNotificationKind::ActionCompleted,
                Automation::Peers::AutomationNotificationProcessing::ImportantMostRecent,
                currentNeedleHasResults ?
                    winrt::hstring{ fmt::format(std::wstring_view{ RS_(L"SuggestionsControl_MatchesAvailable") }, _filteredActions.Size()) } :
                    NoMatchesText(), // what to announce if results were found
                L"SuggestionsControlResultAnnouncement" /* unique name for this group of notifications */);
        }
    }

    Collections::IObservableVector<winrt::TerminalApp::FilteredCommand> SuggestionsControl::FilteredActions()
    {
        return _filteredActions;
    }

    void SuggestionsControl::SetCommands(const Collections::IVector<Command>& actions)
    {
        _allCommands.Clear();
        for (const auto& action : actions)
        {
            // key chords aren't relevant in the suggestions control, so make the palette item with just the command and no keys
            auto actionPaletteItem{ winrt::make<winrt::TerminalApp::implementation::ActionPaletteItem>(action, winrt::hstring{}) };
            auto filteredCommand{ winrt::make<FilteredCommand>(actionPaletteItem) };
            _allCommands.Append(filteredCommand);
        }

        if (Visibility() == Visibility::Visible)
        {
            _updateFilteredActions();
        }
        else // THIS BRANCH IS NEW
        {
            auto actions = _collectFilteredActions();
            _filteredActions.Clear();
            for (const auto& action : actions)
            {
                _filteredActions.Append(action);
            }
        }
    }

    void SuggestionsControl::_switchToMode()
    {
        ParsedCommandLineText(L"");
        _searchBox().Text(L"");
        _searchBox().Select(_searchBox().Text().size(), 0);