Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions objdiff-gui/src/views/diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,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()) {
Expand Down Expand Up @@ -452,7 +452,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()) {
Expand Down Expand Up @@ -741,7 +741,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,
Expand Down
35 changes: 29 additions & 6 deletions objdiff-gui/src/views/symbol_diff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 build_running: bool,
pub scratch_available: bool,
pub scratch_running: bool,
Expand Down Expand Up @@ -154,6 +156,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
Expand Down Expand Up @@ -268,12 +273,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 {
Expand Down Expand Up @@ -394,6 +394,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> {
Expand Down
Loading