From 210ab1164367e2b8661c6200ce24c54c1eb768f1 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Tue, 31 Aug 2021 17:06:18 +0200 Subject: [PATCH] Write node groups one a single line when saving a `.tscn` file This makes `.tscn` files more readable by ensuring sections are always written on a single line. (cherry picked from commit d33a7367b6748a3fac70bb90ebf930c7a663430f) --- scene/resources/resource_format_text.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp index 27a349d75c4..f22bcb8d101 100644 --- a/scene/resources/resource_format_text.cpp +++ b/scene/resources/resource_format_text.cpp @@ -1635,10 +1635,16 @@ Error ResourceFormatSaverTextInstance::save(const String &p_path, const RES &p_r } if (groups.size()) { + // Write all groups on the same line as they're part of a section header. + // This improves readability while not impacting VCS friendliness too much, + // since it's rare to have more than 5 groups assigned to a single node. groups.sort_custom(); - String sgroups = " groups=[\n"; + String sgroups = " groups=["; for (int j = 0; j < groups.size(); j++) { - sgroups += "\"" + String(groups[j]).c_escape() + "\",\n"; + sgroups += "\"" + String(groups[j]).c_escape() + "\""; + if (j < groups.size() - 1) { + sgroups += ", "; + } } sgroups += "]"; header += sgroups;