debugger: Highlight the size of jumped-to memory (#34504)

Closes #ISSUE

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-07-16 01:32:48 +02:00 committed by GitHub
parent afbd2b760f
commit 7ca3d969e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 8 deletions

View file

@ -159,6 +159,11 @@ impl MemoryView {
open_context_menu: None, open_context_menu: None,
}; };
this.change_query_bar_mode(false, window, cx); this.change_query_bar_mode(false, window, cx);
cx.on_focus_out(&this.focus_handle, window, |this, _, window, cx| {
this.change_query_bar_mode(false, window, cx);
cx.notify();
})
.detach();
this this
} }
fn hide_scrollbar(&mut self, window: &mut Window, cx: &mut Context<Self>) { fn hide_scrollbar(&mut self, window: &mut Window, cx: &mut Context<Self>) {
@ -583,16 +588,22 @@ impl MemoryView {
else { else {
return; return;
}; };
let expr = format!("?${{{expr}}}");
let reference = self.session.update(cx, |this, cx| { let reference = self.session.update(cx, |this, cx| {
this.memory_reference_of_expr(selected_frame, expr, cx) this.memory_reference_of_expr(selected_frame, expr, cx)
}); });
cx.spawn(async move |this, cx| { cx.spawn(async move |this, cx| {
if let Some(reference) = reference.await { if let Some((reference, typ)) = reference.await {
_ = this.update(cx, |this, cx| { _ = this.update(cx, |this, cx| {
let Ok(address) = parse_int::parse::<u64>(&reference) else { let sizeof_expr = if typ.as_ref().is_some_and(|t| {
return; t.chars()
.all(|c| c.is_whitespace() || c.is_alphabetic() || c == '*')
}) {
typ.as_deref()
} else {
None
}; };
this.jump_to_address(address, cx); this.go_to_memory_reference(&reference, sizeof_expr, selected_frame, cx);
}); });
} }
}) })
@ -763,7 +774,7 @@ fn render_single_memory_view_line(
this.when(selection.contains(base_address + cell_ix as u64), |this| { this.when(selection.contains(base_address + cell_ix as u64), |this| {
let weak = weak.clone(); let weak = weak.clone();
this.bg(Color::Accent.color(cx)).when( this.bg(Color::Selected.color(cx).opacity(0.2)).when(
!selection.is_dragging(), !selection.is_dragging(),
|this| { |this| {
let selection = selection.drag().memory_range(); let selection = selection.drag().memory_range();
@ -860,7 +871,7 @@ fn render_single_memory_view_line(
.px_0p5() .px_0p5()
.when_some(view_state.selection.as_ref(), |this, selection| { .when_some(view_state.selection.as_ref(), |this, selection| {
this.when(selection.contains(base_address + ix as u64), |this| { this.when(selection.contains(base_address + ix as u64), |this| {
this.bg(Color::Accent.color(cx)) this.bg(Color::Selected.color(cx).opacity(0.2))
}) })
}) })
.child( .child(

View file

@ -1787,7 +1787,7 @@ impl Session {
frame_id: Option<u64>, frame_id: Option<u64>,
expression: String, expression: String,
cx: &mut Context<Self>, cx: &mut Context<Self>,
) -> Task<Option<String>> { ) -> Task<Option<(String, Option<String>)>> {
let request = self.request( let request = self.request(
EvaluateCommand { EvaluateCommand {
expression, expression,
@ -1801,7 +1801,9 @@ impl Session {
); );
cx.background_spawn(async move { cx.background_spawn(async move {
let result = request.await?; let result = request.await?;
result.memory_reference result
.memory_reference
.map(|reference| (reference, result.type_))
}) })
} }