Fix Search Crash from Scrolling (#5571)

* Fix search crashing when section child scrolled too far.

* clang
This commit is contained in:
Malkierian 2025-06-11 14:35:57 -07:00 committed by GitHub
commit 0b9fe2d9b9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -185,8 +185,8 @@ bool ModernMenuHeaderEntry(std::string label) {
}
uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
ImGui::BeginChild("Search Results");
int searchCount = 0;
if (ImGui::BeginChild("Search Results")) {
for (auto& menuLabel : menuOrder) {
auto& menuEntry = menuEntries.at(menuLabel);
for (auto& sidebarLabel : menuEntry.sidebarOrder) {
@ -208,7 +208,8 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
if (widgetStr.find(menuSearchText) != std::string::npos) {
MenuDrawItem(info, 90 / sidebar.columnCount, menuThemeIndex);
ImGui::PushStyleColor(ImGuiCol_Text, UIWidgets::ColorValues.at(UIWidgets::Colors::Gray));
std::string origin = fmt::format(" ({} -> {}, Col {})", menuEntry.label, sidebarLabel, i + 1);
std::string origin =
fmt::format(" ({} -> {}, Col {})", menuEntry.label, sidebarLabel, i + 1);
ImGui::Text("%s", origin.c_str());
ImGui::PopStyleColor();
searchCount++;
@ -217,6 +218,7 @@ uint32_t Menu::DrawSearchResults(std::string& menuSearchText) {
}
}
}
}
return searchCount;
}