1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Dictionary: Serialize empty dict as {} instead of {\n}

Also make sure to always convert multiline dictionaries to a single line for
its EditorHelp representation, as multiline values break formatting.
This commit is contained in:
Rémi Verschelde
2022-01-18 11:31:15 +01:00
parent 045648d091
commit 8898d6dadc
12 changed files with 25 additions and 33 deletions

View File

@@ -1649,12 +1649,13 @@ Error VariantWriter::write(const Variant &p_variant, StoreStringFunc p_store_str
dict.get_key_list(&keys);
keys.sort();
if (keys.is_empty()) { // Avoid unnecessary line break.
p_store_string_func(p_store_string_ud, "{}");
break;
}
p_store_string_func(p_store_string_ud, "{\n");
for (List<Variant>::Element *E = keys.front(); E; E = E->next()) {
/*
if (!_check_type(dict[E->get()]))
continue;
*/
write(E->get(), p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, recursion_count);
p_store_string_func(p_store_string_ud, ": ");
write(dict[E->get()], p_store_string_func, p_store_string_ud, p_encode_res_func, p_encode_res_ud, recursion_count);