fmt: remove trailing space in comments (#9620)
parent
6d77c8821b
commit
1d5ed89138
|
@ -44,7 +44,7 @@ pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
|
||||||
}
|
}
|
||||||
} else if !node.text.contains('\n') {
|
} else if !node.text.contains('\n') {
|
||||||
is_separate_line := !options.inline || node.text.starts_with('\x01')
|
is_separate_line := !options.inline || node.text.starts_with('\x01')
|
||||||
mut s := node.text.trim_left('\x01')
|
mut s := node.text.trim_left('\x01').trim_right(' ')
|
||||||
mut out_s := '//'
|
mut out_s := '//'
|
||||||
if s != '' {
|
if s != '' {
|
||||||
if is_char_alphanumeric(s[0]) {
|
if is_char_alphanumeric(s[0]) {
|
||||||
|
@ -67,7 +67,7 @@ pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
|
||||||
f.writeln('')
|
f.writeln('')
|
||||||
}
|
}
|
||||||
for line in lines {
|
for line in lines {
|
||||||
f.writeln(line)
|
f.writeln(line.trim_right(' '))
|
||||||
f.empty_line = false
|
f.empty_line = false
|
||||||
}
|
}
|
||||||
if end_break {
|
if end_break {
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
// NB: The input file has and *should* have trailing spaces.
|
||||||
|
// When making changes, please ensure these spaces are not removed.
|
||||||
|
|
||||||
|
fn comments_with_trailing_space() {
|
||||||
|
// two spaces on the right
|
||||||
|
/*
|
||||||
|
spaces after here
|
||||||
|
and everywhere :)
|
||||||
|
*/
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
// NB: The input file has and *should* have trailing spaces.
|
||||||
|
// When making changes, please ensure these spaces are not removed.
|
||||||
|
|
||||||
|
fn comments_with_trailing_space() {
|
||||||
|
// two spaces on the right
|
||||||
|
/*
|
||||||
|
spaces after here
|
||||||
|
and everywhere :)
|
||||||
|
*/
|
||||||
|
}
|
Loading…
Reference in New Issue