diff --git a/assets/settings/default.json b/assets/settings/default.json index 802e6fd5858b7bfdad33d84ff5e5a4249dfac7f6..6919578dc79be94171b66950b39d5296316f3ee1 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -1,4 +1,5 @@ { + "project_name": null, // The name of the Zed theme to use for the UI. // // `mode` is one of: diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 70a09793df143f2c837157592a79f4ca5e575a5d..0211568b5abfb7d6a2ccc2c68ea800cebe312145 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -31,10 +31,10 @@ use gpui::{ }; use keymap_editor; use onboarding_banner::OnboardingBanner; -use project::Project; +use project::{Project, WorktreeSettings}; use remote::RemoteConnectionOptions; -use settings::Settings as _; -use std::sync::Arc; +use settings::{Settings, SettingsLocation}; +use std::{path::Path, sync::Arc}; use theme::ActiveTheme; use title_bar_settings::TitleBarSettings; use ui::{ @@ -433,14 +433,24 @@ impl TitleBar { } pub fn render_project_name(&self, cx: &mut Context) -> impl IntoElement { - let name = { - let mut names = self.project.read(cx).visible_worktrees(cx).map(|worktree| { + let name = self + .project + .read(cx) + .visible_worktrees(cx) + .map(|worktree| { let worktree = worktree.read(cx); - worktree.root_name() - }); + let settings_location = SettingsLocation { + worktree_id: worktree.id(), + path: Path::new(""), + }; - names.next() - }; + let settings = WorktreeSettings::get(Some(settings_location), cx); + match &settings.project_name { + Some(name) => name.as_str(), + None => worktree.root_name(), + } + }) + .next(); let is_project_selected = name.is_some(); let name = if let Some(name) = name { util::truncate_and_trailoff(name, MAX_PROJECT_NAME_LENGTH) diff --git a/crates/workspace/src/workspace.rs b/crates/workspace/src/workspace.rs index 58373b5d1a30a431106282d26589aa09694d3382..49b00d26d4f14342c08a3361d8420a658ee1b5a8 100644 --- a/crates/workspace/src/workspace.rs +++ b/crates/workspace/src/workspace.rs @@ -72,6 +72,7 @@ pub use persistence::{ use postage::stream::Stream; use project::{ DirectoryLister, Project, ProjectEntryId, ProjectPath, ResolvedPath, Worktree, WorktreeId, + WorktreeSettings, debugger::{breakpoint_store::BreakpointStoreEvent, session::ThreadStatus}, toolchain_store::ToolchainStoreEvent, }; @@ -79,7 +80,7 @@ use remote::{RemoteClientDelegate, RemoteConnectionOptions, remote_client::Conne use schemars::JsonSchema; use serde::Deserialize; use session::AppSession; -use settings::{Settings, update_settings_file}; +use settings::{Settings, SettingsLocation, update_settings_file}; use shared_screen::SharedScreen; use sqlez::{ bindable::{Bind, Column, StaticColumnCount}, @@ -4376,7 +4377,19 @@ impl Workspace { let project = self.project().read(cx); let mut title = String::new(); - for (i, name) in project.worktree_root_names(cx).enumerate() { + for (i, worktree) in project.worktrees(cx).enumerate() { + let name = { + let settings_location = SettingsLocation { + worktree_id: worktree.read(cx).id(), + path: Path::new(""), + }; + + let settings = WorktreeSettings::get(Some(settings_location), cx); + match &settings.project_name { + Some(name) => name.as_str(), + None => worktree.read(cx).root_name(), + } + }; if i > 0 { title.push_str(", "); } diff --git a/crates/worktree/src/worktree_settings.rs b/crates/worktree/src/worktree_settings.rs index 41eb3ab6f6aa971d44009c1cbb00567a4f3448ea..ca7714fa7315117a5c2e31b06d2f059ad43cb1a9 100644 --- a/crates/worktree/src/worktree_settings.rs +++ b/crates/worktree/src/worktree_settings.rs @@ -9,6 +9,7 @@ use util::paths::PathMatcher; #[derive(Clone, PartialEq, Eq)] pub struct WorktreeSettings { + pub project_name: Option, pub file_scan_inclusions: PathMatcher, pub file_scan_exclusions: PathMatcher, pub private_files: PathMatcher, @@ -34,6 +35,13 @@ impl WorktreeSettings { #[derive(Clone, Default, Serialize, Deserialize, JsonSchema, SettingsUi, SettingsKey)] #[settings_key(None)] pub struct WorktreeSettingsContent { + /// The displayed name of this project. If not set, the root directory name + /// will be displayed. + /// + /// Default: none + #[serde(default)] + pub project_name: Option, + /// Completely ignore files matching globs from `file_scan_exclusions`. Overrides /// `file_scan_inclusions`. /// @@ -93,6 +101,7 @@ impl Settings for WorktreeSettings { &parsed_file_scan_inclusions, "file_scan_inclusions", )?, + project_name: result.project_name, }) }