diff --git a/assets/settings/default.json b/assets/settings/default.json index 995c3901c789912c691950ac0ea3da4855ab2cec..5b37e2d6c07fc348ee795eb4ea5bb043c1f2689d 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 bar diff --git a/crates/project_panel/src/project_panel.rs b/crates/project_panel/src/project_panel.rs index aac3769ac4ed3def5dfd427fe13885176fd43047..17c09dcb06e6f665eb589fc4b61b5bc73a0c2982 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.rs index 45d50efcaf36ea04aa799185490c14a37736b5b1..3eca8a6e8685b787069bc14482bdffce551d87ac 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.rs index a560dc7c5980b418e4c4ada5932c99cb131ccccc..21b25d6d3c47fb76e4de638519a145b5d916e555 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: true pub drag_and_drop: Option, + /// Whether to automatically open files when pasting them in the project panel. + /// + /// Default: true + pub open_file_on_paste: Option, } #[derive( diff --git a/crates/settings_ui/src/page_data.rs b/crates/settings_ui/src/page_data.rs index fd2bd170233389f72c3ae4f6da9b77364089d76e..1330ec62763c5d0a3361c580a666d1be1f1bffd3 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 { 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.md index 876d75c7e8911c774ff3067669a59404c91ee7d5..14c2f724f0367c42e8e0346c9251d27b92bf7a0a 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 } } ```