fmt: remove tail space when using multiline short arg (#9110)

pull/9111/head
zakuro 2021-03-04 19:44:50 +09:00 committed by GitHub
parent 8ce53b8b55
commit 6b2c7fd53e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 2 deletions

View File

@ -2176,6 +2176,14 @@ pub fn (mut f Fmt) struct_init(node ast.StructInit) {
fields_start := f.out.len
fields_loop: for {
if !single_line_fields {
if use_short_args && f.out.buf[f.out.buf.len - 1] == ` ` {
// v Remove space at tail of line
// f(a, b, c, \n
// f1: 0\n
// f2: 1\n
// )
f.out.go_back(1)
}
f.writeln('')
f.indent++
}

View File

@ -6,6 +6,7 @@ struct Bar {
struct Baz {
x int
y int
}
fn main() {
@ -18,8 +19,13 @@ fn main() {
x: 'some string'
b: Baz{
x: 0
y: 0
}
)
baz_func('foo', 'bar',
x: 0
y: 0
)
ui.row(
// stretch: true
margin: {
@ -33,3 +39,5 @@ fn main() {
fn bar_func(bar Bar) {
}
fn baz_func(a string, b string, baz Baz) {}

View File

@ -6,6 +6,7 @@ struct Bar {
struct Baz {
x int
y int
}
fn main() {
@ -13,7 +14,11 @@ fn main() {
bar_func(x: 'a very long content should cause vfmt to use multiple lines instead of one.', y: 123456789)
bar_func(x: 'some string', b: Baz{
x: 0
y: 0
})
baz_func('foo', 'bar', x: 0
y: 0
)
ui.row({
//stretch: true
margin: {top:10,left:10,right:10,bottom:10}
@ -22,3 +27,5 @@ fn main() {
fn bar_func(bar Bar) {
}
fn baz_func(a string, b string, baz Baz) {}