project_panel: Add auto_open settings (#40435)

- Based on #40234, and improvement of #40331

Release Notes:

- Added granular settings to control when files auto-open in the project
panel (project_panel.auto_open.on_create, on_paste, on_drop)

<img width="662" height="367" alt="Screenshot_2025-10-16_17-28-31"
src="https://github.com/user-attachments/assets/930a0a50-fc89-4c5d-8d05-b1fa2279de8b"
/>

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
This commit is contained in:
Miguel Cárdenas
2025-11-12 03:23:40 +05:30
committed by GitHub
co-authored by Smit Barmase
parent 854c6873c7
commit 2ad7ecbcf0
13 changed files with 542 additions and 34 deletions
+36 -12
View File
@@ -3776,23 +3776,47 @@ pub(crate) fn settings_data(cx: &App) -> Vec<SettingsPage> {
metadata: None,
files: USER,
}),
SettingsPageItem::SectionHeader("Auto Open Files"),
SettingsPageItem::SettingItem(SettingItem {
title: "Open File on Paste",
description: "Whether to automatically open files when pasting them in the project panel.",
title: "On Create",
description: "Whether to automatically open newly created files in the editor.",
field: Box::new(SettingField {
json_path: Some("project_panel.open_file_on_paste"),
json_path: Some("project_panel.auto_open.on_create"),
pick: |settings_content| {
settings_content
.project_panel
.as_ref()?
.open_file_on_paste
.as_ref()
settings_content.project_panel.as_ref()?.auto_open.as_ref()?.on_create.as_ref()
},
write: |settings_content, value| {
settings_content
.project_panel
.get_or_insert_default()
.open_file_on_paste = value;
settings_content.project_panel.get_or_insert_default().auto_open.get_or_insert_default().on_create = value;
},
}),
metadata: None,
files: USER,
}),
SettingsPageItem::SettingItem(SettingItem {
title: "On Paste",
description: "Whether to automatically open files after pasting or duplicating them.",
field: Box::new(SettingField {
json_path: Some("project_panel.auto_open.on_paste"),
pick: |settings_content| {
settings_content.project_panel.as_ref()?.auto_open.as_ref()?.on_paste.as_ref()
},
write: |settings_content, value| {
settings_content.project_panel.get_or_insert_default().auto_open.get_or_insert_default().on_paste = value;
},
}),
metadata: None,
files: USER,
}),
SettingsPageItem::SettingItem(SettingItem {
title: "On Drop",
description: "Whether to automatically open files dropped from external sources.",
field: Box::new(SettingField {
json_path: Some("project_panel.auto_open.on_drop"),
pick: |settings_content| {
settings_content.project_panel.as_ref()?.auto_open.as_ref()?.on_drop.as_ref()
},
write: |settings_content, value| {
settings_content.project_panel.get_or_insert_default().auto_open.get_or_insert_default().on_drop = value;
},
}),
metadata: None,