Skip to content

Commit 6ed9c02

Browse files
authored
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 93136a9 commit 6ed9c02

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
@@ -2092,6 +2092,21 @@ mod tests {
20922092
.unindent(),
20932093
),
20942094
);
2095+
2096+
assert_migrate_settings_with_migrations(
2097+
&[MigrationType::Json(
2098+
migrations::m_2025_10_16::restore_code_actions_on_format,
2099+
)],
2100+
&r#"{
2101+
"formatter": [],
2102+
"code_actions_on_format": {
2103+
"bar": true,
2104+
"baz": false
2105+
}
2106+
}"#
2107+
.unindent(),
2108+
None,
2109+
);
20952110
}
20962111

20972112
#[test]

0 commit comments

Comments
 (0)