mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Fix closure indentation and indented-else handling in niche pattern case
This commit is contained in:
parent
9f3f99c573
commit
307b0d9ea9
11 changed files with 299 additions and 128 deletions
|
@ -1847,31 +1847,19 @@ fn fmt_closure<'a>(
|
|||
buf.spaces(1);
|
||||
}
|
||||
|
||||
let arrow_line_indent = buf.cur_line_indent();
|
||||
buf.push_str("->");
|
||||
buf.spaces(1);
|
||||
|
||||
let is_multiline = loc_ret.value.is_multiline();
|
||||
|
||||
// If the body is multiline, go down a line and indent.
|
||||
let body_indent = if is_multiline {
|
||||
indent + INDENT
|
||||
arrow_line_indent + INDENT
|
||||
} else {
|
||||
indent
|
||||
};
|
||||
|
||||
// the body of the Closure can be on the same line, or
|
||||
// on a new line. If it's on the same line, insert a space.
|
||||
|
||||
match &loc_ret.value {
|
||||
SpaceBefore(_, _) => {
|
||||
// the body starts with (first comment and then) a newline
|
||||
// do nothing
|
||||
}
|
||||
_ => {
|
||||
// add a space after the `->`
|
||||
buf.spaces(1);
|
||||
}
|
||||
};
|
||||
|
||||
if is_multiline {
|
||||
match &loc_ret.value {
|
||||
SpaceBefore(sub_expr, spaces) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue