From a0fbf324696ddda41a954c1fd9672751fd235644 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 18 Aug 2026 11:13:33 +0200 Subject: [PATCH] ImDebugger: add a filter box above the symbol list A game with symbols loaded puts a few thousand functions in that list, and the only way to reach one was to scroll. Typing part of a name now narrows it, case-insensitively. The filter produces a list of indices into the symbol cache rather than a filtered copy of it, so selectedSymbol_ keeps meaning the same thing whether or not a filter is active - the Edit Symbol box above the list needs it to index the cache. Rebuilt when the filter text changes or the symbol map reloads, not per frame, and the list clipper works off the match list so a filter that matches everything costs no more to draw than before. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01GZq8ZtJmFY7bkX5FVkr3P9 --- UI/ImDebugger/ImDisasmView.cpp | 23 +++++++++++++++++++++-- UI/ImDebugger/ImDisasmView.h | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/UI/ImDebugger/ImDisasmView.cpp b/UI/ImDebugger/ImDisasmView.cpp index 7b325298c5..fbecad6498 100644 --- a/UI/ImDebugger/ImDisasmView.cpp +++ b/UI/ImDebugger/ImDisasmView.cpp @@ -1296,6 +1296,7 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro if (symCache_.empty() || symsDirty_) { symCache_ = g_symbolMap->GetAllActiveSymbols(SymbolType::ST_FUNCTION); symsDirty_ = false; + symMatchesDirty_ = true; } if (selectedSymbol_ >= 0 && selectedSymbol_ < symCache_.size()) { @@ -1310,11 +1311,29 @@ void ImDisasmWindow::Draw(MIPSDebugInterface *mipsDebug, ImConfig &cfg, ImContro } } + ImGui::SetNextItemWidth(-1.0f); + if (ImGui::InputTextWithHint("##symfilter", "Filter symbols", symFilter_, sizeof(symFilter_))) { + symMatchesDirty_ = true; + } + + if (symMatchesDirty_) { + symMatchesDirty_ = false; + symMatches_.clear(); + // An empty filter still builds the index list, so the draw loop below has only one + // path to get wrong. These lists run to a few thousand entries, and this only reruns + // when the filter or the symbol map changes, not per frame. + for (int i = 0; i < (int)symCache_.size(); i++) { + if (symFilter_[0] == '\0' || containsNoCase(symCache_[i].name, symFilter_)) + symMatches_.push_back(i); + } + } + if (ImGui::BeginListBox("##symbols", ImGui::GetContentRegionAvail())) { ImGuiListClipper clipper; - clipper.Begin((int)symCache_.size(), -1); + clipper.Begin((int)symMatches_.size(), -1); while (clipper.Step()) { - for (int i = clipper.DisplayStart; i < clipper.DisplayEnd; i++) { + for (int row = clipper.DisplayStart; row < clipper.DisplayEnd; row++) { + const int i = symMatches_[row]; if (ImGui::Selectable(symCache_[i].name.c_str(), selectedSymbol_ == i)) { disasmView_.gotoAddr(symCache_[i].address); disasmView_.scrollAddressIntoView(); diff --git a/UI/ImDebugger/ImDisasmView.h b/UI/ImDebugger/ImDisasmView.h index 8e331f3e31..1412158717 100644 --- a/UI/ImDebugger/ImDisasmView.h +++ b/UI/ImDebugger/ImDisasmView.h @@ -221,6 +221,12 @@ private: int selectedSymbol_ = -1; char selectedSymbolName_[128]; + // Filter over symCache_. Held as indices into it rather than a filtered copy, so + // selectedSymbol_ keeps meaning the same thing whether or not a filter is active. + char symFilter_[64]{}; + std::vector symMatches_; + bool symMatchesDirty_ = true; + ImDisasmView disasmView_; char searchTerm_[64]{}; };