Fix search auto-selecting wrong item before programs finish loading (#2451)

fix: defer auto-select until programs loaded to prevent wrong search result selection

When search results refresh mid-collection, OnRefresh auto-selects the
first result item. If programs haven't loaded yet, Settings category
appears first and gets selected. If user hits Enter in that window,
wrong item launches.

Skip auto-select when search is still in progress and no programs
have been found yet. Next refresh after programs load will select
correctly.

Fixes Open-Shell/Open-Shell-Menu#456
Fixes Open-Shell/Open-Shell-Menu#1982
Fixes Open-Shell/Open-Shell-Menu#4

> 🤖 Generated with [Claude Code](https://claude.ai/code)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Nicholas N.
2026-04-18 21:18:23 +08:00
committed by GitHub
parent e2758ec376
commit 32ad90f17d

View File

@@ -6366,7 +6366,10 @@ LRESULT CMenuContainer::OnRefresh( UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL
} }
} }
else if (m_Items[m_OriginalCount].id==MENU_SEARCH_CATEGORY) else if (m_Items[m_OriginalCount].id==MENU_SEARCH_CATEGORY)
hotItem=m_OriginalCount+1; {
if (!bSearching || !s_SearchResults.programs.empty())
hotItem=m_OriginalCount+1;
}
} }
else else
hotItem=-1; hotItem=-1;