mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Ensure we don't over-indent in type headers (fixes #7358)
This commit is contained in:
parent
d82accf83d
commit
7cb2d83168
5 changed files with 115 additions and 1 deletions
|
@ -549,7 +549,11 @@ impl<'a> Formattable for TypeHeader<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
buf.ensure_ends_with_whitespace();
|
||||
if last_multiline {
|
||||
buf.ensure_ends_with_newline();
|
||||
} else {
|
||||
buf.ensure_ends_with_whitespace();
|
||||
}
|
||||
|
||||
last_after = var.after;
|
||||
last_multiline = var.item.is_multiline();
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
M { s ? s
|
||||
{ J &
|
||||
} }
|
||||
{ s ? s
|
||||
{ J &
|
||||
} } : p
|
||||
y
|
|
@ -0,0 +1,98 @@
|
|||
@0-25 SpaceAfter(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(0),
|
||||
],
|
||||
regions: [
|
||||
@0-23,
|
||||
],
|
||||
space_before: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [
|
||||
Alias {
|
||||
header: TypeHeader {
|
||||
name: @0-1 "M",
|
||||
vars: [
|
||||
@1-11 RecordDestructure(
|
||||
[
|
||||
@2-10 OptionalField(
|
||||
"s",
|
||||
@4-10 Apply(
|
||||
@4-5 Var {
|
||||
module_name: "",
|
||||
ident: "s",
|
||||
},
|
||||
[
|
||||
@5-10 RecordUpdate {
|
||||
update: @6-7 Tag(
|
||||
"J",
|
||||
),
|
||||
fields: Collection {
|
||||
items: [],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
@11-21 RecordDestructure(
|
||||
[
|
||||
@12-20 OptionalField(
|
||||
"s",
|
||||
@14-20 Apply(
|
||||
@14-15 Var {
|
||||
module_name: "",
|
||||
ident: "s",
|
||||
},
|
||||
[
|
||||
@15-20 RecordUpdate {
|
||||
update: @16-17 Tag(
|
||||
"J",
|
||||
),
|
||||
fields: Collection {
|
||||
items: [],
|
||||
final_comments: [
|
||||
Newline,
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
],
|
||||
},
|
||||
ann: @22-23 BoundVariable(
|
||||
"p",
|
||||
),
|
||||
},
|
||||
],
|
||||
value_defs: [],
|
||||
},
|
||||
@24-25 SpaceBefore(
|
||||
Var {
|
||||
module_name: "",
|
||||
ident: "y",
|
||||
},
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
),
|
||||
),
|
||||
[
|
||||
Newline,
|
||||
],
|
||||
)
|
|
@ -0,0 +1,4 @@
|
|||
M{s?s{J&
|
||||
}}{s?s{J&
|
||||
}}:p
|
||||
y
|
|
@ -577,6 +577,7 @@ mod test_snapshots {
|
|||
pass/pattern_as_list_rest.expr,
|
||||
pass/pattern_as_spaces.expr,
|
||||
pass/pattern_comma_newlines.expr,
|
||||
pass/pattern_opt_field_bonanza.expr,
|
||||
pass/pattern_record_apply_comment.expr,
|
||||
pass/pattern_with_as_parens.expr,
|
||||
pass/pattern_with_space_in_parens.expr, // https://github.com/roc-lang/roc/issues/929
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue