diff --git a/assets/settings/default.json b/assets/settings/default.json index 561ca0c5663ee0a341abcc40bbd6e1d58a065fc8..8669623f46e9273f777163f377c24ce1a17a6abd 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1329,6 +1329,8 @@ }, // Status bar-related settings. "status_bar": { + // Whether to show the status bar. + "experimental.show": true, // Whether to show the active language button in the status bar. "active_language_button": true, // Whether to show the cursor position button in the status bar. diff --git a/crates/editor/src/editor_settings.rs b/crates/editor/src/editor_settings.rs index 373ccb46d200c55cfc17e627102894f6ddf619b5..3426171e03f70b18faa71584429a49ea009f73c4 100644 --- a/crates/editor/src/editor_settings.rs +++ b/crates/editor/src/editor_settings.rs @@ -25,7 +25,6 @@ pub struct EditorSettings { pub lsp_highlight_debounce: u64, pub hover_popover_enabled: bool, pub hover_popover_delay: u64, - pub status_bar: StatusBar, pub toolbar: Toolbar, pub scrollbar: Scrollbar, pub minimap: Minimap, @@ -67,18 +66,6 @@ pub struct Jupyter { pub enabled: bool, } -#[derive(Clone, Debug, PartialEq, Eq)] -pub struct StatusBar { - /// Whether to display the active language button in the status bar. - /// - /// Default: true - pub active_language_button: bool, - /// Whether to show the cursor position button in the status bar. - /// - /// Default: true - pub cursor_position_button: bool, -} - #[derive(Clone, Debug, PartialEq, Eq)] pub struct Toolbar { pub breadcrumbs: bool, @@ -195,7 +182,6 @@ impl Settings for EditorSettings { let minimap = editor.minimap.unwrap(); let gutter = editor.gutter.unwrap(); let axes = scrollbar.axes.unwrap(); - let status_bar = editor.status_bar.unwrap(); let toolbar = editor.toolbar.unwrap(); let search = editor.search.unwrap(); let drag_and_drop_selection = editor.drag_and_drop_selection.unwrap(); @@ -208,10 +194,6 @@ impl Settings for EditorSettings { lsp_highlight_debounce: editor.lsp_highlight_debounce.unwrap(), hover_popover_enabled: editor.hover_popover_enabled.unwrap(), hover_popover_delay: editor.hover_popover_delay.unwrap(), - status_bar: StatusBar { - active_language_button: status_bar.active_language_button.unwrap(), - cursor_position_button: status_bar.cursor_position_button.unwrap(), - }, toolbar: Toolbar { breadcrumbs: toolbar.breadcrumbs.unwrap(), quick_actions: toolbar.quick_actions.unwrap(), diff --git a/crates/go_to_line/src/cursor_position.rs b/crates/go_to_line/src/cursor_position.rs index 9387a5359ef3013574876602b4c67a44497c65cc..b722777262be078858959ae8fbd95528f8e0f986 100644 --- a/crates/go_to_line/src/cursor_position.rs +++ b/crates/go_to_line/src/cursor_position.rs @@ -1,4 +1,4 @@ -use editor::{Editor, EditorSettings, MultiBufferSnapshot}; +use editor::{Editor, MultiBufferSnapshot}; use gpui::{App, Entity, FocusHandle, Focusable, Subscription, Task, WeakEntity}; use settings::Settings; use std::{fmt::Write, num::NonZeroU32, time::Duration}; @@ -8,7 +8,7 @@ use ui::{ Render, Tooltip, Window, div, }; use util::paths::FILE_ROW_COLUMN_DELIMITER; -use workspace::{StatusItemView, Workspace, item::ItemHandle}; +use workspace::{StatusBarSettings, StatusItemView, Workspace, item::ItemHandle}; #[derive(Copy, Clone, Debug, Default, PartialOrd, PartialEq)] pub(crate) struct SelectionStats { @@ -205,10 +205,7 @@ impl CursorPosition { impl Render for CursorPosition { fn render(&mut self, _window: &mut Window, cx: &mut Context) -> impl IntoElement { - if !EditorSettings::get_global(cx) - .status_bar - .cursor_position_button - { + if !StatusBarSettings::get_global(cx).cursor_position_button { return div(); } diff --git a/crates/language_selector/src/active_buffer_language.rs b/crates/language_selector/src/active_buffer_language.rs index 56924c4cd2d54c64436a5ccaa7dabfe4c53ff0ec..38d010e33bc89012b0dc1a35d1638a6a443f9075 100644 --- a/crates/language_selector/src/active_buffer_language.rs +++ b/crates/language_selector/src/active_buffer_language.rs @@ -1,11 +1,11 @@ -use editor::{Editor, EditorSettings}; +use editor::Editor; use gpui::{ Context, Entity, IntoElement, ParentElement, Render, Subscription, WeakEntity, Window, div, }; use language::LanguageName; use settings::Settings as _; use ui::{Button, ButtonCommon, Clickable, FluentBuilder, LabelSize, Tooltip}; -use workspace::{StatusItemView, Workspace, item::ItemHandle}; +use workspace::{StatusBarSettings, StatusItemView, Workspace, item::ItemHandle}; use crate::{LanguageSelector, Toggle}; @@ -40,10 +40,7 @@ impl ActiveBufferLanguage { impl Render for ActiveBufferLanguage { fn render(&mut self, _: &mut Window, cx: &mut Context) -> impl IntoElement { - if !EditorSettings::get_global(cx) - .status_bar - .active_language_button - { + if !StatusBarSettings::get_global(cx).active_language_button { return div(); } diff --git a/crates/settings/src/settings_content.rs b/crates/settings/src/settings_content.rs index bc315553ca35b71f42bb8461bc6b92fb62a73818..cc273d14c6d7c6b8bc3bf85eb87013e87f88e7b3 100644 --- a/crates/settings/src/settings_content.rs +++ b/crates/settings/src/settings_content.rs @@ -60,6 +60,7 @@ pub struct SettingsContent { pub tabs: Option, pub tab_bar: Option, + pub status_bar: Option, pub preview_tabs: Option, diff --git a/crates/settings/src/settings_content/editor.rs b/crates/settings/src/settings_content/editor.rs index edfbc106538aed42d804f13954271f348ab16485..79a034e75ccbfbabf53f4edbe9bd923325c2fb3c 100644 --- a/crates/settings/src/settings_content/editor.rs +++ b/crates/settings/src/settings_content/editor.rs @@ -54,8 +54,6 @@ pub struct EditorSettingsContent { /// /// Default: 300 pub hover_popover_delay: Option, - /// Status bar related settings - pub status_bar: Option, /// Toolbar related settings pub toolbar: Option, /// Scrollbar related settings @@ -193,20 +191,6 @@ pub struct EditorSettingsContent { pub lsp_document_colors: Option, } -// Status bar related settings -#[skip_serializing_none] -#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)] -pub struct StatusBarContent { - /// Whether to display the active language button in the status bar. - /// - /// Default: true - pub active_language_button: Option, - /// Whether to show the cursor position button in the status bar. - /// - /// Default: true - pub cursor_position_button: Option, -} - // Toolbar related settings #[skip_serializing_none] #[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, PartialEq, Eq)] diff --git a/crates/settings/src/settings_content/workspace.rs b/crates/settings/src/settings_content/workspace.rs index 66b46c4c719ba82aa237cc9034e9c57bb1c4449d..15435f55ed1040b73b58b4ad2816b034c3acfbce 100644 --- a/crates/settings/src/settings_content/workspace.rs +++ b/crates/settings/src/settings_content/workspace.rs @@ -361,6 +361,24 @@ pub struct TabBarSettingsContent { pub show_tab_bar_buttons: Option, } +#[skip_serializing_none] +#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, MergeFrom, Debug, PartialEq, Eq)] +pub struct StatusBarSettingsContent { + /// Whether to show the status bar. + /// + /// Default: true + #[serde(rename = "experimental.show", default)] + pub show: Option, + /// Whether to display the active language button in the status bar. + /// + /// Default: true + pub active_language_button: Option, + /// Whether to show the cursor position button in the status bar. + /// + /// Default: true + pub cursor_position_button: Option, +} + #[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema, MergeFrom)] #[serde(rename_all = "snake_case")] pub enum AutosaveSetting { diff --git a/crates/settings_ui/src/settings_ui.rs b/crates/settings_ui/src/settings_ui.rs index 370ea20b9a0e67f4d67dd494df188ff2b74fa027..6b62adbf2b871832e8eacfdbe74f084e4e8c620b 100644 --- a/crates/settings_ui/src/settings_ui.rs +++ b/crates/settings_ui/src/settings_ui.rs @@ -1418,7 +1418,7 @@ fn user_settings_data() -> Vec { description: "Whether to show the active language button in the status bar", field: Box::new(SettingField { pick: |settings_content| { - if let Some(status_bar) = &settings_content.editor.status_bar { + if let Some(status_bar) = &settings_content.status_bar { &status_bar.active_language_button } else { &None @@ -1426,7 +1426,6 @@ fn user_settings_data() -> Vec { }, pick_mut: |settings_content| { &mut settings_content - .editor .status_bar .get_or_insert_default() .active_language_button @@ -1439,7 +1438,7 @@ fn user_settings_data() -> Vec { description: "Whether to show the cursor position button in the status bar", field: Box::new(SettingField { pick: |settings_content| { - if let Some(status_bar) = &settings_content.editor.status_bar { + if let Some(status_bar) = &settings_content.status_bar { &status_bar.cursor_position_button } else { &None @@ -1447,7 +1446,6 @@ fn user_settings_data() -> Vec { }, pick_mut: |settings_content| { &mut settings_content - .editor .status_bar .get_or_insert_default() .cursor_position_button diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 68edaec34ed511a636d357404c058fb8d1ebaf5d..188fb2fd0046d12aafc7426fd3b20951f8ca9307 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -112,7 +112,8 @@ use util::{ }; use uuid::Uuid; pub use workspace_settings::{ - AutosaveSetting, BottomDockLayout, RestoreOnStartupBehavior, TabBarSettings, WorkspaceSettings, + AutosaveSetting, BottomDockLayout, RestoreOnStartupBehavior, StatusBarSettings, TabBarSettings, + WorkspaceSettings, }; use zed_actions::{Spawn, feedback::FileBugReport}; @@ -506,6 +507,7 @@ pub fn init_settings(cx: &mut App) { ItemSettings::register(cx); PreviewTabsSettings::register(cx); TabBarSettings::register(cx); + StatusBarSettings::register(cx); } fn prompt_and_open_paths(app_state: Arc, options: PathPromptOptions, cx: &mut App) { @@ -1747,6 +1749,10 @@ impl Workspace { &self.status_bar } + pub fn status_bar_visible(&self, cx: &App) -> bool { + StatusBarSettings::get_global(cx).show + } + pub fn app_state(&self) -> &Arc { &self.app_state } @@ -6729,7 +6735,9 @@ impl Render for Workspace { })) .children(self.render_notifications(window, cx)), ) - .child(self.status_bar.clone()) + .when(self.status_bar_visible(cx), |parent| { + parent.child(self.status_bar.clone()) + }) .child(self.modal_layer.clone()) .child(self.toast_layer.clone()), ), @@ -10772,6 +10780,46 @@ mod tests { } } + #[gpui::test] + async fn test_status_bar_visibility(cx: &mut TestAppContext) { + init_test(cx); + + let fs = FakeFs::new(cx.executor()); + let project = Project::test(fs, [], cx).await; + let (workspace, _cx) = + cx.add_window_view(|window, cx| Workspace::test_new(project.clone(), window, cx)); + + // Test with status bar shown (default) + workspace.read_with(cx, |workspace, cx| { + let visible = workspace.status_bar_visible(cx); + assert!(visible, "Status bar should be visible by default"); + }); + + // Test with status bar hidden + cx.update_global(|store: &mut SettingsStore, cx| { + store.update_user_settings(cx, |settings| { + settings.status_bar.get_or_insert_default().show = Some(false); + }); + }); + + workspace.read_with(cx, |workspace, cx| { + let visible = workspace.status_bar_visible(cx); + assert!(!visible, "Status bar should be hidden when show is false"); + }); + + // Test with status bar shown explicitly + cx.update_global(|store: &mut SettingsStore, cx| { + store.update_user_settings(cx, |settings| { + settings.status_bar.get_or_insert_default().show = Some(true); + }); + }); + + workspace.read_with(cx, |workspace, cx| { + let visible = workspace.status_bar_visible(cx); + assert!(visible, "Status bar should be visible when show is true"); + }); + } + fn pane_items_paths(pane: &Entity, cx: &App) -> Vec { pane.read(cx) .items() diff --git a/crates/workspace/src/workspace_settings.rs b/crates/workspace/src/workspace_settings.rs index dfef0bd77ded79b4a1c3037f1506f64d4c0fe54c..963fd6de58c2a722c0592cb911dbabaf87dafa0f 100644 --- a/crates/workspace/src/workspace_settings.rs +++ b/crates/workspace/src/workspace_settings.rs @@ -222,3 +222,30 @@ impl Settings for TabBarSettings { } } } + +#[derive(Deserialize)] +pub struct StatusBarSettings { + pub show: bool, + pub active_language_button: bool, + pub cursor_position_button: bool, +} + +impl Settings for StatusBarSettings { + fn from_settings(content: &settings::SettingsContent, _cx: &mut App) -> Self { + let status_bar = content.status_bar.clone().unwrap(); + StatusBarSettings { + show: status_bar.show.unwrap(), + active_language_button: status_bar.active_language_button.unwrap(), + cursor_position_button: status_bar.cursor_position_button.unwrap(), + } + } + + fn import_from_vscode( + vscode: &settings::VsCodeSettings, + current: &mut settings::SettingsContent, + ) { + if let Some(show) = vscode.read_bool("workbench.statusBar.visible") { + current.status_bar.get_or_insert_default().show = Some(show); + } + } +} diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.md index 96f15a7fda6b5233ccdbf22766f15e67e6c2c207..130540e6344a75358c1ba553b63d009519fafe54 100644 --- a/docs/src/configuring-zed.md +++ b/docs/src/configuring-zed.md @@ -1502,6 +1502,14 @@ Positive `integer` value between 1 and 32. Values outside of this range will be }, ``` +There is an experimental setting that completely hides the status bar. This causes major usability problems (you will be unable to use many of Zed's features), but is provided for those who value screen real-estate above all else. + +```json +"status_bar": { + "experimental.show": false +} +``` + ## LSP - Description: Configuration for language servers.