Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Merge remote-tracking branch 'origin/main' into panels
Antonio Scandurra208ff2fba743
diff --cc Cargo.lockindex b8b57e8b8dd,981005f3f2b..35ea2eefd8b--- a/Cargo.lock+++ b/Cargo.lock@@@ -4886,9 -4886,9 +4886,10 @@@ dependencies =name = "project_panel"version = "0.1.0"dependencies = [+ "anyhow","client","context_menu",+ "db","drag_and_drop","editor","futures 0.3.28",diff --cc assets/settings/default.jsonindex 3e4c59e8067,38d0ce820ba..246e28cc8e2--- a/assets/settings/default.json+++ b/assets/settings/default.json@@@ -52,19 -52,28 +52,32 @@@// 3. Draw all invisible symbols:// "all""show_whitespaces": "selection",- // Whether to show the scrollbar in the editor.- // This setting can take four values:- //- // 1. Show the scrollbar if there's important information or- // follow the system's configured behavior (default):- // "auto"- // 2. Match the system's configured behavior:- // "system"- // 3. Always show the scrollbar:- // "always"- // 4. Never show the scrollbar:- // "never"- "show_scrollbars": "auto",+ // Scrollbar related settings+ "scrollbar": {+ // When to show the scrollbar in the editor.+ // This setting can take four values:+ //+ // 1. Show the scrollbar if there's important information or+ // follow the system's configured behavior (default):+ // "auto"+ // 2. Match the system's configured behavior:+ // "system"+ // 3. Always show the scrollbar:+ // "always"+ // 4. Never show the scrollbar:+ // "never"+ "show": "auto",+ // Whether to show git diff indicators in the scrollbar.+ "git_diff": true+ },+ "project_panel": {+ // Whether to show the git status in the project panel.- "git_status": true++ "git_status": true,++ // Where to dock project panel. Can be 'left' or 'right'.++ "dock": "left",++ // Default width of the project panel.++ "default_width": 240+ },// Whether the screen sharing icon is shown in the os status bar."show_call_status_icon": true,// Whether to use language servers to provide code intelligence.diff --cc crates/project_panel/Cargo.tomlindex aab5b8a41c2,01d1be53b9e..55efc09deb1--- a/crates/project_panel/Cargo.toml+++ b/crates/project_panel/Cargo.toml@@@ -22,9 -21,12 +22,11 @@@ util = { path = "../util"workspace = { path = "../workspace" }postage.workspace = truefutures.workspace = true- schemars.workspace = trueserde.workspace = true+ serde_derive.workspace = trueserde_json.workspace = true+ anyhow.workspace = true+ schemars.workspace = true-unicase = "2.6"[dev-dependencies]diff --cc crates/project_panel/src/project_panel.rsindex 9159e8fa98e,69d8b8be4dd..32a8148cbb7--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@@ -1,13 -1,14 +1,15 @@@+ mod project_panel_settings;+use context_menu::{ContextMenu, ContextMenuItem};+use db::kvp::KEY_VALUE_STORE;use drag_and_drop::{DragAndDrop, Draggable};use editor::{Cancel, Editor};use futures::stream::StreamExt;use gpui::{actions,- anyhow::{anyhow, Result},+ anyhow::{self, anyhow, Result},elements::{- AnchorCorner, ChildView, ComponentHost, ContainerStyle, Empty, Flex, MouseEventHandler,+ AnchorCorner, ChildView, ContainerStyle, Empty, Flex, Label, MouseEventHandler,ParentElement, ScrollTarget, Stack, Svg, UniformList, UniformListState,},geometry::vector::Vector2F,@@@ -18,12 -19,10 +20,12 @@@};use menu::{Confirm, SelectNext, SelectPrev};use project::{- repository::GitFileStatus, Entry, EntryKind, Project, ProjectEntryId, ProjectPath, Worktree,- WorktreeId,+ repository::GitFileStatus, Entry, EntryKind, Fs, Project, ProjectEntryId, ProjectPath,+ Worktree, WorktreeId,};- use schemars::JsonSchema;-use project_panel_settings::ProjectPanelSettings;++use project_panel_settings::{ProjectPanelDockPosition, ProjectPanelSettings};+use serde::{Deserialize, Serialize};+use settings::SettingsStore;use std::{cmp::Ordering,collections::{hash_map, HashMap},@@@ -32,53 -31,14 +34,20 @@@path::Path,sync::Arc,};- use theme::{ui::FileName, ProjectPanelEntry};+ use theme::ProjectPanelEntry;use unicase::UniCase;-use workspace::Workspace;+use util::{ResultExt, TryFutureExt};+use workspace::{+ dock::{DockPosition, Panel},+ Workspace,+};+const PROJECT_PANEL_KEY: &'static str = "ProjectPanel";const NEW_ENTRY_ID: ProjectEntryId = ProjectEntryId::MAX;- #[derive(Deserialize)]- pub struct ProjectPanelSettings {- dock: ProjectPanelDockPosition,- default_width: f32,- }-- impl settings::Setting for ProjectPanelSettings {- const KEY: Option<&'static str> = Some("project_panel");-- type FileContent = ProjectPanelSettingsContent;-- fn load(- default_value: &Self::FileContent,- user_values: &[&Self::FileContent],- _: &AppContext,- ) -> Result<Self> {- Self::load_via_json_merge(default_value, user_values)- }- }-- #[derive(Clone, Debug, Default, Serialize, Deserialize, JsonSchema)]- pub struct ProjectPanelSettingsContent {- dock: Option<ProjectPanelDockPosition>,- default_width: Option<f32>,- }-- #[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]- #[serde(rename_all = "snake_case")]- pub enum ProjectPanelDockPosition {- Left,- Right,- }-pub struct ProjectPanel {project: ModelHandle<Project>,+ fs: Arc<dyn Fs>,list: UniformListState,visible_entries: Vec<(WorktreeId, Vec<Entry>)>,last_worktree_root_id: Option<ProjectEntryId>,diff --cc crates/project_panel/src/project_panel_settings.rsindex 00000000000,7786f1b4380..1d6c590710bmode 000000,100644..100644--- a/crates/project_panel/src/project_panel_settings.rs+++ b/crates/project_panel/src/project_panel_settings.rs@@@ -1,0 -1,28 +1,39 @@@+ use anyhow;+ use schemars::JsonSchema;+ use serde_derive::{Deserialize, Serialize};+ use settings::Setting;+++#[derive(Clone, Debug, Serialize, Deserialize, JsonSchema)]++#[serde(rename_all = "snake_case")]++pub enum ProjectPanelDockPosition {++ Left,++ Right,++}+++ #[derive(Deserialize, Debug)]+ pub struct ProjectPanelSettings {+ pub git_status: bool,++ pub dock: ProjectPanelDockPosition,++ pub default_width: f32,+ }++ #[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]+ pub struct ProjectPanelSettingsContent {+ pub git_status: Option<bool>,++ pub dock: Option<ProjectPanelDockPosition>,++ pub default_width: Option<f32>,+ }++ impl Setting for ProjectPanelSettings {+ const KEY: Option<&'static str> = Some("project_panel");++ type FileContent = ProjectPanelSettingsContent;++ fn load(+ default_value: &Self::FileContent,+ user_values: &[&Self::FileContent],+ _: &gpui::AppContext,+ ) -> anyhow::Result<Self> {+ Self::load_via_json_merge(default_value, user_values)+ }+ }diff --cc crates/zed/src/zed.rsindex 4c4137b7f37,95d09e82ec4..f9c0a1855ee--- a/crates/zed/src/zed.rs+++ b/crates/zed/src/zed.rs@@@ -2087,9 -2068,8 +2087,10 @@@ mod testsworkspace::init(app_state.clone(), cx);language::init(cx);editor::init(cx);+ project_panel::init_settings(cx);pane::init(cx);+ project_panel::init(cx);+ terminal_view::init(cx);app_state})}