fmt: remove tail space when using multiline short arg (#9110)
							parent
							
								
									8ce53b8b55
								
							
						
					
					
						commit
						6b2c7fd53e
					
				| 
						 | 
				
			
			@ -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++
 | 
			
		||||
			}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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) {}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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) {}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue