workspace pt 1

Conrad Irwin created

Change summary

crates/markdown/examples/markdown.rs              |   5 
crates/markdown/examples/markdown_as_child.rs     |   5 
crates/project/src/direnv.rs                      |   2 
crates/settings/src/settings_content.rs           |   9 
crates/settings/src/settings_content/workspace.rs | 305 +++++++++++++++++
crates/workspace/src/item.rs                      | 213 +++++------
crates/workspace/src/workspace.rs                 |   4 
crates/workspace/src/workspace_settings.rs        | 225 ------------
8 files changed, 410 insertions(+), 358 deletions(-)

Detailed changes

crates/markdown/examples/markdown.rs πŸ”—

@@ -1,6 +1,6 @@
 use assets::Assets;
 use gpui::{Application, Entity, KeyBinding, StyleRefinement, WindowOptions, prelude::*, rgb};
-use language::{LanguageRegistry, language_settings::AllLanguageSettings};
+use language::LanguageRegistry;
 use markdown::{Markdown, MarkdownElement, MarkdownStyle};
 use node_runtime::NodeRuntime;
 use settings::SettingsStore;
@@ -39,9 +39,6 @@ pub fn main() {
         let store = SettingsStore::test(cx);
         cx.set_global(store);
         language::init(cx);
-        SettingsStore::update(cx, |store, cx| {
-            store.update_user_settings::<AllLanguageSettings>(cx, |_| {});
-        });
         cx.bind_keys([KeyBinding::new("cmd-c", markdown::Copy, None)]);
 
         let node_runtime = NodeRuntime::unavailable();

crates/markdown/examples/markdown_as_child.rs πŸ”—

@@ -1,6 +1,6 @@
 use assets::Assets;
 use gpui::{Application, Entity, KeyBinding, Length, StyleRefinement, WindowOptions, rgb};
-use language::{LanguageRegistry, language_settings::AllLanguageSettings};
+use language::LanguageRegistry;
 use markdown::{Markdown, MarkdownElement, MarkdownStyle};
 use node_runtime::NodeRuntime;
 use settings::SettingsStore;
@@ -23,9 +23,6 @@ pub fn main() {
         let store = SettingsStore::test(cx);
         cx.set_global(store);
         language::init(cx);
-        SettingsStore::update(cx, |store, cx| {
-            store.update_user_settings::<AllLanguageSettings>(cx, |_| {});
-        });
         cx.bind_keys([KeyBinding::new("cmd-c", markdown::Copy, None)]);
 
         let node_runtime = NodeRuntime::unavailable();

crates/project/src/direnv.rs πŸ”—

@@ -65,7 +65,7 @@ pub async fn load_direnv_environment(
     let output = String::from_utf8_lossy(&direnv_output.stdout);
     if output.is_empty() {
         // direnv outputs nothing when it has no changes to apply to environment variables
-        return Ok(HashMap::new());
+        return Ok(HashMap::default());
     }
 
     match serde_json::from_str(&output) {

crates/settings/src/settings_content.rs πŸ”—

@@ -3,11 +3,13 @@ mod language;
 mod project;
 mod terminal;
 mod theme;
+mod workspace;
 pub use agent::*;
 pub use language::*;
 pub use project::*;
 pub use terminal::*;
 pub use theme::*;
+pub use workspace::*;
 
 use collections::HashMap;
 use gpui::{App, SharedString};
@@ -31,6 +33,13 @@ pub struct SettingsContent {
     #[serde(flatten)]
     pub extension: ExtensionSettingsContent,
 
+    #[serde(flatten)]
+    pub workspace: WorkspaceSettingsContent,
+
+    pub tabs: Option<ItemSettingsContent>,
+
+    pub preview_tabs: Option<PreviewTabsSettingsContent>,
+
     pub agent: Option<AgentSettingsContent>,
     pub agent_servers: Option<AllAgentServersSettings>,
 

crates/settings/src/settings_content/workspace.rs πŸ”—

@@ -0,0 +1,305 @@
+use schemars::JsonSchema;
+use serde::{Deserialize, Serialize};
+
+#[derive(Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
+pub struct WorkspaceSettingsContent {
+    /// Active pane styling settings.
+    pub active_pane_modifiers: Option<ActivePanelModifiers>,
+    /// Layout mode for the bottom dock
+    ///
+    /// Default: contained
+    pub bottom_dock_layout: Option<BottomDockLayout>,
+    /// Direction to split horizontally.
+    ///
+    /// Default: "up"
+    pub pane_split_direction_horizontal: Option<PaneSplitDirectionHorizontal>,
+    /// Direction to split vertically.
+    ///
+    /// Default: "left"
+    pub pane_split_direction_vertical: Option<PaneSplitDirectionVertical>,
+    /// Centered layout related settings.
+    pub centered_layout: Option<CenteredLayoutSettings>,
+    /// Whether or not to prompt the user to confirm before closing the application.
+    ///
+    /// Default: false
+    pub confirm_quit: Option<bool>,
+    /// Whether or not to show the call status icon in the status bar.
+    ///
+    /// Default: true
+    pub show_call_status_icon: Option<bool>,
+    /// When to automatically save edited buffers.
+    ///
+    /// Default: off
+    pub autosave: Option<AutosaveSetting>,
+    /// Controls previous session restoration in freshly launched Zed instance.
+    /// Values: none, last_workspace, last_session
+    /// Default: last_session
+    pub restore_on_startup: Option<RestoreOnStartupBehavior>,
+    /// Whether to attempt to restore previous file's state when opening it again.
+    /// The state is stored per pane.
+    /// When disabled, defaults are applied instead of the state restoration.
+    ///
+    /// E.g. for editors, selections, folds and scroll positions are restored, if the same file is closed and, later, opened again in the same pane.
+    /// When disabled, a single selection in the very beginning of the file, zero scroll position and no folds state is used as a default.
+    ///
+    /// Default: true
+    pub restore_on_file_reopen: Option<bool>,
+    /// The size of the workspace split drop targets on the outer edges.
+    /// Given as a fraction that will be multiplied by the smaller dimension of the workspace.
+    ///
+    /// Default: `0.2` (20% of the smaller dimension of the workspace)
+    pub drop_target_size: Option<f32>,
+    /// Whether to close the window when using 'close active item' on a workspace with no tabs
+    ///
+    /// Default: auto ("on" on macOS, "off" otherwise)
+    pub when_closing_with_no_tabs: Option<CloseWindowWhenNoItems>,
+    /// Whether to use the system provided dialogs for Open and Save As.
+    /// When set to false, Zed will use the built-in keyboard-first pickers.
+    ///
+    /// Default: true
+    pub use_system_path_prompts: Option<bool>,
+    /// Whether to use the system provided prompts.
+    /// When set to false, Zed will use the built-in prompts.
+    /// Note that this setting has no effect on Linux, where Zed will always
+    /// use the built-in prompts.
+    ///
+    /// Default: true
+    pub use_system_prompts: Option<bool>,
+    /// Aliases for the command palette. When you type a key in this map,
+    /// it will be assumed to equal the value.
+    ///
+    /// Default: true
+    pub command_aliases: Option<HashMap<String, String>>,
+    /// Maximum open tabs in a pane. Will not close an unsaved
+    /// tab. Set to `None` for unlimited tabs.
+    ///
+    /// Default: none
+    pub max_tabs: Option<NonZeroUsize>,
+    /// What to do when the last window is closed
+    ///
+    /// Default: auto (nothing on macOS, "app quit" otherwise)
+    pub on_last_window_closed: Option<OnLastWindowClosed>,
+    /// Whether to resize all the panels in a dock when resizing the dock.
+    ///
+    /// Default: ["left"]
+    pub resize_all_panels_in_dock: Option<Vec<DockPosition>>,
+    /// Whether to automatically close files that have been deleted on disk.
+    ///
+    /// Default: false
+    pub close_on_file_delete: Option<bool>,
+    /// Whether to allow windows to tab together based on the user’s tabbing preference (macOS only).
+    ///
+    /// Default: false
+    pub use_system_window_tabs: Option<bool>,
+    /// Whether to show padding for zoomed panels.
+    /// When enabled, zoomed bottom panels will have some top padding,
+    /// while zoomed left/right panels will have padding to the right/left (respectively).
+    ///
+    /// Default: true
+    pub zoomed_padding: Option<bool>,
+}
+
+#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
+pub struct ItemSettingsContent {
+    /// Whether to show the Git file status on a tab item.
+    ///
+    /// Default: false
+    pub git_status: Option<bool>,
+    /// Position of the close button in a tab.
+    ///
+    /// Default: right
+    pub close_position: Option<ClosePosition>,
+    /// Whether to show the file icon for a tab.
+    ///
+    /// Default: false
+    pub file_icons: Option<bool>,
+    /// What to do after closing the current tab.
+    ///
+    /// Default: history
+    pub activate_on_close: Option<ActivateOnClose>,
+    /// Which files containing diagnostic errors/warnings to mark in the tabs.
+    /// This setting can take the following three values:
+    ///
+    /// Default: off
+    pub show_diagnostics: Option<ShowDiagnostics>,
+    /// Whether to always show the close button on tabs.
+    ///
+    /// Default: false
+    pub show_close_button: Option<ShowCloseButton>,
+}
+
+#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize, JsonSchema)]
+pub struct PreviewTabsSettingsContent {
+    /// Whether to show opened editors as preview tabs.
+    /// Preview tabs do not stay open, are reused until explicitly set to be kept open opened (via double-click or editing) and show file names in italic.
+    ///
+    /// Default: true
+    pub enabled: Option<bool>,
+    /// Whether to open tabs in preview mode when selected from the file finder.
+    ///
+    /// Default: false
+    pub enable_preview_from_file_finder: Option<bool>,
+    /// Whether a preview tab gets replaced when code navigation is used to navigate away from the tab.
+    ///
+    /// Default: false
+    pub enable_preview_from_code_navigation: Option<bool>,
+}
+
+#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
+#[serde(rename_all = "lowercase")]
+pub enum ClosePosition {
+    Left,
+    #[default]
+    Right,
+}
+
+#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
+#[serde(rename_all = "lowercase")]
+pub enum ShowCloseButton {
+    Always,
+    #[default]
+    Hover,
+    Hidden,
+}
+
+#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
+#[serde(rename_all = "snake_case")]
+pub enum ShowDiagnostics {
+    #[default]
+    Off,
+    Errors,
+    All,
+}
+
+#[derive(Copy, Clone, Debug, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum ActivateOnClose {
+    #[default]
+    History,
+    Neighbour,
+    LeftNeighbour,
+}
+
+#[derive(Copy, Clone, PartialEq, Debug, Default, Serialize, Deserialize, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub struct ActivePanelModifiers {
+    /// Size of the border surrounding the active pane.
+    /// When set to 0, the active pane doesn't have any border.
+    /// The border is drawn inset.
+    ///
+    /// Default: `0.0`
+    pub border_size: Option<f32>,
+    /// Opacity of inactive panels.
+    /// When set to 1.0, the inactive panes have the same opacity as the active one.
+    /// If set to 0, the inactive panes content will not be visible at all.
+    /// Values are clamped to the [0.0, 1.0] range.
+    ///
+    /// Default: `1.0`
+    pub inactive_opacity: Option<f32>,
+}
+
+#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum BottomDockLayout {
+    /// Contained between the left and right docks
+    #[default]
+    Contained,
+    /// Takes up the full width of the window
+    Full,
+    /// Extends under the left dock while snapping to the right dock
+    LeftAligned,
+    /// Extends under the right dock while snapping to the left dock
+    RightAligned,
+}
+
+#[derive(Copy, Clone, PartialEq, Default, Serialize, Deserialize, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum CloseWindowWhenNoItems {
+    /// Match platform conventions by default, so "on" on macOS and "off" everywhere else
+    #[default]
+    PlatformDefault,
+    /// Close the window when there are no tabs
+    CloseWindow,
+    /// Leave the window open when there are no tabs
+    KeepWindowOpen,
+}
+
+impl CloseWindowWhenNoItems {
+    pub fn should_close(&self) -> bool {
+        match self {
+            CloseWindowWhenNoItems::PlatformDefault => cfg!(target_os = "macos"),
+            CloseWindowWhenNoItems::CloseWindow => true,
+            CloseWindowWhenNoItems::KeepWindowOpen => false,
+        }
+    }
+}
+
+#[derive(Copy, Clone, PartialEq, Eq, Default, Serialize, Deserialize, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum RestoreOnStartupBehavior {
+    /// Always start with an empty editor
+    None,
+    /// Restore the workspace that was closed last.
+    LastWorkspace,
+    /// Restore all workspaces that were open when quitting Zed.
+    #[default]
+    LastSession,
+}
+
+#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
+pub struct TabBarSettingsContent {
+    /// Whether or not to show the tab bar in the editor.
+    ///
+    /// Default: true
+    pub show: Option<bool>,
+    /// Whether or not to show the navigation history buttons in the tab bar.
+    ///
+    /// Default: true
+    pub show_nav_history_buttons: Option<bool>,
+    /// Whether or not to show the tab bar buttons.
+    ///
+    /// Default: true
+    pub show_tab_bar_buttons: Option<bool>,
+}
+
+#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum AutosaveSetting {
+    /// Disable autosave.
+    Off,
+    /// Save after inactivity period of `milliseconds`.
+    AfterDelay { milliseconds: u64 },
+    /// Autosave when focus changes.
+    OnFocusChange,
+    /// Autosave when the active window changes.
+    OnWindowChange,
+}
+
+#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum PaneSplitDirectionHorizontal {
+    Up,
+    Down,
+}
+
+#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
+#[serde(rename_all = "snake_case")]
+pub enum PaneSplitDirectionVertical {
+    Left,
+    Right,
+}
+
+#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, SettingsUi)]
+#[serde(rename_all = "snake_case")]
+pub struct CenteredLayoutSettings {
+    /// The relative width of the left padding of the central pane from the
+    /// workspace when the centered layout is used.
+    ///
+    /// Default: 0.2
+    pub left_padding: Option<f32>,
+    // The relative width of the right padding of the central pane from the
+    // workspace when the centered layout is used.
+    ///
+    /// Default: 0.2
+    pub right_padding: Option<f32>,
+}

