Skip to content

Visual Studio Code, rebuilt in Rust

Rust

feat(debug): track the debug trees' list focus and draw the frame line badge

rokarturf77c4cfe26d3
diff --git a/native/crates/app/src/workbench/debug_view.rs b/native/crates/app/src/workbench/debug_view.rs
index 4e620f241d5..6090d6f6106 100644
--- a/native/crates/app/src/workbench/debug_view.rs
+++ b/native/crates/app/src/workbench/debug_view.rs
@@ -45,6 +45,10 @@ pub struct DebugView {
/// The breakpoint Run to Cursor added, removed at the next stop or session end.
pub run_to_cursor: Option<String>,
pub selected: Option<String>,
+ /// The list focus (listWidget.ts `setFocus`): the row last clicked or right-clicked.
+ pub focused_row: Option<String>,
+ /// The DOM focus of each view's tree, which turns its selection active and shows its focused row's outline.
+ pub list_focus: std::collections::HashMap<&'static str, gpui::FocusHandle>,
/// The glyph margin line under the pointer, which shows the breakpoint hint.
pub hint: Option<(String, usize)>,
/// The input element of the breakpoint widget, which shows one widget at a time.
@@ -65,6 +69,8 @@ impl DebugView {
input_focus: cx.focus_handle(),
run_to_cursor: None,
selected: None,
+ focused_row: None,
+ list_focus: [VARIABLES_VIEW, WATCH_VIEW, CALL_STACK_VIEW, BREAKPOINTS_VIEW, LOADED_SCRIPTS_VIEW].into_iter().map(|id| (id, cx.focus_handle())).collect(),
hint: None,
widget_view: Default::default(),
widget_focus: cx.focus_handle(),
@@ -282,19 +288,26 @@ impl Workbench {
LOADED_SCRIPTS_VIEW => ("Loaded Scripts", Vec::new()),
_ => ("Run", Vec::new()),
};
+ let list_focus = self.debug_view.list_focus.get(id);
+ let menu_return = self.context_menu.as_ref().and_then(|menu| menu.focus_to_return.as_ref());
+ let list_focused = list_focus.is_some_and(|focus| focus.is_focused(window) || menu_return == Some(focus));
let rows = match id {
- VARIABLES_VIEW => self.variables_rows(cx),
- WATCH_VIEW => self.watch_rows(window, cx),
- CALL_STACK_VIEW => self.call_stack_rows(cx),
- BREAKPOINTS_VIEW => self.breakpoint_rows(window, cx),
- LOADED_SCRIPTS_VIEW => self.loaded_script_rows(),
+ VARIABLES_VIEW => self.variables_rows(list_focused, cx),
+ WATCH_VIEW => self.watch_rows(list_focused, window, cx),
+ CALL_STACK_VIEW => self.call_stack_rows(list_focused, cx),
+ BREAKPOINTS_VIEW => self.breakpoint_rows(list_focused, window, cx),
+ LOADED_SCRIPTS_VIEW => self.loaded_script_rows(list_focused, cx),
_ => vec![self.debug_welcome(window, cx).into_any_element()],
};
let bar = (!actions.is_empty()).then(|| {
let bar = div().flex().gap(px(2.)).children(actions.into_iter().map(|(icon, command, enabled)| self.action_bar_item(id, command, self.search_action(icon, command, enabled, cx), cx)));
bar.into_any_element()
});
- let body = div().id(id).flex_1().min_h_0().overflow_y_scroll().children(rows).into_any_element();
+ // The tree takes the focus in the capture phase, before a row's menu records it as the focus to return to.
+ let body = div().id(id).flex_1().min_h_0().overflow_y_scroll().when_some(list_focus.cloned(), |body, focus| {
+ body.track_focus(&focus).capture_any_mouse_down(move |_, window, cx| window.focus(&focus, cx))
+ });
+ let body = body.children(rows).into_any_element();
super::view_panes::ViewPane { id, title: title.into(), description: None, actions: bar, draws_more: false, show_actions: false, body }
}
@@ -341,20 +354,31 @@ impl Workbench {
unverified.then(|| message.to_owned())
}
- fn debug_row(&self, key: String, depth: usize, twistie: Option<bool>) -> gpui::Stateful<Div> {
- let hover = self.color("list.hoverBackground");
- let selected = self.debug_view.selected.as_deref() == Some(key.as_str());
- let mut row = div()
- .id(gpui::SharedString::from(key))
+ /// A tree row; listWidget.ts `MouseController` moves the list focus to a clicked or right-clicked row and the
+ /// selection to a clicked one.
+ fn debug_row(&self, key: String, depth: usize, twistie: Option<bool>, selected: bool, list_focused: bool, cx: &Context<Self>) -> gpui::Stateful<Div> {
+ let is_focus = self.debug_view.focused_row.as_deref() == Some(key.as_str());
+ let (clicked, right_clicked) = (key.clone(), key.clone());
+ let row = div()
+ .id(gpui::SharedString::from(key.clone()))
+ .debug_selector(move || key)
.h(px(ROW_HEIGHT))
.mx(px(self.pane_row_inset()))
.rounded(px(4.))
.flex()
.items_center()
.cursor_pointer()
- .hover(move |row| row.bg(hover))
- .when(selected, |row| row.bg(self.color("list.inactiveSelectionBackground")))
- .pl(px(INDENT * depth as f32 + 4.));
+ .pl(px(INDENT * depth as f32 + 4.))
+ .on_mouse_down(MouseButton::Left, cx.listener(move |workbench, _: &MouseDownEvent, _, cx| {
+ workbench.debug_view.focused_row = Some(clicked.clone());
+ workbench.debug_view.selected = Some(clicked.clone());
+ cx.notify();
+ }))
+ .on_mouse_down(MouseButton::Right, cx.listener(move |workbench, _: &MouseDownEvent, _, cx| {
+ workbench.debug_view.focused_row = Some(right_clicked.clone());
+ cx.notify();
+ }));
+ let mut row = self.list_row_selection(row, selected, is_focus, list_focused);
let foreground = self.foreground_or("icon.foreground");
row = match twistie {
Some(true) => row.child(self.icon("chevron-down", 16., 16., foreground)),
@@ -417,7 +441,7 @@ impl Workbench {
.into_any_element()
}
- fn variables_rows(&self, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
+ fn variables_rows(&self, list_focused: bool, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
let Some(session) = self.debug.focus.session.clone() else { return Vec::new() };
let mut rows = Vec::new();
let first_cheap = self.debug.scopes.iter().position(|scope| !scope.expensive);
@@ -428,19 +452,20 @@ impl Workbench {
let row_key = key.clone();
let session_id = session.clone();
rows.push(
- self.debug_row(key.clone(), 0, Some(expanded))
+ self.debug_row(key.clone(), 0, Some(expanded), self.row_selected(&key), list_focused, cx)
.child(div().child(scope.name.clone()))
.on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| workbench.toggle_debug_row(&row_key, expanded, &session_id, reference, window, cx)))
.into_any_element(),
);
if expanded {
- self.variable_children(&session, reference, &key, 1, false, &mut rows, cx);
+ self.variable_children(&session, reference, &key, 1, false, list_focused, &mut rows, cx);
}
}
rows
}
- fn variable_children(&self, session: &str, reference: i64, parent: &str, depth: usize, in_watch: bool, rows: &mut Vec<gpui::AnyElement>, cx: &mut Context<Self>) {
+ #[allow(clippy::too_many_arguments)]
+ fn variable_children(&self, session: &str, reference: i64, parent: &str, depth: usize, in_watch: bool, list_focused: bool, rows: &mut Vec<gpui::AnyElement>, cx: &mut Context<Self>) {
let Some(children) = self.debug.children.get(&(session.to_owned(), reference)) else { return };
for variable in children {
let key = format!("{parent}/{}", variable.name);
@@ -448,7 +473,7 @@ impl Workbench {
let expanded = expandable && self.row_expanded(&key, false);
let (row_key, session_id, child_reference) = (key.clone(), session.to_owned(), variable.variables_reference);
let lazy_button = variable.is_lazy().then(|| self.lazy_button(session, reference, variable, &key, cx));
- let mut row = self.debug_row(key.clone(), depth, expandable.then_some(expanded)).child(self.expression_label(variable, &[], lazy_button));
+ let mut row = self.debug_row(key.clone(), depth, expandable.then_some(expanded), self.row_selected(&key), list_focused, cx).child(self.expression_label(variable, &[], lazy_button));
if expandable {
row = row.on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| workbench.toggle_debug_row(&row_key, expanded, &session_id, child_reference, window, cx)));
}
@@ -463,11 +488,15 @@ impl Workbench {
}));
rows.push(row.into_any_element());
if expanded {
- self.variable_children(session, variable.variables_reference, &key, depth + 1, in_watch, rows, cx);
+ self.variable_children(session, variable.variables_reference, &key, depth + 1, in_watch, list_focused, rows, cx);
}
}
}
+ fn row_selected(&self, key: &str) -> bool {
+ self.debug_view.selected.as_deref() == Some(key)
+ }
+
fn row_expanded(&self, key: &str, default: bool) -> bool {
if self.debug_view.expanded.contains(key) {
return true;
@@ -488,20 +517,20 @@ impl Workbench {
cx.notify();
}
- fn watch_rows(&self, window: &Window, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
+ fn watch_rows(&self, list_focused: bool, window: &Window, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
let mut rows = Vec::new();
let session = self.debug.focus.session.clone().unwrap_or_default();
for expression in &self.debug.model.watch_expressions {
let key = format!("watch/{}", expression.id);
if self.debug_view.editing == Some(Editing::Watch(expression.id.clone())) {
- rows.push(self.debug_input_row(key, window, cx));
+ rows.push(self.debug_input_row(key, list_focused, window, cx));
continue;
}
let value = self.debug.watch_values.get(&expression.id).cloned().unwrap_or_else(|| Variable { name: expression.name.clone(), value: "not available".into(), ..Variable::default() });
let expandable = value.has_children();
let expanded = expandable && self.row_expanded(&key, false);
let (row_key, session_id, reference, id) = (key.clone(), session.clone(), value.variables_reference, expression.id.clone());
- let mut row = self.debug_row(key.clone(), 0, expandable.then_some(expanded)).child(self.expression_label(&Variable { name: expression.name.clone(), ..value.clone() }, &[], None));
+ let mut row = self.debug_row(key.clone(), 0, expandable.then_some(expanded), self.row_selected(&key), list_focused, cx).child(self.expression_label(&Variable { name: expression.name.clone(), ..value.clone() }, &[], None));
row = row.on_click(cx.listener(move |workbench, event: &ClickEvent, window, cx| {
if event.click_count() == 2 {
workbench.start_debug_view_edit(Editing::Watch(id.clone()), window, cx);
@@ -518,16 +547,16 @@ impl Workbench {
}));
rows.push(row.into_any_element());
if expanded {
- self.variable_children(&session, value.variables_reference, &key, 1, true, &mut rows, cx);
+ self.variable_children(&session, value.variables_reference, &key, 1, true, list_focused, &mut rows, cx);
}
}
if self.debug_view.editing == Some(Editing::NewWatch) {
- rows.push(self.debug_input_row("watch/new".into(), window, cx));
+ rows.push(self.debug_input_row("watch/new".into(), list_focused, window, cx));
}
rows
}
- fn call_stack_rows(&self, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
+ fn call_stack_rows(&self, list_focused: bool, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
let mut rows = Vec::new();
let call_stack_menu = |item: CallStackItem| cx.listener(move |workbench, event: &MouseDownEvent, window, cx| workbench.show_call_stack_menu(&item, gpui::Bounds::new(event.position, Default::default()), window, cx));
let sessions = &self.debug.sessions;
@@ -541,7 +570,6 @@ impl Workbench {
}
let label_background = self.color("debugView.stateLabelBackground");
let label_foreground = self.color("debugView.stateLabelForeground");
- let description = self.color("descriptionForeground");
let state_label = |text: String| div().ml_auto().mr(px(8.)).px(px(4.)).rounded(px(3.)).text_size(px(10.)).bg(label_background).text_color(label_foreground).child(text.to_uppercase());
for (session, session_depth) in shown {
let depth = session_depth + usize::from(several);
@@ -552,7 +580,7 @@ impl Workbench {
let state = state.split(' ').map(|word| word.chars().next().map_or_else(String::new, |first| first.to_uppercase().chain(word.chars().skip(1)).collect())).collect::<Vec<_>>().join(" ");
let state = div().flex_none().ml_auto().mr(px(8.)).px(px(4.)).rounded(px(3.)).text_size(px(12.)).bg(label_background).text_color(label_foreground).child(state);
let item = CallStackItem::Session(session.id.clone());
- rows.push(self.debug_row(format!("session/{}", session.id), session_depth, Some(true)).child(self.icon("bug", 16., 16., self.foreground_or("icon.foreground"))).child(div().min_w_0().truncate().child(session.name.clone())).child(state).on_mouse_down(MouseButton::Right, call_stack_menu(item)).into_any_element());
+ rows.push(self.debug_row(format!("session/{}", session.id), session_depth, Some(true), false, list_focused, cx).child(self.icon("bug", 16., 16., self.foreground_or("icon.foreground"))).child(div().min_w_0().truncate().child(session.name.clone())).child(state).on_mouse_down(MouseButton::Right, call_stack_menu(item)).into_any_element());
}
for thread in &session.threads {
let thread_key = format!("thread/{}/{}", session.id, thread.id);
@@ -560,7 +588,7 @@ impl Workbench {
let show_thread = session.threads.len() > 1;
if show_thread {
let item = CallStackItem::Thread(session.id.clone(), thread.id);
- rows.push(self.debug_row(thread_key.clone(), depth, Some(true)).child(thread.name.clone()).child(state_label(thread.state_label())).on_mouse_down(MouseButton::Right, call_stack_menu(item)).into_any_element());
+ rows.push(self.debug_row(thread_key.clone(), depth, Some(true), false, list_focused, cx).child(thread.name.clone()).child(state_label(thread.state_label())).on_mouse_down(MouseButton::Right, call_stack_menu(item)).into_any_element());
}
let frame_depth = depth + usize::from(show_thread);
let frames = &thread.frames;
@@ -576,7 +604,7 @@ impl Workbench {
let keys: Vec<String> = folded.iter().map(|frame| format!("deemphasized/{}/{}", session.id, frame.id)).collect();
let label = show_more_label(folded);
rows.push(
- self.debug_row(format!("more-frames/{}/{}", session.id, frame.id), frame_depth, None)
+ self.debug_row(format!("more-frames/{}/{}", session.id, frame.id), frame_depth, None, false, list_focused, cx)
.justify_center()
.text_color(self.color("textLink.foreground"))
.child(div().opacity(0.5).child(label))
@@ -591,18 +619,17 @@ impl Workbench {
}
let frame_menu = call_stack_menu(CallStackItem::Frame(session.id.clone(), thread.id, index - 1));
if frame.presentation_hint.as_deref() == Some("label") {
- rows.push(self.debug_row(format!("frame/{}/{}", session.id, frame.id), frame_depth, None).justify_center().italic().text_color(self.color("descriptionForeground")).child(frame.name.clone()).on_mouse_down(MouseButton::Right, frame_menu).into_any_element());
+ rows.push(self.debug_row(format!("frame/{}/{}", session.id, frame.id), frame_depth, None, false, list_focused, cx).justify_center().italic().text_color(self.color("descriptionForeground")).child(frame.name.clone()).on_mouse_down(MouseButton::Right, frame_menu).into_any_element());
continue;
}
let focused = self.debug.focus.session.as_deref() == Some(session.id.as_str()) && self.debug.focus.frame == Some(frame.id);
let (session_id, thread_id, frame_id) = (session.id.clone(), thread.id, frame.id);
- let file = format!("{} {}:{}", frame.source_name(), frame.line, frame.column);
let row = self
- .debug_row(format!("frame/{}/{}", session.id, frame.id), frame_depth, None)
- .when(focused, |row| row.bg(self.color("list.inactiveSelectionBackground")))
+ .debug_row(format!("frame/{}/{}", session.id, frame.id), frame_depth, None, focused, list_focused, cx)
.when(frame.deemphasized(), |row| row.opacity(0.7))
- .child(div().flex_1().min_w_0().overflow_hidden().whitespace_nowrap().text_ellipsis().child(frame.name.clone()))
- .child(div().flex_none().mr(px(8.)).text_size(px(11.)).text_color(description).child(file))
+ .overflow_hidden()
+ .child(div().flex_1().flex_shrink_0().whitespace_nowrap().child(frame.name.clone()))
+ .child(self.frame_file(frame, focused))
.on_mouse_down(MouseButton::Right, frame_menu)
.on_click(cx.listener(move |workbench, _: &ClickEvent, window, cx| {
let focus = super::debug_service::DebugFocus { session: Some(session_id.clone()), thread: Some(thread_id), frame: Some(frame_id) };
@@ -613,7 +640,7 @@ impl Workbench {
if thread.stopped && thread.total_frames.is_some() {
let (session_id, thread_id) = (session.id.clone(), thread.id);
rows.push(
- self.debug_row(format!("more/{}/{}", session.id, thread.id), frame_depth, None)
+ self.debug_row(format!("more/{}/{}", session.id, thread.id), frame_depth, None, false, list_focused, cx)
.text_color(self.color("textLink.foreground"))
.child("Load More Stack Frames")
.on_click(cx.listener(move |workbench, _: &ClickEvent, _, cx| workbench.fetch_more_frames(&session_id, thread_id, cx)))
@@ -625,7 +652,34 @@ impl Workbench {
rows
}
- fn breakpoint_rows(&self, window: &Window, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
+ /// callStackView.ts `StackFramesRenderer`: the source name 0.8em before the `line:column` count badge, which
+ /// debugColors.ts draws at 60% opacity outside the selected row.
+ fn frame_file(&self, frame: &StackFrame, selected: bool) -> Div {
+ let alpha = if selected { 1. } else { 0.6 };
+ let faded = |color: Rgba| Rgba { a: color.a * alpha, ..color };
+ let line = match frame.column {
+ 0 => frame.line.to_string(),
+ column => format!("{}:{column}", frame.line),
+ };
+ let badge = div()
+ .flex_none()
+ .min_w(px(18.))
+ .min_h(px(18.))
+ .px(px(4.))
+ .rounded(px(11.))
+ .flex()
+ .items_center()
+ .justify_center()
+ .text_size(px(11.))
+ .bg(faded(self.color("badge.background")))
+ .text_color(faded(self.color("badge.foreground")))
+ .when_some(self.theme.color("contrastBorder"), |badge, border| badge.border_1().border_color(border))
+ .child(line);
+ let name = div().min_w_0().mr(px(10.4)).overflow_hidden().whitespace_nowrap().text_ellipsis().child(frame.source_name());
+ div().flex().min_w_0().ml(px(10.4)).mr(px(12.)).justify_end().items_center().overflow_hidden().child(name).child(badge)
+ }
+
+ fn breakpoint_rows(&self, list_focused: bool, window: &Window, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
let mut rows = Vec::new();
let model = &self.debug.model;
let focused = self.debug.focus.session.as_deref();
@@ -635,7 +689,7 @@ impl Workbench {
let id = breakpoint.base.id.clone();
let enabled = breakpoint.base.enabled;
rows.push(
- self.debug_row(format!("exception/{id}"), 0, None)
+ self.debug_row(format!("exception/{id}"), 0, None, self.row_selected(&format!("exception/{id}")), list_focused, cx)
.child(self.debug_checkbox(&id, enabled, cx))
.child(div().child(breakpoint.label.clone()))
.into_any_element(),
@@ -645,7 +699,7 @@ impl Workbench {
let id = breakpoint.base.id.clone();
let icon = if !breakpoint.base.enabled || !model.breakpoints_activated { "debug-breakpoint-function-disabled" } else { "debug-breakpoint-function" };
rows.push(
- self.debug_row(format!("function/{id}"), 0, None)
+ self.debug_row(format!("function/{id}"), 0, None, self.row_selected(&format!("function/{id}")), list_focused, cx)
.child(self.breakpoint_icon(icon, 16.))
.child(self.debug_checkbox(&id, breakpoint.base.enabled, cx))
.child(div().child(breakpoint.name.clone()))
@@ -653,7 +707,7 @@ impl Workbench {
);
}
if self.debug_view.editing == Some(Editing::NewFunctionBreakpoint) {
- rows.push(self.debug_input_row("function/new".into(), window, cx));
+ rows.push(self.debug_input_row("function/new".into(), list_focused, window, cx));
}
for breakpoint in &model.breakpoints {
let id = breakpoint.id().to_owned();
@@ -665,7 +719,7 @@ impl Workbench {
let line = breakpoint.line_number();
let uri = breakpoint.uri.clone();
rows.push(
- self.debug_row(format!("breakpoint/{id}"), 0, None)
+ self.debug_row(format!("breakpoint/{id}"), 0, None, self.row_selected(&format!("breakpoint/{id}")), list_focused, cx)
.child(self.breakpoint_icon(icon, 16.))
.child(self.debug_checkbox(&id, breakpoint.base.enabled, cx))
.child(div().flex_none().child(name))
@@ -691,7 +745,7 @@ impl Workbench {
"debug-breakpoint"
};
rows.push(
- self.debug_row(format!("instruction/{id}"), 0, None)
+ self.debug_row(format!("instruction/{id}"), 0, None, self.row_selected(&format!("instruction/{id}")), list_focused, cx)
.child(self.breakpoint_icon(icon, 16.))
.child(self.debug_checkbox(&id, breakpoint.base.enabled, cx))
.child(div().child(format!("0x{:x}", breakpoint.address)))
@@ -701,14 +755,15 @@ impl Workbench {
rows
}
- fn loaded_script_rows(&self) -> Vec<gpui::AnyElement> {
+ fn loaded_script_rows(&self, list_focused: bool, cx: &mut Context<Self>) -> Vec<gpui::AnyElement> {
let Some(session) = self.debug.focused_session() else { return Vec::new() };
session
.loaded_sources
.iter()
.map(|source| {
let name = source["name"].as_str().or(source["path"].as_str()).unwrap_or_default().to_owned();
- self.debug_row(format!("source/{name}"), 0, None).child(name).into_any_element()
+ let key = format!("source/{name}");
+ self.debug_row(key.clone(), 0, None, self.row_selected(&key), list_focused, cx).child(name).into_any_element()
})
.collect()
}
@@ -761,10 +816,10 @@ impl Workbench {
/// The inline input of the Watch and Breakpoints views: Enter accepts, Escape cancels, as the trees'
/// `renderInputBox` does.
- fn debug_input_row(&self, key: String, window: &Window, cx: &mut Context<Self>) -> gpui::AnyElement {
+ fn debug_input_row(&self, key: String, list_focused: bool, window: &Window, cx: &mut Context<Self>) -> gpui::AnyElement {
let focused = self.debug_view.input_focus.is_focused(window);
let border = self.color("focusBorder");
- self.debug_row(key, 0, None)
+ self.debug_row(key, 0, None, false, list_focused, cx)
.child(
div()
.flex_1()
@@ -951,6 +1006,38 @@ mod tests {
assert!(hint_after(1, cx));
}
+ /// listWidget.ts `MouseController.onContextMenu`: a right-click moves the list focus to the row and focuses the
+ /// tree, which outlines the row with `list.focusOutline`.
+ #[gpui::test]
+ fn a_right_clicked_call_stack_row_takes_the_list_focus(cx: &mut TestAppContext) {
+ let app_root = Path::new(env!("VSCODE_SRC")).to_path_buf();
+ let themes = exthost::scan::scan_extension(&app_root.join("extensions/theme-defaults"), true).unwrap();
+ let theme = load_theme(&[themes], "Dark Modern").unwrap();
+ let (workbench, cx) = cx.add_window_view(|_, cx| {
+ let mut workbench = Workbench::new(theme, app_root.clone(), None, Languages::new(&[]), crate::default_settings(), HostSync::new(std::sync::mpsc::channel().0), cx);
+ let mut session = crate::debug::session::Session::new("s".into(), 1, json!({ "name": "Launch", "type": "node", "request": "launch" }), json!({}), None, json!({}));
+ session.set_threads(&[json!({ "id": 1, "name": "main" })]);
+ let thread = session.thread_mut(1).unwrap();
+ thread.stopped = true;
+ let frame = |id: i64, name: &str| StackFrame { id, name: name.into(), source: json!({ "path": "/app.js" }), line: 5, column: 2, ..Default::default() };
+ thread.frames = vec![frame(1, "main"), frame(2, "<anonymous>")];
+ workbench.debug.sessions.push(session);
+ workbench.debug.focus = super::super::debug_service::DebugFocus { session: Some("s".into()), thread: Some(1), frame: Some(1) };
+ workbench.show_debug_view(cx);
+ workbench
+ });
+ cx.update(|window, cx| drop(window.draw(cx)));
+ assert!(cx.debug_bounds("list-focus-outline").is_none());
+ let row = cx.debug_bounds("frame/s/2").expect("the second frame's row");
+ cx.simulate_mouse_down(row.center(), MouseButton::Right, gpui::Modifiers::none());
+ cx.simulate_mouse_up(row.center(), MouseButton::Right, gpui::Modifiers::none());
+ cx.update(|window, cx| drop(window.draw(cx)));
+ let returns_to_tree = workbench.read_with(cx, |workbench, _| workbench.context_menu.as_ref().and_then(|menu| menu.focus_to_return.clone()) == Some(workbench.debug_view.list_focus[CALL_STACK_VIEW].clone()));
+ assert!(returns_to_tree, "the frame menu returns the focus to the Call Stack tree");
+ let outline = cx.debug_bounds("list-focus-outline").expect("the focused row's outline");
+ assert_eq!(outline, row);
+ }
+
/// callStackView.ts `ShowMoreRenderer`.
#[test]
fn folded_frames_name_their_common_origin() {