Skip to content

Commit 80d1551

Browse files
committed
Don't migrate empty formatter array (#40932)
Follow up for #40409 Fix for #40874 (comment) Release Notes: - Fixed an issue where having an empty formatter array in your settings `"formatter": []` would result in an erroneous prompt to migrate settings
1 parent 00a1434 commit 80d1551

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

crates/migrator/src/migrations/m_2025_10_16/settings.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ fn restore_code_actions_on_format_inner(value: &mut Value, path: &[&str]) -> Res
3737
} else {
3838
vec![formatter.clone()]
3939
};
40+
if formatter_array.is_empty() {
41+
return Ok(());
42+
}
4043
let mut code_action_formatters = Vec::new();
4144
for formatter in formatter_array {
4245
let Some(code_action) = formatter.get("code_action") else {

crates/migrator/src/migrator.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2090,6 +2090,21 @@ mod tests {
20902090
.unindent(),
20912091
),
20922092
);
2093+
2094+
assert_migrate_settings_with_migrations(
2095+
&[MigrationType::Json(
2096+
migrations::m_2025_10_16::restore_code_actions_on_format,
2097+
)],
2098+
&r#"{
2099+
"formatter": [],
2100+
"code_actions_on_format": {
2101+
"bar": true,
2102+
"baz": false
2103+
}
2104+
}"#
2105+
.unindent(),
2106+
None,
2107+
);
20932108
}
20942109

20952110
#[test]

0 commit comments

Comments
 (0)