
<img width="389" alt="image" src="https://github.com/user-attachments/assets/c6718c6e-0fe1-40ed-b3db-7d576c4d98c8"> https://github.com/user-attachments/assets/734f1f52-70d9-4308-b1fc-36c7cfd4dd76 Closes https://github.com/zed-industries/zed/issues/7001 Closes https://github.com/zed-industries/zed/issues/4427 Part of https://github.com/zed-industries/zed/issues/15324 Part of https://github.com/zed-industries/zed/issues/14551 * Adjusts a `UniformList` to have a horizontal sizing behavior: the old mode forced all items to have the size of the list exactly. A new mode (with corresponding `ListItems` having `overflow_x` enabled) lays out the uniform list elements with width of its widest element, setting the same width to the list itself too. * Using the new behavior, adds a new scrollbar into the project panel and enhances its file name editor to scroll it during editing of long file names * Also restyles the scrollbar a bit, making it narrower and removing its background * Changes the project_panel.scrollbar.show settings to accept `null` and be `null` by default, to inherit `editor`'s scrollbar settings. All editor scrollbar settings are supported now. Release Notes: - Added a horizontal scrollbar to project panel ([#7001](https://github.com/zed-industries/zed/issues/7001)) ([#4427](https://github.com/zed-industries/zed/issues/4427)) --------- Co-authored-by: Piotr Osiewicz <piotr@zed.dev>
100 lines
3 KiB
Rust
100 lines
3 KiB
Rust
use editor::ShowScrollbar;
|
|
use gpui::Pixels;
|
|
use schemars::JsonSchema;
|
|
use serde_derive::{Deserialize, Serialize};
|
|
use settings::{Settings, SettingsSources};
|
|
|
|
#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema, Copy, PartialEq)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum ProjectPanelDockPosition {
|
|
Left,
|
|
Right,
|
|
}
|
|
|
|
#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
|
|
pub struct ProjectPanelSettings {
|
|
pub button: bool,
|
|
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,
|
|
pub scrollbar: ScrollbarSettings,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct ScrollbarSettings {
|
|
/// When to show the scrollbar in the project panel.
|
|
///
|
|
/// Default: inherits editor scrollbar settings
|
|
pub show: Option<ShowScrollbar>,
|
|
}
|
|
|
|
#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]
|
|
pub struct ScrollbarSettingsContent {
|
|
/// When to show the scrollbar in the project panel.
|
|
///
|
|
/// Default: inherits editor scrollbar settings
|
|
pub show: Option<Option<ShowScrollbar>>,
|
|
}
|
|
|
|
#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
|
|
pub struct ProjectPanelSettingsContent {
|
|
/// Whether to show the project panel button in the status bar.
|
|
///
|
|
/// Default: true
|
|
pub button: Option<bool>,
|
|
/// Customize 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: false
|
|
pub auto_fold_dirs: Option<bool>,
|
|
/// Scrollbar-related settings
|
|
pub scrollbar: Option<ScrollbarSettingsContent>,
|
|
}
|
|
|
|
impl Settings for ProjectPanelSettings {
|
|
const KEY: Option<&'static str> = Some("project_panel");
|
|
|
|
type FileContent = ProjectPanelSettingsContent;
|
|
|
|
fn load(
|
|
sources: SettingsSources<Self::FileContent>,
|
|
_: &mut gpui::AppContext,
|
|
) -> anyhow::Result<Self> {
|
|
sources.json_merge()
|
|
}
|
|
}
|