Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
project_panel: Add `open_file_on_paste` setting to configure auto opening of file on paste (#40331)
zeld-a546715634c34
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex 995c3901c78..5b37e2d6c07 100644--- a/assets/settings/default.json+++ b/assets/settings/default.json@@ -724,7 +724,9 @@// Whether to hide the root entry when only one folder is open in the window."hide_root": false,// Whether to hide the hidden entries in the project panel.- "hide_hidden": false+ "hide_hidden": false,+ // Whether to automatically open files when pasting them in the project panel.+ "open_file_on_paste": true},"outline_panel": {// Whether to show the outline panel button in the status bardiff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rsindex aac3769ac4e..17c09dcb06e 100644--- a/crates/project_panel/src/project_panel.rs+++ b/crates/project_panel/src/project_panel.rs@@ -2698,8 +2698,10 @@ impl ProjectPanel {});if item_count == 1 {- // open entry if not dir, and only focus if rename is not pending- if !entry.is_dir() {+ // open entry if not dir, setting is enabled, and only focus if rename is not pending+ if !entry.is_dir()+ && ProjectPanelSettings::get_global(cx).open_file_on_paste+ {project_panel.open_entry(entry.id,disambiguation_range.is_none(),diff --git a/crates/project_panel/src/project_panel_settings.rs b/crates/project_panel/src/project_panel_settings.rsindex 45d50efcaf3..3eca8a6e868 100644--- a/crates/project_panel/src/project_panel_settings.rs+++ b/crates/project_panel/src/project_panel_settings.rs@@ -32,6 +32,7 @@ pub struct ProjectPanelSettings {pub hide_root: bool,pub hide_hidden: bool,pub drag_and_drop: bool,+ pub open_file_on_paste: bool,}#[derive(Copy, Clone, Debug, Serialize, Deserialize, JsonSchema, PartialEq, Eq)]@@ -82,6 +83,7 @@ impl Settings for ProjectPanelSettings {hide_root: project_panel.hide_root.unwrap(),hide_hidden: project_panel.hide_hidden.unwrap(),drag_and_drop: project_panel.drag_and_drop.unwrap(),+ open_file_on_paste: project_panel.open_file_on_paste.unwrap(),}}diff --git a/crates/settings/src/settings_content/workspace.rs b/crates/settings/src/settings_content/workspace.rsindex a560dc7c598..21b25d6d3c4 100644--- a/crates/settings/src/settings_content/workspace.rs+++ b/crates/settings/src/settings_content/workspace.rs@@ -566,6 +566,10 @@ pub struct ProjectPanelSettingsContent {////// Default: truepub drag_and_drop: Option<bool>,+ /// Whether to automatically open files when pasting them in the project panel.+ ///+ /// Default: true+ pub open_file_on_paste: Option<bool>,}#[derive(diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rsindex fd2bd170233..1330ec62763 100644--- a/crates/settings_ui/src/page_data.rs+++ b/crates/settings_ui/src/page_data.rs@@ -3120,6 +3120,27 @@ pub(crate) fn settings_data(cx: &App) -> Vec<SettingsPage> {metadata: None,files: USER,}),+ SettingsPageItem::SettingItem(SettingItem {+ title: "Open File on Paste",+ description: "Whether to automatically open files when pasting them in the project panel",+ field: Box::new(SettingField {+ pick: |settings_content| {+ if let Some(project_panel) = &settings_content.project_panel {+ &project_panel.open_file_on_paste+ } else {+ &None+ }+ },+ pick_mut: |settings_content| {+ &mut settings_content+ .project_panel+ .get_or_insert_default()+ .open_file_on_paste+ },+ }),+ metadata: None,+ files: USER,+ }),SettingsPageItem::SectionHeader("Terminal Panel"),SettingsPageItem::SettingItem(SettingItem {title: "Terminal Dock",diff --git a/docs/src/configuring-zed.md b/docs/src/configuring-zed.mdindex 876d75c7e89..14c2f724f03 100644--- a/docs/src/configuring-zed.md+++ b/docs/src/configuring-zed.md@@ -4155,7 +4155,8 @@ Run the {#action theme_selector::Toggle} action in the command palette to see a},"hide_root": false,"hide_hidden": false,- "starts_open": true+ "starts_open": true,+ "open_file_on_paste": true}}```