vfmt: fix bug where duplicated comma is placed before comment in array init (#12281)
							parent
							
								
									47a2301139
								
							
						
					
					
						commit
						242b99340d
					
				|  | @ -1460,7 +1460,8 @@ pub fn (mut f Fmt) array_init(node ast.ArrayInit) { | |||
| 					if cmt.is_inline { | ||||
| 						f.write(' ') | ||||
| 						f.comment(cmt, iembed: true) | ||||
| 						if cmt.pos.line_nr == expr_pos.last_line && cmt.pos.pos < expr_pos.pos { | ||||
| 						if !set_comma && cmt.pos.line_nr == expr_pos.last_line | ||||
| 							&& cmt.pos.pos < expr_pos.pos { | ||||
| 							f.write(',') | ||||
| 							set_comma = true | ||||
| 						} else { | ||||
|  | @ -1471,9 +1472,12 @@ pub fn (mut f Fmt) array_init(node ast.ArrayInit) { | |||
| 							} | ||||
| 						} | ||||
| 					} else { | ||||
| 						f.write(', ') | ||||
| 						if !set_comma { | ||||
| 							f.write(',') | ||||
| 							set_comma = true | ||||
| 						} | ||||
| 						f.write(' ') | ||||
| 						f.comment(cmt, iembed: false) | ||||
| 						set_comma = true | ||||
| 					} | ||||
| 				} | ||||
| 				last_comment_was_inline = cmt.is_inline | ||||
|  |  | |||
|  | @ -0,0 +1,9 @@ | |||
| v := [ | ||||
| 	0, // 0
 | ||||
| 	1, // 1
 | ||||
| 	2, // 2
 | ||||
| 	// 2-3
 | ||||
| 	3, // 3
 | ||||
| 	// 4
 | ||||
| 	// 5
 | ||||
| ] | ||||
|  | @ -0,0 +1,9 @@ | |||
| v := [ | ||||
| 	0// 0
 | ||||
| 	1      // 1
 | ||||
|   2,// 2
 | ||||
| 	// 2-3
 | ||||
|   3,      // 3
 | ||||
| 	// 4
 | ||||
| 	/* 5 */ | ||||
| ] | ||||
		Loading…
	
		Reference in New Issue