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
+53
View File
@@ -215,6 +215,10 @@ pub fn migrate_settings(text: &str) -> Result<Option<String>> {
MigrationType::Json(migrations::m_2025_10_16::restore_code_actions_on_format),
MigrationType::Json(migrations::m_2025_10_17::make_file_finder_include_ignored_an_enum),
MigrationType::Json(migrations::m_2025_10_21::make_relative_line_numbers_an_enum),
MigrationType::TreeSitter(
migrations::m_2025_11_12::SETTINGS_PATTERNS,
&SETTINGS_QUERY_2025_11_12,
),
];
run_migrations(text, migrations)
}
@@ -333,6 +337,10 @@ define_query!(
SETTINGS_QUERY_2025_10_03,
migrations::m_2025_10_03::SETTINGS_PATTERNS
);
define_query!(
SETTINGS_QUERY_2025_11_12,
migrations::m_2025_11_12::SETTINGS_PATTERNS
);
// custom query
static EDIT_PREDICTION_SETTINGS_MIGRATION_QUERY: LazyLock<Query> = LazyLock::new(|| {
@@ -2193,4 +2201,49 @@ mod tests {
),
);
}
#[test]
fn test_project_panel_open_file_on_paste_migration() {
assert_migrate_settings(
&r#"
{
"project_panel": {
"open_file_on_paste": true
}
}
"#
.unindent(),
Some(
&r#"
{
"project_panel": {
"auto_open": { "on_paste": true }
}
}
"#
.unindent(),
),
);
assert_migrate_settings(
&r#"
{
"project_panel": {
"open_file_on_paste": false
}
}
"#
.unindent(),
Some(
&r#"
{
"project_panel": {
"auto_open": { "on_paste": false }
}
}
"#
.unindent(),
),
);
}
}