debugger: Configure default pane layout conditionally based on capabilities (#28991)
This fixes a debug panic that happened when closing a debug session item through the debug panel context menu. The default layout now only includes module list and loaded sources list if they're supported. Release Notes: - N/A
This commit is contained in:
parent
1aa1b2bede
commit
8660101b83
1 changed files with 61 additions and 15 deletions
|
@ -447,12 +447,35 @@ impl RunningState {
|
||||||
workspace::PaneGroup::with_root(root)
|
workspace::PaneGroup::with_root(root)
|
||||||
} else {
|
} else {
|
||||||
pane_close_subscriptions.clear();
|
pane_close_subscriptions.clear();
|
||||||
|
let module_list = if session
|
||||||
|
.read(cx)
|
||||||
|
.capabilities()
|
||||||
|
.supports_modules_request
|
||||||
|
.unwrap_or(false)
|
||||||
|
{
|
||||||
|
Some(&module_list)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
|
let loaded_source_list = if session
|
||||||
|
.read(cx)
|
||||||
|
.capabilities()
|
||||||
|
.supports_loaded_sources_request
|
||||||
|
.unwrap_or(false)
|
||||||
|
{
|
||||||
|
Some(&loaded_source_list)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
};
|
||||||
|
|
||||||
let root = Self::default_pane_layout(
|
let root = Self::default_pane_layout(
|
||||||
project,
|
project,
|
||||||
&workspace,
|
&workspace,
|
||||||
&stack_frame_list,
|
&stack_frame_list,
|
||||||
&variable_list,
|
&variable_list,
|
||||||
&module_list,
|
module_list,
|
||||||
|
loaded_source_list,
|
||||||
&console,
|
&console,
|
||||||
&breakpoint_list,
|
&breakpoint_list,
|
||||||
&mut pane_close_subscriptions,
|
&mut pane_close_subscriptions,
|
||||||
|
@ -923,7 +946,8 @@ impl RunningState {
|
||||||
workspace: &WeakEntity<Workspace>,
|
workspace: &WeakEntity<Workspace>,
|
||||||
stack_frame_list: &Entity<StackFrameList>,
|
stack_frame_list: &Entity<StackFrameList>,
|
||||||
variable_list: &Entity<VariableList>,
|
variable_list: &Entity<VariableList>,
|
||||||
module_list: &Entity<ModuleList>,
|
module_list: Option<&Entity<ModuleList>>,
|
||||||
|
loaded_source_list: Option<&Entity<LoadedSourceList>>,
|
||||||
console: &Entity<Console>,
|
console: &Entity<Console>,
|
||||||
breakpoints: &Entity<BreakpointList>,
|
breakpoints: &Entity<BreakpointList>,
|
||||||
subscriptions: &mut HashMap<EntityId, Subscription>,
|
subscriptions: &mut HashMap<EntityId, Subscription>,
|
||||||
|
@ -963,6 +987,7 @@ impl RunningState {
|
||||||
this.activate_item(0, false, false, window, cx);
|
this.activate_item(0, false, false, window, cx);
|
||||||
});
|
});
|
||||||
let center_pane = new_debugger_pane(workspace.clone(), project.clone(), window, cx);
|
let center_pane = new_debugger_pane(workspace.clone(), project.clone(), window, cx);
|
||||||
|
|
||||||
center_pane.update(cx, |this, cx| {
|
center_pane.update(cx, |this, cx| {
|
||||||
this.add_item(
|
this.add_item(
|
||||||
Box::new(SubView::new(
|
Box::new(SubView::new(
|
||||||
|
@ -978,22 +1003,43 @@ impl RunningState {
|
||||||
window,
|
window,
|
||||||
cx,
|
cx,
|
||||||
);
|
);
|
||||||
this.add_item(
|
if let Some(module_list) = module_list {
|
||||||
Box::new(SubView::new(
|
this.add_item(
|
||||||
this.focus_handle(cx),
|
Box::new(SubView::new(
|
||||||
module_list.clone().into(),
|
module_list.focus_handle(cx),
|
||||||
DebuggerPaneItem::Modules,
|
module_list.clone().into(),
|
||||||
|
DebuggerPaneItem::Modules,
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
)),
|
||||||
|
false,
|
||||||
|
false,
|
||||||
None,
|
None,
|
||||||
|
window,
|
||||||
cx,
|
cx,
|
||||||
)),
|
);
|
||||||
false,
|
this.activate_item(0, false, false, window, cx);
|
||||||
false,
|
}
|
||||||
None,
|
|
||||||
window,
|
if let Some(loaded_source_list) = loaded_source_list {
|
||||||
cx,
|
this.add_item(
|
||||||
);
|
Box::new(SubView::new(
|
||||||
this.activate_item(0, false, false, window, cx);
|
loaded_source_list.focus_handle(cx),
|
||||||
|
loaded_source_list.clone().into(),
|
||||||
|
DebuggerPaneItem::LoadedSources,
|
||||||
|
None,
|
||||||
|
cx,
|
||||||
|
)),
|
||||||
|
false,
|
||||||
|
false,
|
||||||
|
None,
|
||||||
|
window,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
this.activate_item(1, false, false, window, cx);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
let rightmost_pane = new_debugger_pane(workspace.clone(), project.clone(), window, cx);
|
let rightmost_pane = new_debugger_pane(workspace.clone(), project.clone(), window, cx);
|
||||||
rightmost_pane.update(cx, |this, cx| {
|
rightmost_pane.update(cx, |this, cx| {
|
||||||
let weak_console = console.downgrade();
|
let weak_console = console.downgrade();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue