debugger: Enable setting debug panel dock position to the side (#29914)

### Preview
<img width="301" alt="Screenshot 2025-05-05 at 11 08 43 PM"
src="https://github.com/user-attachments/assets/aa445117-1c1c-4d90-a3bb-049f8417eca4"
/>


Setups the ground work to write debug panel persistence tests and allows
users to change the dock position of the debug panel.


Release Notes:

- N/A
This commit is contained in:
Anthony Eid 2025-05-05 17:27:20 -04:00 committed by GitHub
parent 6e28400e17
commit 1aa92d9928
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 590 additions and 302 deletions

View file

@ -7,7 +7,7 @@ pub mod variable_list;
use std::{any::Any, ops::ControlFlow, path::PathBuf, sync::Arc, time::Duration};
use crate::persistence::{self, DebuggerPaneItem, SerializedPaneLayout};
use crate::persistence::{self, DebuggerPaneItem, SerializedLayout};
use super::DebugPanelItemEvent;
use anyhow::{Result, anyhow};
@ -22,7 +22,7 @@ use dap::{
};
use futures::{SinkExt, channel::mpsc};
use gpui::{
Action as _, AnyView, AppContext, Entity, EntityId, EventEmitter, FocusHandle, Focusable,
Action as _, AnyView, AppContext, Axis, Entity, EntityId, EventEmitter, FocusHandle, Focusable,
NoAction, Pixels, Point, Subscription, Task, WeakEntity,
};
use language::Buffer;
@ -73,6 +73,7 @@ pub struct RunningState {
panes: PaneGroup,
active_pane: Option<Entity<Pane>>,
pane_close_subscriptions: HashMap<EntityId, Subscription>,
dock_axis: Axis,
_schedule_serialize: Option<Task<()>>,
}
@ -510,7 +511,8 @@ impl RunningState {
session: Entity<Session>,
project: Entity<Project>,
workspace: WeakEntity<Workspace>,
serialized_pane_layout: Option<SerializedPaneLayout>,
serialized_pane_layout: Option<SerializedLayout>,
dock_axis: Axis,
window: &mut Window,
cx: &mut Context<Self>,
) -> Self {
@ -589,7 +591,8 @@ impl RunningState {
let mut pane_close_subscriptions = HashMap::default();
let panes = if let Some(root) = serialized_pane_layout.and_then(|serialized_layout| {
persistence::deserialize_pane_layout(
serialized_layout,
serialized_layout.panes,
dock_axis != serialized_layout.dock_axis,
&workspace,
&project,
&stack_frame_list,
@ -617,6 +620,7 @@ impl RunningState {
&loaded_source_list,
&console,
&breakpoint_list,
dock_axis,
&mut pane_close_subscriptions,
window,
cx,
@ -643,6 +647,7 @@ impl RunningState {
loaded_sources_list: loaded_source_list,
pane_close_subscriptions,
debug_terminal,
dock_axis,
_schedule_serialize: None,
}
}
@ -1056,12 +1061,16 @@ impl RunningState {
.timer(Duration::from_millis(100))
.await;
let Some((adapter_name, pane_group)) = this
.update(cx, |this, cx| {
let Some((adapter_name, pane_layout)) = this
.read_with(cx, |this, cx| {
let adapter_name = this.session.read(cx).adapter();
(
adapter_name,
persistence::build_serialized_pane_layout(&this.panes.root, cx),
persistence::build_serialized_layout(
&this.panes.root,
this.dock_axis,
cx,
),
)
})
.ok()
@ -1069,7 +1078,7 @@ impl RunningState {
return;
};
persistence::serialize_pane_layout(adapter_name, pane_group)
persistence::serialize_pane_layout(adapter_name, pane_layout)
.await
.log_err();
@ -1195,6 +1204,11 @@ impl RunningState {
&self.variable_list
}
#[cfg(test)]
pub(crate) fn serialized_layout(&self, cx: &App) -> SerializedLayout {
persistence::build_serialized_layout(&self.panes.root, self.dock_axis, cx)
}
pub fn capabilities(&self, cx: &App) -> Capabilities {
self.session().read(cx).capabilities().clone()
}
@ -1408,6 +1422,7 @@ impl RunningState {
loaded_source_list: &Entity<LoadedSourceList>,
console: &Entity<Console>,
breakpoints: &Entity<BreakpointList>,
dock_axis: Axis,
subscriptions: &mut HashMap<EntityId, Subscription>,
window: &mut Window,
cx: &mut Context<'_, RunningState>,
@ -1528,7 +1543,7 @@ impl RunningState {
);
let group_root = workspace::PaneAxis::new(
gpui::Axis::Horizontal,
dock_axis.invert(),
[leftmost_pane, center_pane, rightmost_pane]
.into_iter()
.map(workspace::Member::Pane)
@ -1537,6 +1552,11 @@ impl RunningState {
Member::Axis(group_root)
}
pub(crate) fn invert_axies(&mut self) {
self.dock_axis = self.dock_axis.invert();
self.panes.invert_axies();
}
}
impl EventEmitter<DebugPanelItemEvent> for RunningState {}