debugger: Fix inline values panic when selecting stack frames (#30821)

Release Notes:

- debugger beta: Fix panic that could occur when selecting a stack frame
- debugger beta: Fix inline values not showing in stack trace view

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Co-authored-by: Remco Smits <djsmits12@gmail.com>
This commit is contained in:
Anthony Eid 2025-05-16 15:42:09 +02:00 committed by GitHub
parent 0355b9dfab
commit 33b60bc16d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 35 additions and 23 deletions

View file

@ -2,16 +2,14 @@
{ {
"label": "Debug Zed (CodeLLDB)", "label": "Debug Zed (CodeLLDB)",
"adapter": "CodeLLDB", "adapter": "CodeLLDB",
"program": "$ZED_WORKTREE_ROOT/target/debug/zed", "program": "target/debug/zed",
"request": "launch", "request": "launch"
"cwd": "$ZED_WORKTREE_ROOT"
}, },
{ {
"label": "Debug Zed (GDB)", "label": "Debug Zed (GDB)",
"adapter": "GDB", "adapter": "GDB",
"program": "$ZED_WORKTREE_ROOT/target/debug/zed", "program": "target/debug/zed",
"request": "launch", "request": "launch",
"cwd": "$ZED_WORKTREE_ROOT",
"initialize_args": { "initialize_args": {
"stopAtBeginningOfMainSubprogram": true "stopAtBeginningOfMainSubprogram": true
} }

View file

@ -18067,10 +18067,6 @@ impl Editor {
.and_then(|lines| lines.last().map(|line| line.range.start)); .and_then(|lines| lines.last().map(|line| line.range.start));
self.inline_value_cache.refresh_task = cx.spawn(async move |editor, cx| { self.inline_value_cache.refresh_task = cx.spawn(async move |editor, cx| {
let snapshot = editor
.update(cx, |editor, cx| editor.buffer().read(cx).snapshot(cx))
.ok()?;
let inline_values = editor let inline_values = editor
.update(cx, |editor, cx| { .update(cx, |editor, cx| {
let Some(current_execution_position) = current_execution_position else { let Some(current_execution_position) = current_execution_position else {
@ -18098,22 +18094,40 @@ impl Editor {
.context("refreshing debugger inlays") .context("refreshing debugger inlays")
.log_err()?; .log_err()?;
let (excerpt_id, buffer_id) = snapshot let mut buffer_inline_values: HashMap<BufferId, Vec<InlayHint>> = HashMap::default();
.excerpts()
.next() for (buffer_id, inline_value) in inline_values
.map(|excerpt| (excerpt.0, excerpt.1.remote_id()))?; .into_iter()
.filter_map(|hint| Some((hint.position.buffer_id?, hint)))
{
buffer_inline_values
.entry(buffer_id)
.or_default()
.push(inline_value);
}
editor editor
.update(cx, |editor, cx| { .update(cx, |editor, cx| {
let new_inlays = inline_values let snapshot = editor.buffer.read(cx).snapshot(cx);
.into_iter() let mut new_inlays = Vec::default();
.map(|debugger_value| {
Inlay::debugger_hint( for (excerpt_id, buffer_snapshot, _) in snapshot.excerpts() {
post_inc(&mut editor.next_inlay_id), let buffer_id = buffer_snapshot.remote_id();
Anchor::in_buffer(excerpt_id, buffer_id, debugger_value.position), buffer_inline_values
debugger_value.text(), .get(&buffer_id)
) .into_iter()
}) .flatten()
.collect::<Vec<_>>(); .for_each(|hint| {
let inlay = Inlay::debugger_hint(
post_inc(&mut editor.next_inlay_id),
Anchor::in_buffer(excerpt_id, buffer_id, hint.position),
hint.text(),
);
new_inlays.push(inlay);
});
}
let mut inlay_ids = new_inlays.iter().map(|inlay| inlay.id).collect(); let mut inlay_ids = new_inlays.iter().map(|inlay| inlay.id).collect();
std::mem::swap(&mut editor.inline_value_cache.inlays, &mut inlay_ids); std::mem::swap(&mut editor.inline_value_cache.inlays, &mut inlay_ids);