MCPcopy Index your code
hub / github.com/encounter/objdiff / diff_view_ui

Function diff_view_ui

objdiff-gui/src/views/diff.rs:120–717  ·  view source on GitHub ↗
(
    ui: &mut Ui,
    state: &DiffViewState,
    appearance: &Appearance,
    diff_config: &DiffObjConfig,
)

Source from the content-addressed store, hash-verified

118
119#[must_use]
120pub fn diff_view_ui(
121 ui: &mut Ui,
122 state: &DiffViewState,
123 appearance: &Appearance,
124 diff_config: &DiffObjConfig,
125) -> Option<DiffViewAction> {
126 let mut ret = None;
127 let Some(result) = &state.build else {
128 return ret;
129 };
130
131 let left_ctx = DiffColumnContext::new(
132 state.current_view,
133 &result.first_status,
134 result.first_obj.as_ref(),
135 state.symbol_state.left_symbol.as_ref(),
136 );
137 let right_ctx = DiffColumnContext::new(
138 state.current_view,
139 &result.second_status,
140 result.second_obj.as_ref(),
141 state.symbol_state.right_symbol.as_ref(),
142 );
143
144 // Check if we need to perform any navigation
145 let current_navigation = DiffViewNavigation {
146 kind: match state.current_view {
147 View::ExtabDiff => SymbolNavigationKind::Extab,
148 _ => SymbolNavigationKind::Normal,
149 },
150 left_symbol: left_ctx.symbol.map(|(_, _, idx)| idx),
151 right_symbol: right_ctx.symbol.map(|(_, _, idx)| idx),
152 };
153 let mut navigation = current_navigation.clone();
154 if let Some((_symbol, symbol_diff, _symbol_idx)) = left_ctx.symbol {
155 // If a matching symbol appears, select it
156 if !right_ctx.has_symbol()
157 && let Some(target_symbol_ref) = symbol_diff.target_symbol
158 {
159 navigation.right_symbol = Some(target_symbol_ref);
160 }
161 } else if navigation.left_symbol.is_some() && left_ctx.obj.is_some() {
162 // Clear selection if symbol goes missing
163 navigation.left_symbol = None;
164 }
165 if let Some((_symbol, symbol_diff, _symbol_idx)) = right_ctx.symbol {
166 // If a matching symbol appears, select it
167 if !left_ctx.has_symbol()
168 && let Some(target_symbol_ref) = symbol_diff.target_symbol
169 {
170 navigation.left_symbol = Some(target_symbol_ref);
171 }
172 } else if navigation.right_symbol.is_some() && right_ctx.obj.is_some() {
173 // Clear selection if symbol goes missing
174 navigation.right_symbol = None;
175 }
176 // If both sides are missing a symbol, switch to symbol diff view
177 if navigation.left_symbol.is_none() && navigation.right_symbol.is_none() {

Callers 1

updateMethod · 0.85

Calls 15

render_headerFunction · 0.85
back_pressedFunction · 0.85
get_asm_textFunction · 0.85
symbol_label_uiFunction · 0.85
parseFunction · 0.85
match_color_for_symbolFunction · 0.85
check_scroll_hotkeysFunction · 0.85

Tested by

no test coverage detected