Fix the symbol filter not working in the mapping view (#315)

* Fix the symbol filter not working in the mapping view

* Separate the mapping filter from the regular filter

* Make set/get search function names consistent with each other
This commit is contained in:
LagoLunatic
2026-01-24 20:15:01 -05:00
committed by GitHub
parent 46b8890159
commit 08ebea8bd2
2 changed files with 32 additions and 9 deletions
+3 -3
View File
@@ -290,7 +290,7 @@ pub fn diff_view_ui(
});
} else if left_ctx.status.success && !left_ctx.has_symbol() {
ui.horizontal(|ui| {
let mut search = state.search.clone();
let mut search = state.get_current_search();
let response =
TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
@@ -480,7 +480,7 @@ pub fn diff_view_ui(
}
}
} else if right_ctx.status.success && !right_ctx.has_symbol() {
let mut search = state.search.clone();
let mut search = state.get_current_search();
let response =
TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
@@ -827,7 +827,7 @@ fn diff_col_ui(
ui,
SymbolDiffContext { obj, diff },
&state.symbol_state,
SymbolFilter::Mapping(other_symbol_idx, None),
SymbolFilter::Mapping(other_symbol_idx, state.mapping_search_regex.as_ref()),
appearance,
column,
open_sections,
+29 -6
View File
@@ -118,6 +118,8 @@ pub struct DiffViewState {
pub function_state: FunctionViewState,
pub search: String,
pub search_regex: Option<Regex>,
pub mapping_search: String,
pub mapping_search_regex: Option<Regex>,
pub scroll_to_diff_row: Option<usize>,
pub build_running: bool,
pub scratch_available: bool,
@@ -155,6 +157,9 @@ impl DiffViewState {
self.current_view = result.view;
self.symbol_state.left_symbol = result.left_symbol;
self.symbol_state.right_symbol = result.right_symbol;
// Clear the mapping filter so it's not saved between mapping different symbols.
self.mapping_search = "".to_string();
self.mapping_search_regex = None;
}
false
@@ -269,12 +274,7 @@ impl DiffViewState {
self.symbol_state.autoscroll_to_highlighted_symbols = autoscroll;
}
DiffViewAction::SetSearch(search) => {
self.search_regex = if search.is_empty() {
None
} else {
RegexBuilder::new(&search).case_insensitive(true).build().ok()
};
self.search = search;
self.set_current_search(search);
}
DiffViewAction::CreateScratch(function_name) => {
let Ok(state) = state.read() else {
@@ -395,6 +395,29 @@ impl DiffViewState {
target_symbol: symbol_diff.target_symbol,
})
}
pub fn get_current_search(&self) -> String {
if self.current_view == View::FunctionDiff {
self.mapping_search.clone()
} else {
self.search.clone()
}
}
fn set_current_search(&mut self, search: String) {
let search_regex = if search.is_empty() {
None
} else {
RegexBuilder::new(&search).case_insensitive(true).build().ok()
};
if self.current_view == View::FunctionDiff {
self.mapping_search = search;
self.mapping_search_regex = search_regex;
} else {
self.search = search;
self.search_regex = search_regex;
}
}
}
struct ResolvedSymbol<'obj> {