mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: fix missing space after single line array pre comments (#8904)
This commit is contained in:
parent
fb028abc71
commit
7f6c4caa01
@ -255,7 +255,7 @@ pub fn (x Expr) str() string {
|
||||
return '/* $lines.len lines comment */'
|
||||
} else {
|
||||
text := x.text.trim('\x01').trim_space()
|
||||
return '// $text'
|
||||
return '´// $text´'
|
||||
}
|
||||
}
|
||||
ComptimeSelector {
|
||||
|
@ -1970,9 +1970,14 @@ pub fn (mut f Fmt) array_init(it ast.ArrayInit) {
|
||||
f.comment(c, level: .indent, iembed: true)
|
||||
last_line_nr = c.pos.last_line
|
||||
}
|
||||
if it.exprs.len == 0 && it.pre_cmnts.len > 0 && it.pre_cmnts[0].pos.line_nr != it.pos.line_nr {
|
||||
if it.pre_cmnts.len > 0 {
|
||||
same_line := it.pre_cmnts[0].pos.line_nr == it.pos.line_nr
|
||||
if same_line && it.exprs.len > 0 {
|
||||
f.write(' ')
|
||||
} else if !same_line && it.exprs.len == 0 {
|
||||
f.writeln('')
|
||||
}
|
||||
}
|
||||
for i, expr in it.exprs {
|
||||
line_nr := expr.position().line_nr
|
||||
if i == 0 {
|
||||
|
@ -10,3 +10,8 @@ fn only_comments_array() {
|
||||
/* 4, */
|
||||
]
|
||||
}
|
||||
|
||||
fn array_pre_comments() {
|
||||
_ := [/* 2, */ 3]
|
||||
_ := [/* 4, */ /* 5, */ 6]
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user