@@ -288,8 +288,12 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
288288 }
289289
290290 // Consolidate any lines if the configuration requires it
291+ // TODO there is a hack here so that multi-line forms that are consolidated still line up properly
292+ // i have to make consolidate a more first-class feature of the config
291293 if (curr_node.formatting_config .inline_until_index (form_lines)) {
292294 std::vector<std::string> new_form_lines = {};
295+ const auto original_form_head_width = str_util::split (form_lines.at (0 ), ' \n ' ).at (0 ).length ();
296+ bool consolidating_lines = true ;
293297 for (int i = 0 ; i < (int )form_lines.size (); i++) {
294298 if (i < curr_node.formatting_config .inline_until_index (form_lines)) {
295299 if (new_form_lines.empty ()) {
@@ -298,7 +302,13 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
298302 new_form_lines.at (0 ) += fmt::format (" {}" , form_lines.at (i));
299303 }
300304 } else {
301- new_form_lines.push_back (form_lines.at (i));
305+ if (str_util::starts_with (form_lines.at (i), " " ) && consolidating_lines) {
306+ new_form_lines.push_back (fmt::format (
307+ " {}{}" , str_util::repeat (original_form_head_width, " " ), form_lines.at (i)));
308+ } else {
309+ consolidating_lines = false ;
310+ new_form_lines.push_back (form_lines.at (i));
311+ }
302312 }
303313 }
304314 form_lines = new_form_lines;
0 commit comments