fmt: fix comment handling on ending of struct decl (fix #23947) (#23948)

This commit is contained in:
Felipe Pena 2025-03-17 11:32:29 -03:00 committed by GitHub
parent 5978cbcfbf
commit cb4d16ff3a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 17 additions and 1 deletions

View File

@ -351,7 +351,6 @@ pub:
option_pos token.Pos
pre_comments []Comment
comments []Comment
next_comments []Comment
i int
has_default_expr bool
has_prev_newline bool
@ -365,6 +364,7 @@ pub:
is_deprecated bool
is_embed bool
pub mut:
next_comments []Comment
is_recursive bool
is_part_of_union bool
container_typ Type

View File

@ -0,0 +1,11 @@
module main
pub struct CSDL_GamepadBinding {
pub mut:
output_type u8
// TODO: BELONGS ABOVE // union {
// SDL_GamepadButton button; struct {
// SDL_GamepadAxis axis; int axis_min; int axis_max; } axis; } output
}
pub type GamepadBinding = CSDL_GamepadBinding

View File

@ -212,6 +212,11 @@ fn (mut p Parser) struct_decl(is_anon bool) ast.StructDecl {
mut field_pos := token.Pos{}
mut option_pos := token.Pos{}
if p.tok.kind == .rcbr {
ast_fields.last().next_comments << pre_field_comments
break
}
if is_embed {
// struct embedding
type_pos = p.tok.pos()