Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Add starts_open setting to terminal panel (#54373)
Jake Nelson08827f9208b4
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex bbd1a33a0de..a03ad887424 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -1868,6 +1868,10 @@"shell": "system",// Where to dock terminals panel. Can be `left`, `right`, `bottom`."dock": "bottom",+ // Whether the terminal panel should open on startup.+ //+ // Default: false+ "starts_open": false,// Whether the terminal panel should use flexible (proportional) sizing.//// Default: truediff --git a/crates/settings/src/vscode_import.rs b/crates/settings/src/vscode_import.rsindex 652748eda09..a872bd462c0 100644--- a/crates/settings/src/vscode_import.rs+++ b/crates/settings/src/vscode_import.rs@@ -908,6 +908,7 @@ impl VsCodeSettings {default_height: None,default_width: None,dock: None,+ starts_open: None,font_fallbacks,font_family,font_features: None,diff --git a/crates/settings_content/src/terminal.rs b/crates/settings_content/src/terminal.rsindex e66795a193f..338cee6d24c 100644--- a/crates/settings_content/src/terminal.rs+++ b/crates/settings_content/src/terminal.rs@@ -137,6 +137,10 @@ pub struct TerminalSettingsContent {/// Default: truepub button: Option<bool>,pub dock: Option<TerminalDockPosition>,+ /// Whether the terminal panel should open on startup.+ ///+ /// Default: false+ pub starts_open: Option<bool>,/// Whether the terminal panel should use flexible (proportional) sizing.////// Default: truediff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rsindex a1b905fe18b..8f1b54ca207 100644--- a/crates/settings_ui/src/page_data.rs+++ b/crates/settings_ui/src/page_data.rs@@ -5679,7 +5679,7 @@ fn panels_page() -> SettingsPage {]}- fn terminal_panel_section() -> [SettingsPageItem; 4] {+ fn terminal_panel_section() -> [SettingsPageItem; 5] {[SettingsPageItem::SectionHeader("Terminal Panel"),SettingsPageItem::SettingItem(SettingItem {@@ -5696,6 +5696,25 @@ fn panels_page() -> SettingsPage {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Starts Open",+ description: "Whether the terminal panel should open on startup.",+ field: Box::new(SettingField {+ organization_override: None,+ json_path: Some("terminal.starts_open"),+ pick: |settings_content| {+ settings_content.terminal.as_ref()?.starts_open.as_ref()+ },+ write: |settings_content, value, _| {+ settings_content+ .terminal+ .get_or_insert_default()+ .starts_open = value;+ },+ }),+ metadata: None,+ files: USER,+ }),SettingsPageItem::SettingItem(SettingItem {title: "Terminal Panel Flexible Sizing",description: "Whether the terminal panel should use flexible (proportional) sizing when docked to the left or right.",@@ -5955,7 +5974,7 @@ fn panels_page() -> SettingsPage {]}- fn git_panel_section() -> [SettingsPageItem; 17] {+ fn git_panel_section() -> [SettingsPageItem; 18] {[SettingsPageItem::SectionHeader("Git Panel"),SettingsPageItem::SettingItem(SettingItem {@@ -5986,6 +6005,25 @@ fn panels_page() -> SettingsPage {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Starts Open",+ description: "Whether the git panel should open on startup.",+ field: Box::new(SettingField {+ organization_override: None,+ json_path: Some("git_panel.starts_open"),+ pick: |settings_content| {+ settings_content.git_panel.as_ref()?.starts_open.as_ref()+ },+ write: |settings_content, value, _| {+ settings_content+ .git_panel+ .get_or_insert_default()+ .starts_open = value;+ },+ }),+ metadata: None,+ files: USER,+ }),SettingsPageItem::SettingItem(SettingItem {title: "Git Panel Default Width",description: "Default width of the Git panel in pixels.",diff --git a/crates/terminal/src/terminal_settings.rs b/crates/terminal/src/terminal_settings.rsindex 64d76b7de3f..698f60f68f2 100644--- a/crates/terminal/src/terminal_settings.rs+++ b/crates/terminal/src/terminal_settings.rs@@ -38,6 +38,7 @@ pub struct TerminalSettings {pub open_links_in_mouse_mode: bool,pub button: bool,pub dock: TerminalDockPosition,+ pub starts_open: bool,pub flexible: bool,pub default_width: Pixels,pub default_height: Pixels,@@ -109,6 +110,7 @@ impl settings::Settings for TerminalSettings {open_links_in_mouse_mode: user_content.open_links_in_mouse_mode.unwrap(),button: user_content.button.unwrap(),dock: user_content.dock.unwrap(),+ starts_open: user_content.starts_open.unwrap(),default_width: px(user_content.default_width.unwrap()),default_height: px(user_content.default_height.unwrap()),flexible: user_content.flexible.unwrap(),diff --git a/crates/terminal_view/src/terminal_panel.rs b/crates/terminal_view/src/terminal_panel.rsindex be9bda6f792..f24561992e4 100644--- a/crates/terminal_view/src/terminal_panel.rs+++ b/crates/terminal_view/src/terminal_panel.rs@@ -1554,6 +1554,10 @@ impl Panel for TerminalPanel {true}+ fn starts_open(&self, _: &Window, cx: &App) -> bool {+ TerminalSettings::get_global(cx).starts_open+ }+fn set_position(&mut self,position: DockPosition,@@ -2112,6 +2116,42 @@ mod tests {(window_handle, terminal_panel)}+ #[gpui::test]+ async fn test_terminal_panel_starts_open_follows_setting(cx: &mut TestAppContext) {+ cx.executor().allow_parking();+ init_test(cx);++ let (window_handle, terminal_panel) = init_workspace_with_panel(cx).await;++ window_handle+ .update(cx, |_, window, cx| {+ terminal_panel.update(cx, |terminal_panel, cx| {+ assert!(+ !terminal_panel.starts_open(window, cx),+ "terminal panel should not start open by default"+ );+ });+ })+ .expect("Failed to read terminal panel starts_open default");++ cx.update_global(|store: &mut SettingsStore, cx| {+ store.update_user_settings(cx, |settings| {+ settings.terminal.get_or_insert_default().starts_open = Some(true);+ });+ });++ window_handle+ .update(cx, |_, window, cx| {+ terminal_panel.update(cx, |terminal_panel, cx| {+ assert!(+ terminal_panel.starts_open(window, cx),+ "terminal panel should start open when configured"+ );+ });+ })+ .expect("Failed to read configured terminal panel starts_open");+ }+#[gpui::test]async fn test_new_terminal_opens_in_panel_by_default(cx: &mut TestAppContext) {cx.executor().allow_parking();diff --git a/docs/src/reference/all-settings.md b/docs/src/reference/all-settings.mdindex b0bf79dbe20..694a518045a 100644--- a/docs/src/reference/all-settings.md+++ b/docs/src/reference/all-settings.md@@ -4270,6 +4270,7 @@ List of `integer` column numbers"keep_selection_on_copy": true,"open_links_in_mouse_mode": true,"dock": "bottom",+ "starts_open": false,"default_width": 640,"default_height": 320,"detect_venv": {@@ -4309,6 +4310,24 @@ List of `integer` column numbers`"bottom"`, `"left"` or `"right"`+### Terminal: Starts Open++- Description: Whether the terminal panel should open on startup.+- Setting: `starts_open`+- Default: `false`++**Options**++`boolean` values++```json [settings]+{+ "terminal": {+ "starts_open": true+ }+}+```+### Terminal: Alternate Scroll- Description: Set whether Alternate Scroll mode (DECSET code: `?1007`) is active by default. Alternate Scroll mode converts mouse scroll events into up / down key presses when in the alternate screen (e.g. when running applications like vim or less). The terminal can still set and unset this mode with ANSI escape codes.