
Added support of auto collapsed directories, for example when directory has only one directory inside we should display it as dir1/dir2 (#6935 ). Please feel free to propose better solutions, as I am new in Rust Demo: https://streamable.com/seo3n9 Release Notes: - Added support for auto-collapsing directories.
77 lines
2.2 KiB
Rust
77 lines
2.2 KiB
Rust
use anyhow;
|
|
use gpui::Pixels;
|
|
use schemars::JsonSchema;
|
|
use serde_derive::{Deserialize, Serialize};
|
|
use settings::Settings;
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ProjectPanelDockPosition {
|
|
Left,
|
|
Right,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug)]
|
|
pub struct ProjectPanelSettings {
|
|
pub default_width: Pixels,
|
|
pub dock: ProjectPanelDockPosition,
|
|
pub file_icons: bool,
|
|
pub folder_icons: bool,
|
|
pub git_status: bool,
|
|
pub indent_size: f32,
|
|
pub auto_reveal_entries: bool,
|
|
pub auto_fold_dirs: bool,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
|
pub struct ProjectPanelSettingsContent {
|
|
/// Customise default width (in pixels) taken by project panel
|
|
///
|
|
/// Default: 240
|
|
pub default_width: Option<f32>,
|
|
/// The position of project panel
|
|
///
|
|
/// Default: left
|
|
pub dock: Option<ProjectPanelDockPosition>,
|
|
/// Whether to show file icons in the project panel.
|
|
///
|
|
/// Default: true
|
|
pub file_icons: Option<bool>,
|
|
/// Whether to show folder icons or chevrons for directories in the project panel.
|
|
///
|
|
/// Default: true
|
|
pub folder_icons: Option<bool>,
|
|
/// Whether to show the git status in the project panel.
|
|
///
|
|
/// Default: true
|
|
pub git_status: Option<bool>,
|
|
/// Amount of indentation (in pixels) for nested items.
|
|
///
|
|
/// Default: 20
|
|
pub indent_size: Option<f32>,
|
|
/// Whether to reveal it in the project panel automatically,
|
|
/// when a corresponding project entry becomes active.
|
|
/// Gitignored entries are never auto revealed.
|
|
///
|
|
/// Default: true
|
|
pub auto_reveal_entries: Option<bool>,
|
|
/// Whether to fold directories automatically
|
|
/// when directory has only one directory inside.
|
|
///
|
|
/// Default: true
|
|
pub auto_fold_dirs: Option<bool>,
|
|
}
|
|
|
|
impl Settings for ProjectPanelSettings {
|
|
const KEY: Option<&'static str> = Some("project_panel");
|
|
|
|
type FileContent = ProjectPanelSettingsContent;
|
|
|
|
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)
|
|
}
|
|
}
|