Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

debugger: Allow configuring the default panel size (#66435)

Piotr Osiewicz00b86477f8b8
diff --git a/assets/settings/default.json b/assets/settings/default.json
index aec35d8bd8a..4687e9ac3e9 100644
--- a/assets/settings/default.json
+++ b/assets/settings/default.json
@@ -3002,6 +3002,8 @@
"save_breakpoints": true,
"timeout": 2000,
"dock": "bottom",
+ "default_width": 300,
+ "default_height": 300,
"log_dap_communications": true,
"format_dap_log_messages": true,
"button": true,
diff --git a/crates/dap/src/debugger_settings.rs b/crates/dap/src/debugger_settings.rs
index 8b2f1bf8d6c..f606306f652 100644
--- a/crates/dap/src/debugger_settings.rs
+++ b/crates/dap/src/debugger_settings.rs
@@ -1,5 +1,5 @@
use dap_types::SteppingGranularity;
-use settings::{RegisterSetting, Settings, SettingsContent};
+use settings::{IntoGpui, RegisterSetting, Settings, SettingsContent};
#[derive(Debug, RegisterSetting)]
pub struct DebuggerSettings {
@@ -31,6 +31,14 @@ pub struct DebuggerSettings {
///
/// Default: Bottom
pub dock: settings::DockPosition,
+ /// Default width of the debug panel in pixels when docked to the left or right.
+ ///
+ /// Default: 300
+ pub default_width: gpui::Pixels,
+ /// Default height of the debug panel in pixels when docked to the bottom.
+ ///
+ /// Default: 300
+ pub default_height: gpui::Pixels,
}
impl Settings for DebuggerSettings {
@@ -46,6 +54,8 @@ impl Settings for DebuggerSettings {
log_dap_communications: content.log_dap_communications.unwrap(),
format_dap_log_messages: content.format_dap_log_messages.unwrap(),
dock: content.dock.unwrap(),
+ default_width: content.default_width.unwrap().into_gpui(),
+ default_height: content.default_height.unwrap().into_gpui(),
}
}
}
diff --git a/crates/debugger_ui/src/debugger_panel.rs b/crates/debugger_ui/src/debugger_panel.rs
index e980e0a7cc0..5bd19082144 100644
--- a/crates/debugger_ui/src/debugger_panel.rs
+++ b/crates/debugger_ui/src/debugger_panel.rs
@@ -1547,8 +1547,12 @@ impl Panel for DebugPanel {
});
}
- fn default_size(&self, _window: &Window, _: &App) -> Pixels {
- px(300.)
+ fn default_size(&self, window: &Window, cx: &App) -> Pixels {
+ let settings = DebuggerSettings::get_global(cx);
+ match self.position(window, cx) {
+ DockPosition::Left | DockPosition::Right => settings.default_width,
+ DockPosition::Bottom => settings.default_height,
+ }
}
fn remote_id() -> Option<proto::PanelId> {
diff --git a/crates/debugger_ui/src/tests/debugger_panel.rs b/crates/debugger_ui/src/tests/debugger_panel.rs
index cd795e5a012..3b9c98c80f0 100644
--- a/crates/debugger_ui/src/tests/debugger_panel.rs
+++ b/crates/debugger_ui/src/tests/debugger_panel.rs
@@ -18,7 +18,7 @@ use editor::{
ActiveDebugLine, Editor, EditorMode, MultiBuffer,
actions::{self},
};
-use gpui::{AppContext, BackgroundExecutor, TestAppContext, VisualTestContext};
+use gpui::{AppContext, BackgroundExecutor, TestAppContext, UpdateGlobal, VisualTestContext, px};
use project::{
FakeFs, Project,
debugger::session::{ThreadId, ThreadStatus},
@@ -38,6 +38,39 @@ use workspace::item::SaveOptions;
use workspace::pane_group::SplitDirection;
use workspace::{Item, dock::Panel, move_active_item};
+#[gpui::test]
+async fn test_debug_panel_default_size(cx: &mut TestAppContext) {
+ init_test(cx);
+
+ let fs = FakeFs::new(cx.executor());
+ let project = Project::test(fs, [], cx).await;
+ let workspace = init_test_workspace(&project, cx).await;
+
+ workspace
+ .update(cx, |workspace, window, cx| {
+ let panel = workspace.panel::<DebugPanel>(cx).unwrap();
+ assert_eq!(panel.read(cx).default_size(window, cx), px(300.));
+
+ for (dock, expected_size) in [
+ (settings::DockPosition::Left, px(495.)),
+ (settings::DockPosition::Right, px(495.)),
+ (settings::DockPosition::Bottom, px(275.)),
+ ] {
+ settings::SettingsStore::update_global(cx, |store, cx| {
+ store.update_user_settings(cx, |settings| {
+ let debugger = settings.debugger.get_or_insert_default();
+ debugger.dock = Some(dock);
+ debugger.default_width = Some(495.0.into());
+ debugger.default_height = Some(275.0.into());
+ });
+ });
+
+ assert_eq!(panel.read(cx).default_size(window, cx), expected_size);
+ }
+ })
+ .unwrap();
+}
+
#[gpui::test]
async fn test_basic_show_debug_panel(executor: BackgroundExecutor, cx: &mut TestAppContext) {
init_test(cx);
diff --git a/crates/settings_content/src/settings_content.rs b/crates/settings_content/src/settings_content.rs
index c97679dfaee..65e018d9591 100644
--- a/crates/settings_content/src/settings_content.rs
+++ b/crates/settings_content/src/settings_content.rs
@@ -634,7 +634,7 @@ impl Default for TelemetrySettingsContent {
}
#[with_fallible_options]
-#[derive(Default, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema, Clone, MergeFrom)]
+#[derive(Default, Debug, PartialEq, Serialize, Deserialize, JsonSchema, Clone, MergeFrom)]
pub struct DebuggerSettingsContent {
/// Determines the stepping granularity.
///
@@ -664,6 +664,14 @@ pub struct DebuggerSettingsContent {
///
/// Default: Bottom
pub dock: Option<DockPosition>,
+ /// Default width of the debug panel in pixels when docked to the left or right.
+ ///
+ /// Default: 300
+ pub default_width: Option<PixelSetting>,
+ /// Default height of the debug panel in pixels when docked to the bottom.
+ ///
+ /// Default: 300
+ pub default_height: Option<PixelSetting>,
}
/// The granularity of one 'step' in the stepping requests `next`, `stepIn`, `stepOut`, and `stepBack`.
diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs
index f50548be2f1..3b9001d925e 100644
--- a/crates/settings_ui/src/page_data.rs
+++ b/crates/settings_ui/src/page_data.rs
@@ -6886,7 +6886,7 @@ fn panels_page() -> SettingsPage {
]
}
- fn debugger_panel_section() -> [SettingsPageItem; 2] {
+ fn debugger_panel_section() -> [SettingsPageItem; 4] {
[
SettingsPageItem::SectionHeader("Debugger Panel"),
SettingsPageItem::SettingItem(SettingItem {
@@ -6903,6 +6903,44 @@ fn panels_page() -> SettingsPage {
metadata: None,
files: USER,
}),
+ SettingsPageItem::SettingItem(SettingItem {
+ title: "Debugger Panel Default Width",
+ description: "Default width in pixels when the debug panel is docked to the left or right.",
+ field: Box::new(SettingField {
+ organization_override: None,
+ json_path: Some("debugger.default_width"),
+ pick: |settings_content| {
+ settings_content.debugger.as_ref()?.default_width.as_ref()
+ },
+ write: |settings_content, value, _| {
+ settings_content
+ .debugger
+ .get_or_insert_default()
+ .default_width = value;
+ },
+ }),
+ metadata: None,
+ files: USER,
+ }),
+ SettingsPageItem::SettingItem(SettingItem {
+ title: "Debugger Panel Default Height",
+ description: "Default height in pixels when the debug panel is docked to the bottom.",
+ field: Box::new(SettingField {
+ organization_override: None,
+ json_path: Some("debugger.default_height"),
+ pick: |settings_content| {
+ settings_content.debugger.as_ref()?.default_height.as_ref()
+ },
+ write: |settings_content, value, _| {
+ settings_content
+ .debugger
+ .get_or_insert_default()
+ .default_height = value;
+ },
+ }),
+ metadata: None,
+ files: USER,
+ }),
]
}
diff --git a/docs/src/debugger.md b/docs/src/debugger.md
index 4c7c21e5e38..f58b30f4aa1 100644
--- a/docs/src/debugger.md
+++ b/docs/src/debugger.md
@@ -173,9 +173,14 @@ This ensures the debugger doesn't disrupt your workflow when stepping through co
## Settings
+In the Settings Editor, open **Panels → Debugger Panel** to configure the panel's
+dock position, default width, and default height.
+
The settings for the debugger are grouped under the `debugger` key in `settings.json`:
- `dock`: Determines the position of the debug panel in the UI.
+- `default_width`: Default width in pixels when docked to the left or right (default: `300`).
+- `default_height`: Default height in pixels when docked to the bottom (default: `300`).
- `stepping_granularity`: Determines the stepping granularity.
- `save_breakpoints`: Whether the breakpoints should be reused across Zed sessions.
- `button`: Whether to show the debug button in the status bar.