crates/workspace/src/item.rs πŸ”—

@@ -15,9 +15,9 @@ use gpui::{
     Focusable, Font, HighlightStyle, Pixels, Point, Render, SharedString, Task, WeakEntity, Window,
 };
 use project::{Project, ProjectEntryId, ProjectPath};
-use schemars::JsonSchema;
-use serde::{Deserialize, Serialize};
-use settings::{Settings, SettingsKey, SettingsLocation, SettingsSources, SettingsUi};
+use settings::{
+    ActivateOnClose, ClosePosition, Settings, SettingsLocation, ShowCloseButton, ShowDiagnostics,
+};
 use smallvec::SmallVec;
 use std::{
     any::{Any, TypeId},
@@ -30,7 +30,7 @@ use std::{
 };
 use theme::Theme;
 use ui::{Color, Icon, IntoElement, Label, LabelCommon};
-use util::ResultExt;
+use util::{MergeFrom as _, ResultExt};
 
 pub const LEADER_UPDATE_THROTTLE: Duration = Duration::from_millis(200);
 
@@ -49,7 +49,6 @@ impl Default for SaveOptions {
     }
 }
 
-#[derive(Deserialize)]
 pub struct ItemSettings {
     pub git_status: bool,
     pub close_position: ClosePosition,
@@ -59,150 +58,120 @@ pub struct ItemSettings {
     pub show_close_button: ShowCloseButton,
 }
 
-#[derive(Deserialize)]
 pub struct PreviewTabsSettings {
     pub enabled: bool,
     pub enable_preview_from_file_finder: bool,
     pub enable_preview_from_code_navigation: bool,
 }
 
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "lowercase")]
-pub enum ClosePosition {
-    Left,
-    #[default]
-    Right,
-}
-
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "lowercase")]
-pub enum ShowCloseButton {
-    Always,
-    #[default]
-    Hover,
-    Hidden,
-}
-
-#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
-#[serde(rename_all = "snake_case")]
-pub enum ShowDiagnostics {
-    #[default]
-    Off,
-    Errors,
-    All,
-}
-
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum ActivateOnClose {
-    #[default]
-    History,
-    Neighbour,
-    LeftNeighbour,
-}
-
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, SettingsUi, SettingsKey)]
-#[settings_key(key = "tabs")]
-pub struct ItemSettingsContent {
-    /// Whether to show the Git file status on a tab item.
-    ///
-    /// Default: false
-    git_status: Option<bool>,
-    /// Position of the close button in a tab.
-    ///
-    /// Default: right
-    close_position: Option<ClosePosition>,
-    /// Whether to show the file icon for a tab.
-    ///
-    /// Default: false
-    file_icons: Option<bool>,
-    /// What to do after closing the current tab.
-    ///
-    /// Default: history
-    pub activate_on_close: Option<ActivateOnClose>,
-    /// Which files containing diagnostic errors/warnings to mark in the tabs.
-    /// This setting can take the following three values:
-    ///
-    /// Default: off
-    show_diagnostics: Option<ShowDiagnostics>,
-    /// Whether to always show the close button on tabs.
-    ///
-    /// Default: false
-    show_close_button: Option<ShowCloseButton>,
-}
-
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, SettingsUi, SettingsKey)]
-#[settings_key(key = "preview_tabs")]
-pub struct PreviewTabsSettingsContent {
-    /// Whether to show opened editors as preview tabs.
-    /// Preview tabs do not stay open, are reused until explicitly set to be kept open opened (via double-click or editing) and show file names in italic.
-    ///
-    /// Default: true
-    enabled: Option<bool>,
-    /// Whether to open tabs in preview mode when selected from the file finder.
-    ///
-    /// Default: false
-    enable_preview_from_file_finder: Option<bool>,
-    /// Whether a preview tab gets replaced when code navigation is used to navigate away from the tab.
-    ///
-    /// Default: false
-    enable_preview_from_code_navigation: Option<bool>,
-}
-
 impl Settings for ItemSettings {
-    type FileContent = ItemSettingsContent;
+    fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
+        let tabs = content.tabs.as_ref().unwrap();
+        Self {
+            git_status: tabs.git_status.unwrap(),
+            close_position: tabs.close_position.unwrap(),
+            activate_on_close: tabs.activate_on_close.unwrap(),
+            file_icons: tabs.file_icons.unwrap(),
+            show_diagnostics: tabs.show_diagnostics.unwrap(),
+            show_close_button: tabs.show_close_button.unwrap(),
+        }
+    }
 
