formatter: fix multi-line form consolidation (#3336)
parent
0ea718a5ee
commit
0236e36a53
|
@ -288,8 +288,12 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
|
|||
}
|
||||
|
||||
// Consolidate any lines if the configuration requires it
|
||||
// TODO there is a hack here so that multi-line forms that are consolidated still line up properly
|
||||
// i have to make consolidate a more first-class feature of the config
|
||||
if (curr_node.formatting_config.inline_until_index(form_lines)) {
|
||||
std::vector<std::string> new_form_lines = {};
|
||||
const auto original_form_head_width = str_util::split(form_lines.at(0), '\n').at(0).length();
|
||||
bool consolidating_lines = true;
|
||||
for (int i = 0; i < (int)form_lines.size(); i++) {
|
||||
if (i < curr_node.formatting_config.inline_until_index(form_lines)) {
|
||||
if (new_form_lines.empty()) {
|
||||
|
@ -298,7 +302,13 @@ std::vector<std::string> apply_formatting(const FormatterTreeNode& curr_node,
|
|||
new_form_lines.at(0) += fmt::format(" {}", form_lines.at(i));
|
||||
}
|
||||
} else {
|
||||
new_form_lines.push_back(form_lines.at(i));
|
||||
if (str_util::starts_with(form_lines.at(i), " ") && consolidating_lines) {
|
||||
new_form_lines.push_back(fmt::format(
|
||||
"{}{}", str_util::repeat(original_form_head_width, " "), form_lines.at(i)));
|
||||
} else {
|
||||
consolidating_lines = false;
|
||||
new_form_lines.push_back(form_lines.at(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
form_lines = new_form_lines;
|
||||
|
|
|
@ -25,3 +25,20 @@ Non-Inlinable If
|
|||
(if arg1
|
||||
(symbol->string (-> arg0 type symbol) (-> arg0 type symbol) (-> arg0 type symbol) (-> arg0 type symbol))
|
||||
(symbol->string (-> arg0 type symbol) (-> arg0 type symbol) (-> arg0 type symbol) (-> arg0 type symbol)))
|
||||
|
||||
===
|
||||
Multiline condition hang
|
||||
===
|
||||
|
||||
(when (and (-> this ignore-menu-toggle?)
|
||||
(or (not (cpad-hold? 0 l1)) (not (cpad-hold? 0 r1)))
|
||||
(or (and (-> this opened-with-start?) (not (cpad-hold? 0 start)) (not (cpad-hold? 0 start))) (and (not (-> this opened-with-start?)) (not (cpad-hold? 0 select)))))
|
||||
(set! (-> this ignore-menu-toggle?) #f))
|
||||
|
||||
---
|
||||
|
||||
(when (and (-> this ignore-menu-toggle?)
|
||||
(or (not (cpad-hold? 0 l1)) (not (cpad-hold? 0 r1)))
|
||||
(or (and (-> this opened-with-start?) (not (cpad-hold? 0 start)) (not (cpad-hold? 0 start)))
|
||||
(and (not (-> this opened-with-start?)) (not (cpad-hold? 0 select)))))
|
||||
(set! (-> this ignore-menu-toggle?) #f))
|
||||
|
|
Loading…
Reference in New Issue