Skip to content

Commit c7ac7f8

Browse files
committed
Separate the mapping filter from the regular filter
1 parent 79ca201 commit c7ac7f8

2 files changed

Lines changed: 32 additions & 9 deletions

File tree

objdiff-gui/src/views/diff.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ pub fn diff_view_ui(
287287
});
288288
} else if left_ctx.status.success && !left_ctx.has_symbol() {
289289
ui.horizontal(|ui| {
290-
let mut search = state.search.clone();
290+
let mut search = state.get_current_search();
291291
let response =
292292
TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
293293
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
@@ -452,7 +452,7 @@ pub fn diff_view_ui(
452452
}
453453
}
454454
} else if right_ctx.status.success && !right_ctx.has_symbol() {
455-
let mut search = state.search.clone();
455+
let mut search = state.get_current_search();
456456
let response =
457457
TextEdit::singleline(&mut search).hint_text("Filter symbols").ui(ui);
458458
if hotkeys::consume_symbol_filter_shortcut(ui.ctx()) {
@@ -741,7 +741,7 @@ fn diff_col_ui(
741741
ui,
742742
SymbolDiffContext { obj, diff },
743743
&state.symbol_state,
744-
SymbolFilter::Mapping(other_symbol_idx, state.search_regex.as_ref()),
744+
SymbolFilter::Mapping(other_symbol_idx, state.mapping_search_regex.as_ref()),
745745
appearance,
746746
column,
747747
open_sections,

objdiff-gui/src/views/symbol_diff.rs

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ pub struct DiffViewState {
118118
pub function_state: FunctionViewState,
119119
pub search: String,
120120
pub search_regex: Option<Regex>,
121+
pub mapping_search: String,
122+
pub mapping_search_regex: Option<Regex>,
121123
pub build_running: bool,
122124
pub scratch_available: bool,
123125
pub scratch_running: bool,
@@ -154,6 +156,9 @@ impl DiffViewState {
154156
self.current_view = result.view;
155157
self.symbol_state.left_symbol = result.left_symbol;
156158
self.symbol_state.right_symbol = result.right_symbol;
159+
// Clear the mapping filter so it's not saved between mapping different symbols.
160+
self.mapping_search = "".to_string();
161+
self.mapping_search_regex = None;
157162
}
158163

159164
false
@@ -268,12 +273,7 @@ impl DiffViewState {
268273
self.symbol_state.autoscroll_to_highlighted_symbols = autoscroll;
269274
}
270275
DiffViewAction::SetSearch(search) => {
271-
self.search_regex = if search.is_empty() {
272-
None
273-
} else {
274-
RegexBuilder::new(&search).case_insensitive(true).build().ok()
275-
};
276-
self.search = search;
276+
self.set_search(search);
277277
}
278278
DiffViewAction::CreateScratch(function_name) => {
279279
let Ok(state) = state.read() else {
@@ -394,6 +394,29 @@ impl DiffViewState {
394394
target_symbol: symbol_diff.target_symbol,
395395
})
396396
}
397+
398+
pub fn get_current_search(&self) -> String {
399+
if self.current_view == View::FunctionDiff {
400+
self.mapping_search.clone()
401+
} else {
402+
self.search.clone()
403+
}
404+
}
405+
406+
fn set_search(&mut self, search: String) {
407+
let search_regex = if search.is_empty() {
408+
None
409+
} else {
410+
RegexBuilder::new(&search).case_insensitive(true).build().ok()
411+
};
412+
if self.current_view == View::FunctionDiff {
413+
self.mapping_search = search;
414+
self.mapping_search_regex = search_regex;
415+
} else {
416+
self.search = search;
417+
self.search_regex = search_regex;
418+
}
419+
}
397420
}
398421

399422
struct ResolvedSymbol<'obj> {

0 commit comments

Comments
 (0)