-    fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> Result<Self> {
-        sources.json_merge()
+    fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
+        let Some(tabs) = content.tabs.as_ref() else {
+            return;
+        };
+        self.git_status.merge_from(&tabs.git_status);
+        self.close_position.merge_from(&tabs.close_position);
+        self.activate_on_close.merge_from(&tabs.activate_on_close);
+        self.file_icons.merge_from(&tabs.file_icons);
+        self.show_diagnostics.merge_from(&tabs.show_diagnostics);
+        self.show_close_button.merge_from(&tabs.show_close_button);
     }
 
-    fn import_from_vscode(vscode: &settings::VsCodeSettings, current: &mut Self::FileContent) {
+    fn import_from_vscode(
+        vscode: &settings::VsCodeSettings,
+        current: &mut settings::SettingsContent,
+    ) {
         if let Some(b) = vscode.read_bool("workbench.editor.tabActionCloseVisibility") {
-            current.show_close_button = Some(if b {
+            current.tabs.get_or_insert_default().show_close_button = Some(if b {
                 ShowCloseButton::Always
             } else {
                 ShowCloseButton::Hidden
             })
         }
-        vscode.enum_setting(
-            "workbench.editor.tabActionLocation",
-            &mut current.close_position,
-            |s| match s {
-                "right" => Some(ClosePosition::Right),
-                "left" => Some(ClosePosition::Left),
-                _ => None,
-            },
-        );
+        if let Some(s) = vscode.read_enum_setting("workbench.editor.tabActionLocation", |s| match s
+        {
+            "right" => Some(ClosePosition::Right),
+            "left" => Some(ClosePosition::Left),
+            _ => None,
+        }) {
+            current.tabs.get_or_insert_default().close_position = Some(s)
+        }
         if let Some(b) = vscode.read_bool("workbench.editor.focusRecentEditorAfterClose") {
-            current.activate_on_close = Some(if b {
+            current.tabs.get_or_insert_default().activate_on_close = Some(if b {
                 ActivateOnClose::History
             } else {
                 ActivateOnClose::LeftNeighbour
             })
         }
 
-        vscode.bool_setting("workbench.editor.showIcons", &mut current.file_icons);
-        vscode.bool_setting("git.decorations.enabled", &mut current.git_status);
+        if let Some(b) = vscode.read_bool("workbench.editor.showIcons") {
+            current.tabs.get_or_insert_default().file_icons = Some(b);
+        };
+        if let Some(b) = vscode.read_bool("git.decorations.enabled") {
+            current.tabs.get_or_insert_default().git_status = Some(b);
+        }
     }
 }
 
 impl Settings for PreviewTabsSettings {
-    type FileContent = PreviewTabsSettingsContent;
-
-    fn load(sources: SettingsSources<Self::FileContent>, _: &mut App) -> Result<Self> {
-        sources.json_merge()
-    }
-
-    fn import_from_vscode(vscode: &settings::VsCodeSettings, current: &mut Self::FileContent) {
-        vscode.bool_setting("workbench.editor.enablePreview", &mut current.enabled);
-        vscode.bool_setting(
-            "workbench.editor.enablePreviewFromCodeNavigation",
-            &mut current.enable_preview_from_code_navigation,
-        );
-        vscode.bool_setting(
-            "workbench.editor.enablePreviewFromQuickOpen",
-            &mut current.enable_preview_from_file_finder,
-        );
+    fn from_defaults(content: &settings::SettingsContent, _cx: &mut App) -> Self {
+        let preview_tabs = content.preview_tabs.as_ref().unwrap();
+        Self {
+            enabled: preview_tabs.enabled.unwrap(),
+            enable_preview_from_file_finder: preview_tabs.enable_preview_from_file_finder.unwrap(),
+            enable_preview_from_code_navigation: preview_tabs
+                .enable_preview_from_code_navigation
+                .unwrap(),
+        }
+    }
+
+    fn refine(&mut self, content: &settings::SettingsContent, _cx: &mut App) {
+        let Some(preview_tabs) = content.preview_tabs.as_ref() else {
+            return;
+        };
+
+        self.enabled.merge_from(&preview_tabs.enabled);
+        self.enable_preview_from_file_finder
+            .merge_from(&preview_tabs.enable_preview_from_file_finder);
+        self.enable_preview_from_code_navigation
+            .merge_from(&preview_tabs.enable_preview_from_code_navigation);
+    }
+
+    fn import_from_vscode(
+        vscode: &settings::VsCodeSettings,
+        current: &mut settings::SettingsContent,
+    ) {
+        if let Some(enabled) = vscode.read_bool("workbench.editor.enablePreview") {
+            current.preview_tabs.get_or_insert_default().enabled = Some(enabled);
+        }
+        if let Some(enable_preview_from_code_navigation) =
+            vscode.read_bool("workbench.editor.enablePreviewFromCodeNavigation")
+        {
+            current
+                .preview_tabs
+                .get_or_insert_default()
+                .enable_preview_from_code_navigation = Some(enable_preview_from_code_navigation)
+        }
+        if let Some(enable_preview_from_file_finder) =
+            vscode.read_bool("workbench.editor.enablePreviewFromQuickOpen")
+        {
+            current
+                .preview_tabs
+                .get_or_insert_default()
+                .enable_preview_from_file_finder = Some(enable_preview_from_file_finder)
+        }
     }
 }
 

crates/workspace/src/workspace.rs πŸ”—

@@ -9889,8 +9889,8 @@ mod tests {
 
         // Enable the close_on_file_delete setting
         cx.update_global(|store: &mut SettingsStore, cx| {
-            store.update_user_settings::<WorkspaceSettings>(cx, |settings| {
-                settings.close_on_file_delete = Some(true);
+            store.update_user_settings(cx, |settings| {
+                settings.tabs.get_or_insert_default().close_on_file_delete = Some(true);
             });
         });
 

crates/workspace/src/workspace_settings.rs πŸ”—

@@ -52,237 +52,12 @@ impl OnLastWindowClosed {
     }
 }
 
-#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub struct ActivePanelModifiers {
-    /// Size of the border surrounding the active pane.
-    /// When set to 0, the active pane doesn't have any border.
-    /// The border is drawn inset.
-    ///
-    /// Default: `0.0`
-    pub border_size: Option<f32>,
-    /// Opacity of inactive panels.
-    /// When set to 1.0, the inactive panes have the same opacity as the active one.
-    /// If set to 0, the inactive panes content will not be visible at all.
-    /// Values are clamped to the [0.0, 1.0] range.
-    ///
-    /// Default: `1.0`
-    pub inactive_opacity: Option<f32>,
-}
-
-#[derive(Copy, Clone, Debug, Default, Serialize, Deserialize, PartialEq, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum BottomDockLayout {
-    /// Contained between the left and right docks
-    #[default]
-    Contained,
-    /// Takes up the full width of the window
-    Full,
-    /// Extends under the left dock while snapping to the right dock
-    LeftAligned,
-    /// Extends under the right dock while snapping to the left dock
-    RightAligned,
-}
-
-#[derive(Copy, Clone, Default, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum CloseWindowWhenNoItems {
-    /// Match platform conventions by default, so "on" on macOS and "off" everywhere else
-    #[default]
-    PlatformDefault,
-    /// Close the window when there are no tabs
-    CloseWindow,
-    /// Leave the window open when there are no tabs
-    KeepWindowOpen,
-}
-
-impl CloseWindowWhenNoItems {
-    pub fn should_close(&self) -> bool {
-        match self {
-            CloseWindowWhenNoItems::PlatformDefault => cfg!(target_os = "macos"),
-            CloseWindowWhenNoItems::CloseWindow => true,
-            CloseWindowWhenNoItems::KeepWindowOpen => false,
-        }
-    }
-}
-
-#[derive(Copy, Clone, PartialEq, Eq, Default, Serialize, Deserialize, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum RestoreOnStartupBehavior {
-    /// Always start with an empty editor
-    None,
-    /// Restore the workspace that was closed last.
-    LastWorkspace,
-    /// Restore all workspaces that were open when quitting Zed.
-    #[default]
-    LastSession,
-}
-
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, SettingsUi, SettingsKey)]
-#[settings_key(None)]
-pub struct WorkspaceSettingsContent {
-    /// Active pane styling settings.
-    pub active_pane_modifiers: Option<ActivePanelModifiers>,
-    /// Layout mode for the bottom dock
-    ///
-    /// Default: contained
-    pub bottom_dock_layout: Option<BottomDockLayout>,
-    /// Direction to split horizontally.
-    ///
-    /// Default: "up"
-    pub pane_split_direction_horizontal: Option<PaneSplitDirectionHorizontal>,
-    /// Direction to split vertically.
-    ///
-    /// Default: "left"
-    pub pane_split_direction_vertical: Option<PaneSplitDirectionVertical>,
-    /// Centered layout related settings.
-    pub centered_layout: Option<CenteredLayoutSettings>,
-    /// Whether or not to prompt the user to confirm before closing the application.
-    ///
-    /// Default: false
-    pub confirm_quit: Option<bool>,
-    /// Whether or not to show the call status icon in the status bar.
-    ///
-    /// Default: true
-    pub show_call_status_icon: Option<bool>,
-    /// When to automatically save edited buffers.
-    ///
-    /// Default: off
-    pub autosave: Option<AutosaveSetting>,
-    /// Controls previous session restoration in freshly launched Zed instance.
-    /// Values: none, last_workspace, last_session
-    /// Default: last_session
-    pub restore_on_startup: Option<RestoreOnStartupBehavior>,
-    /// Whether to attempt to restore previous file's state when opening it again.
-    /// The state is stored per pane.
-    /// When disabled, defaults are applied instead of the state restoration.
-    ///
-    /// E.g. for editors, selections, folds and scroll positions are restored, if the same file is closed and, later, opened again in the same pane.
-    /// When disabled, a single selection in the very beginning of the file, zero scroll position and no folds state is used as a default.
-    ///
-    /// Default: true
-    pub restore_on_file_reopen: Option<bool>,
-    /// The size of the workspace split drop targets on the outer edges.
-    /// Given as a fraction that will be multiplied by the smaller dimension of the workspace.
-    ///
-    /// Default: `0.2` (20% of the smaller dimension of the workspace)
-    pub drop_target_size: Option<f32>,
-    /// Whether to close the window when using 'close active item' on a workspace with no tabs
-    ///
-    /// Default: auto ("on" on macOS, "off" otherwise)
-    pub when_closing_with_no_tabs: Option<CloseWindowWhenNoItems>,
-    /// Whether to use the system provided dialogs for Open and Save As.
-    /// When set to false, Zed will use the built-in keyboard-first pickers.
-    ///
-    /// Default: true
-    pub use_system_path_prompts: Option<bool>,
-    /// Whether to use the system provided prompts.
-    /// When set to false, Zed will use the built-in prompts.
-    /// Note that this setting has no effect on Linux, where Zed will always
-    /// use the built-in prompts.
-    ///
-    /// Default: true
-    pub use_system_prompts: Option<bool>,
-    /// Aliases for the command palette. When you type a key in this map,
-    /// it will be assumed to equal the value.
-    ///
-    /// Default: true
-    pub command_aliases: Option<HashMap<String, String>>,
-    /// Maximum open tabs in a pane. Will not close an unsaved
-    /// tab. Set to `None` for unlimited tabs.
-    ///
-    /// Default: none
-    pub max_tabs: Option<NonZeroUsize>,
-    /// What to do when the last window is closed
-    ///
-    /// Default: auto (nothing on macOS, "app quit" otherwise)
-    pub on_last_window_closed: Option<OnLastWindowClosed>,
-    /// Whether to resize all the panels in a dock when resizing the dock.
-    ///
-    /// Default: ["left"]
-    pub resize_all_panels_in_dock: Option<Vec<DockPosition>>,
-    /// Whether to automatically close files that have been deleted on disk.
-    ///
-    /// Default: false
-    pub close_on_file_delete: Option<bool>,
-    /// Whether to allow windows to tab together based on the user’s tabbing preference (macOS only).
-    ///
-    /// Default: false
-    pub use_system_window_tabs: Option<bool>,
-    /// Whether to show padding for zoomed panels.
-    /// When enabled, zoomed bottom panels will have some top padding,
-    /// while zoomed left/right panels will have padding to the right/left (respectively).
-    ///
-    /// Default: true
-    pub zoomed_padding: Option<bool>,
-}
-
 #[derive(Deserialize)]
 pub struct TabBarSettings {
     pub show: bool,
     pub show_nav_history_buttons: bool,
     pub show_tab_bar_buttons: bool,
 }
-
-#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, SettingsUi, SettingsKey)]
-#[settings_key(key = "tab_bar")]
-pub struct TabBarSettingsContent {
-    /// Whether or not to show the tab bar in the editor.
-    ///
-    /// Default: true
-    pub show: Option<bool>,
-    /// Whether or not to show the navigation history buttons in the tab bar.
-    ///
-    /// Default: true
-    pub show_nav_history_buttons: Option<bool>,
-    /// Whether or not to show the tab bar buttons.
-    ///
-    /// Default: true
-    pub show_tab_bar_buttons: Option<bool>,
-}
-
-#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum AutosaveSetting {
-    /// Disable autosave.
-    Off,
-    /// Save after inactivity period of `milliseconds`.
-    AfterDelay { milliseconds: u64 },
-    /// Autosave when focus changes.
-    OnFocusChange,
-    /// Autosave when the active window changes.
-    OnWindowChange,
-}
-
-#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum PaneSplitDirectionHorizontal {
-    Up,
-    Down,
-}
-
-#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, JsonSchema)]
-#[serde(rename_all = "snake_case")]
-pub enum PaneSplitDirectionVertical {
-    Left,
-    Right,
-}
-
-#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, SettingsUi)]
-#[serde(rename_all = "snake_case")]
-pub struct CenteredLayoutSettings {
-    /// The relative width of the left padding of the central pane from the
-    /// workspace when the centered layout is used.
-    ///
-    /// Default: 0.2
-    pub left_padding: Option<f32>,
-    // The relative width of the right padding of the central pane from the
-    // workspace when the centered layout is used.
-    ///
-    /// Default: 0.2
-    pub right_padding: Option<f32>,
-}
-
 impl Settings for WorkspaceSettings {
     type FileContent = WorkspaceSettingsContent;