Skip to content

Commit

Permalink
parser: fix block position's last line
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyi98 committed Nov 19, 2024
1 parent faac1fd commit 4cf90d0
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vlib/v/fmt/fmt.v
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ fn (f &Fmt) should_insert_newline_before_node(node ast.Node, prev_node ast.Node)
return false
}
ast.Block {
if node is ast.Block && !node.is_unsafe && node.pos.line_nr - prev_line_nr > 0 {
if node is ast.Block && !node.is_unsafe && node.pos.line_nr - prev_line_nr > 1 {
return true
} else {
return false
Expand Down
2 changes: 1 addition & 1 deletion vlib/v/parser/parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ fn (mut p Parser) stmt(is_top_level bool) ast.Stmt {
}
} else {
stmts := p.parse_block()
pos.last_line = p.prev_tok.line_nr
pos.update_last_line(p.prev_tok.line_nr)
return ast.Block{
stmts: stmts
pos: pos
Expand Down

0 comments on commit 4cf90d0

Please sign in to comment.