Terminal crashes when navigating in empty palette #11610

Closed
opened 2026-01-31 02:52:31 +00:00 by claunia · 2 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.
Author
Owner

@zadjii-msft commented on GitHub (Nov 29, 2020):

G U H

Yep that's an easily repro-able crash alright, thanks for hoping on the fix so quick

@zadjii-msft commented on GitHub (Nov 29, 2020): _G U H_ Yep that's an easily repro-able crash alright, thanks for hoping on the fix so quick
Author
Owner

@ghost commented on GitHub (Jan 28, 2021):

:tada:This issue was addressed in #8422, which has now been successfully released as Windows Terminal Preview v1.6.10272.0.🎉

Handy links:

@ghost commented on GitHub (Jan 28, 2021): :tada:This issue was addressed in #8422, which has now been successfully released as `Windows Terminal Preview v1.6.10272.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.6.10272.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11610