Don't migrate empty formatter array (#40932)

Follow up for #40409
Fix for
https://github.com/zed-industries/zed/issues/40874#issuecomment-3433759849

Release Notes:

- Fixed an issue where having an empty formatter array in your settings
`"formatter": []` would result in an erroneous prompt to migrate
settings
This commit is contained in:
Ben Kunkle
2025-10-22 20:01:45 +00:00
committed by GitHub
parent 93136a9aaa
commit 6ed9c0271d
2 changed files with 18 additions and 0 deletions
@@ -37,6 +37,9 @@ fn restore_code_actions_on_format_inner(value: &mut Value, path: &[&str]) -> Res
} else {
vec![formatter.clone()]
};
if formatter_array.is_empty() {
return Ok(());
}
let mut code_action_formatters = Vec::new();
for formatter in formatter_array {
let Some(code_action) = formatter.get("code_action") else {
+15
View File
@@ -2092,6 +2092,21 @@ mod tests {
.unindent(),
),
);
assert_migrate_settings_with_migrations(
&[MigrationType::Json(
migrations::m_2025_10_16::restore_code_actions_on_format,
)],
&r#"{
"formatter": [],
"code_actions_on_format": {
"bar": true,
"baz": false
}
}"#
.unindent(),
None,
);
}
#[test]