fmt: trim space in embedded comments (#7521)

pull/7534/head^2
zakuro 2020-12-24 19:57:48 +09:00 committed by GitHub
parent 9d1365ec67
commit fec9f1324c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -1228,7 +1228,7 @@ pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
f.writeln(x)
f.write('*/')
} else {
f.write('/* $x */')
f.write('/* ${x.trim(' ')} */')
}
return
}

View File

@ -18,6 +18,10 @@ fn main() {
d := c // and an extra one
e := c
// more comments = more good
arr := [
/* block foo bar */ /* inline foo bar */
0,
]
// before arg comment
// after arg comment
println('this is a test')

View File

@ -12,6 +12,11 @@ fn main() {
d := c // and an extra one
e := c
// more comments = more good
arr := [
/* block foo bar */
// inline foo bar
0,
]
println(/* before arg comment */ 'this is a test' /* after arg comment */)
if /* before if expr */ true /* after if expr */ {
println('if')