Move indent call to correct spot

This commit is contained in:
Joshua Warner 2024-12-14 22:11:00 -08:00
parent 11d8dd1335
commit 1b4f5bbb52
No known key found for this signature in database
GPG key ID: 89AD497003F93FDD
7 changed files with 68 additions and 12 deletions

View file

@ -894,8 +894,8 @@ impl<'a> Formattable for ImplementsAbilities<'a> {
ImplementsAbilities::Implements(has_abilities) => {
if newlines == Newlines::Yes {
buf.newline();
buf.indent(indent);
}
buf.indent(indent);
buf.push_str(roc_parse::keyword::IMPLEMENTS);
buf.spaces(1);
fmt_collection(buf, indent, Braces::Square, *has_abilities, Newlines::No);

View file

@ -95,11 +95,7 @@ impl<'a> Buf<'a> {
#[track_caller]
pub fn push_str_allow_spaces(&mut self, s: &str) {
debug_assert!(
!self.beginning_of_line,
"push_str: `{s}` with text:\n{}",
self.text
);
debug_assert!(!self.beginning_of_line, "push_str: `{s}`");
self.flush_spaces();
@ -108,11 +104,7 @@ impl<'a> Buf<'a> {
#[track_caller]
pub fn push_str(&mut self, s: &str) {
debug_assert!(
!self.beginning_of_line,
"push_str: `{s}` with text:\n{}",
self.text
);
debug_assert!(!self.beginning_of_line, "push_str: `{s}`");
debug_assert!(!s.contains('\n'));
debug_assert!(!s.ends_with(' '));

View file

@ -95,7 +95,8 @@ fn round_trip_once(input: Input<'_>) -> Option<String> {
let actual = match input.parse_in(&arena) {
Ok(a) => a,
Err(e) => return Some(format!("Initial parse failed: {:?}", e.normalize(&arena))),
Err(_e) => return None,
// Err(e) => return Some(format!("Initial parse failed: {:?}", e.normalize(&arena))),
};
if actual.is_malformed() {

View file

@ -0,0 +1,4 @@
P := p
#
implements []
n

View file

@ -0,0 +1,55 @@
@0-22 SpaceAfter(
Defs(
Defs {
tags: [
EitherIndex(0),
],
regions: [
@0-20,
],
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: [
Opaque {
header: TypeHeader {
name: @0-1 "P",
vars: [],
},
typ: @3-4 BoundVariable(
"p",
),
derived: Some(
@18-20 SpaceBefore(
Implements(
[],
),
[
LineComment(
"",
),
],
),
),
},
],
value_defs: [],
},
@21-22 SpaceBefore(
Var {
module_name: "",
ident: "n",
},
[
Newline,
],
),
),
[
Newline,
],
)

View file

@ -0,0 +1,3 @@
P:=p#
implements[]
n

View file

@ -373,6 +373,7 @@ mod test_snapshots {
pass/crazy_annotation_left.expr,
pass/crazy_annotation_left2.expr,
pass/crazy_backpassing_parens.expr,
pass/crazy_implements_bangs.expr,
pass/crazy_pat_ann.expr,
pass/dbg.expr,
pass/dbg_bang_neg_bang_if_bang.expr,