fmt: fix inserted empty line before go stmt with anonymus function (#8951)
							parent
							
								
									12a4e7ad90
								
							
						
					
					
						commit
						7e27920cf7
					
				|  | @ -1340,12 +1340,9 @@ pub fn (stmt Stmt) position() token.Position { | |||
| 	match stmt { | ||||
| 		AssertStmt, AssignStmt, Block, BranchStmt, CompFor, ConstDecl, DeferStmt, EnumDecl, ExprStmt, | ||||
| 		FnDecl, ForCStmt, ForInStmt, ForStmt, GotoLabel, GotoStmt, Import, Return, StructDecl, | ||||
| 		GlobalDecl, HashStmt, InterfaceDecl, Module, SqlStmt { | ||||
| 		GlobalDecl, HashStmt, InterfaceDecl, Module, SqlStmt, GoStmt { | ||||
| 			return stmt.pos | ||||
| 		} | ||||
| 		GoStmt { | ||||
| 			return stmt.call_expr.pos | ||||
| 		} | ||||
| 		TypeDecl { | ||||
| 			match stmt { | ||||
| 				AliasTypeDecl, FnTypeDecl, SumTypeDecl { return stmt.pos } | ||||
|  |  | |||
|  | @ -310,7 +310,7 @@ pub fn (f Fmt) imp_stmt_str(imp ast.Import) string { | |||
| 	return '$imp.mod$imp_alias_suffix' | ||||
| } | ||||
| 
 | ||||
| fn (mut f Fmt) should_insert_newline_before_stmt(stmt ast.Stmt, prev_stmt ast.Stmt) bool { | ||||
| fn (f Fmt) should_insert_newline_before_stmt(stmt ast.Stmt, prev_stmt ast.Stmt) bool { | ||||
| 	prev_line_nr := prev_stmt.position().last_line | ||||
| 	// No need to insert a newline if there is already one
 | ||||
| 	if f.out.last_n(2) == '\n\n' { | ||||
|  |  | |||
|  | @ -0,0 +1,9 @@ | |||
| import sync | ||||
| 
 | ||||
| fn go_with_anon_fn() { | ||||
| 	wg.add(1) | ||||
| 	go fn (mut wg sync.WaitGroup) { | ||||
| 		wg.done() | ||||
| 	}(mut wg) | ||||
| 	wg.wait() | ||||
| } | ||||
|  | @ -779,7 +779,7 @@ pub fn (mut p Parser) stmt(is_top_level bool) ast.Stmt { | |||
| 			} | ||||
| 			return ast.GoStmt{ | ||||
| 				call_expr: call_expr | ||||
| 				pos: spos.extend(p.tok.position()) | ||||
| 				pos: spos.extend(p.prev_tok.position()) | ||||
| 			} | ||||
| 		} | ||||
| 		.key_goto { | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue