diff --git a/lib/std/zig/Ast/Render.zig b/lib/std/zig/Ast/Render.zig index 19abada490..7d367805d4 100644 --- a/lib/std/zig/Ast/Render.zig +++ b/lib/std/zig/Ast/Render.zig @@ -3326,6 +3326,7 @@ fn renderComments(r: *Render, start: usize, end: usize) Error!bool { // Write with the canonical single space. try ais.underlying_writer.writeAll("// zig fmt: on\n"); ais.disabled_offset = null; + ais.resetLine(); } else if (ais.disabled_offset == null and mem.eql(u8, comment_content, "zig fmt: off")) { // Write with the canonical single space. try ais.writeAll("// zig fmt: off\n"); diff --git a/lib/std/zig/parser_test.zig b/lib/std/zig/parser_test.zig index bc9256f1dd..7a6dc3f2f2 100644 --- a/lib/std/zig/parser_test.zig +++ b/lib/std/zig/parser_test.zig @@ -6871,6 +6871,16 @@ test "zig fmt: nested asm indentation" { ); } +test "zig fmt: asm with zig fmt on" { + try testCanonical( + \\// zig fmt: off + \\const A = asm("a" // zig fmt: on + \\ : [_] "" (_), + \\); + \\ + ); +} + test "recovery: top level" { try testError( \\test "" {inline}