Get rid of some extra newlines in bpfmt am: d2f1141871

Original change: https://android-review.googlesource.com/c/platform/build/blueprint/+/3007878

Change-Id: I958bf48af64ff4d70b7754dbbaf90345283e849b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Cole Faust 2024-03-20 17:35:28 +00:00 committed by Automerger Merge Worker
commit 6f7c2d8049
2 changed files with 5 additions and 7 deletions

View file

@ -144,6 +144,7 @@ func (p *printer) printSelect(s *Select) {
}
if len(s.Cases) == 1 && s.Cases[0].Pattern.Value == "__soong_conditions_default__" {
p.printExpression(s.Cases[0].Value)
p.pos = s.RBracePos
return
}
p.requestSpace()
@ -317,8 +318,8 @@ func (p *printer) printEndOfLineCommentsBefore(pos scanner.Position) {
if len(p.skippedComments) > 0 {
for _, c := range p.skippedComments {
p.printComment(c)
p._requestNewline()
}
p._requestNewline()
p.skippedComments = nil
}
for p.curComment < len(p.comments) && p.comments[p.curComment].Pos().Line < pos.Line {
@ -406,7 +407,9 @@ func (p *printer) printComment(cg *CommentGroup) {
p._requestNewline()
}
}
p.pos = comment.End()
if p.pos.Offset < comment.End().Offset {
p.pos = comment.End()
}
}
}

View file

@ -281,7 +281,6 @@ module // test
output: `
// test
module { // test
srcs: [
"src1.c",
"src2.c",
@ -356,9 +355,7 @@ test // test
`,
output: `
test { // test
// test
}
`,
},
@ -598,12 +595,10 @@ foo {
}),
}
`,
// TODO(b/323382414): This shouldn't have an empty newline after stuff
output: `
// test
foo {
stuff: "c2", // test2
}
`,
},