Terminal crashes when navigating in empty palette #11607

Open
opened 2026-01-31 02:52:24 +00:00 by claunia · 0 comments
Owner

Originally created by @Don-Vito on GitHub (Nov 27, 2020).

Environment

Windows Terminal version (if applicable): both 1.4 and 1.5

Steps to reproduce

  1. Open command palette
  2. Type filter that is not matched by any command
  3. Press "UP"
  4. Enjoy postmortem debugger

The reason is double bug here

void CommandPalette::SelectNextItem(const bool moveDown)
    {
        const auto selected = _filteredActionsView().SelectedIndex();
        const int numItems = ::base::saturated_cast<int>(_filteredActionsView().Items().Size());
       
        const auto newIndex = ((numItems + selected + (moveDown ? 1 : -1)) % numItems);
        _filteredActionsView().SelectedIndex(newIndex);
        _filteredActionsView().ScrollIntoView(_filteredActionsView().SelectedItem());
    }

We both do the math when numItems=0, and when we go up starting from selected=-1.

I have a fix here: https://github.com/microsoft/terminal/pull/8420.
But I will probably extract it to a separate PR.

Originally created by @Don-Vito on GitHub (Nov 27, 2020). # Environment ``` Windows Terminal version (if applicable): both 1.4 and 1.5 ``` # Steps to reproduce 1. Open command palette 2. Type filter that is not matched by any command 3. Press "UP" 4. Enjoy postmortem debugger The reason is double bug here ``` void CommandPalette::SelectNextItem(const bool moveDown) { const auto selected = _filteredActionsView().SelectedIndex(); const int numItems = ::base::saturated_cast<int>(_filteredActionsView().Items().Size()); const auto newIndex = ((numItems + selected + (moveDown ? 1 : -1)) % numItems); _filteredActionsView().SelectedIndex(newIndex); _filteredActionsView().ScrollIntoView(_filteredActionsView().SelectedItem()); } ``` We both do the math when numItems=0, and when we go up starting from selected=-1. I have a fix here: https://github.com/microsoft/terminal/pull/8420. But I will probably extract it to a separate PR.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11607