This is another variant for this [original PR](https://github.com/zed-industries/zed/pull/10091) to add settings to show/hide navigation history buttons that puts the settings under a new section called `tab_bar`: ``` "tab_bar": { // Whether or not to show the navigation history buttons. "show_nav_history_buttons": true } ``` <img width="314" alt="Screenshot 2024-04-02 at 3 00 53 PM" src="https://github.com/zed-industries/zed/assets/1253505/23c4fa19-5a63-4160-b3b7-1b5e976c36bf"> <img width="329" alt="Screenshot 2024-04-02 at 3 01 03 PM" src="https://github.com/zed-industries/zed/assets/1253505/64c2ebd2-9311-4589-a4e8-bd149c6c4ece">
88 lines
2.5 KiB
Rust
88 lines
2.5 KiB
Rust
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use settings::Settings;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct WorkspaceSettings {
|
|
pub active_pane_magnification: f32,
|
|
pub confirm_quit: bool,
|
|
pub show_call_status_icon: bool,
|
|
pub autosave: AutosaveSetting,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
|
pub struct WorkspaceSettingsContent {
|
|
/// Scale by which to zoom the active pane.
|
|
/// When set to 1.0, the active pane has the same size as others,
|
|
/// but when set to a larger value, the active pane takes up more space.
|
|
///
|
|
/// Default: `1.0`
|
|
pub active_pane_magnification: Option<f32>,
|
|
/// 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>,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct TabBarSettings {
|
|
pub show_nav_history_buttons: bool,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema)]
|
|
pub struct TabBarSettingsContent {
|
|
/// Whether or not to show the navigation history buttons in the tab bar.
|
|
///
|
|
/// Default: true
|
|
pub show_nav_history_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,
|
|
}
|
|
|
|
impl Settings for WorkspaceSettings {
|
|
const KEY: Option<&'static str> = None;
|
|
|
|
type FileContent = WorkspaceSettingsContent;
|
|
|
|
fn load(
|
|
default_value: &Self::FileContent,
|
|
user_values: &[&Self::FileContent],
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
}
|
|
}
|
|
|
|
impl Settings for TabBarSettings {
|
|
const KEY: Option<&'static str> = Some("tab_bar");
|
|
|
|
type FileContent = TabBarSettingsContent;
|
|
|
|
fn load(
|
|
default_value: &Self::FileContent,
|
|
user_values: &[&Self::FileContent],
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
Self::load_via_json_merge(default_value, user_values)
|
|
}
|
|
}
|