diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index db403e30084324..66cac0d42e594b 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -443,13 +443,6 @@ fn (f &Fmt) should_insert_newline_before_node(node ast.Node, prev_node ast.Node) ast.Import { return false } - ast.Block { - if node is ast.Block && !node.is_unsafe && node.pos.line_nr - prev_line_nr > 0 { - return true - } else { - return false - } - } ast.ConstDecl { if node !is ast.ConstDecl && !(node is ast.ExprStmt && node.expr is ast.Comment) { return true diff --git a/vlib/v/fmt/tests/block_with_blank_line_keep.vv b/vlib/v/fmt/tests/block_with_blank_line_keep.vv new file mode 100644 index 00000000000000..07f04d286d9574 --- /dev/null +++ b/vlib/v/fmt/tests/block_with_blank_line_keep.vv @@ -0,0 +1,8 @@ +fn main() { + { + println('(1/3) My first small scope') + // + } + + println('hello') +} diff --git a/vlib/v/parser/parser.v b/vlib/v/parser/parser.v index 70feb1ea520dbf..2b3122d333f720 100644 --- a/vlib/v/parser/parser.v +++ b/vlib/v/parser/parser.v @@ -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