Indent for multiline | patterns

This commit is contained in:
Richard Feldman 2022-07-03 22:17:13 -04:00
parent 872efa9724
commit 244a501433
No known key found for this signature in database
GPG key ID: 7E4127D1E4241798
3 changed files with 21 additions and 17 deletions

View file

@ -710,10 +710,15 @@ fn fmt_when<'a, 'buf>(
if index != 0 {
if is_multiline_patterns {
buf.newline();
buf.indent(indent + INDENT);
// Indent an extra level for the `|`;
// otherwise it'll be at the start of the line,
// and will be incorrectly parsed as a pattern
buf.indent(indent + INDENT + INDENT);
buf.push('|');
} else {
buf.push_str(" |");
}
buf.push_str(" |");
buf.spaces(1);
}