From ed3ca0f570e052adbed291a79e9a11bba5d3f7d0 Mon Sep 17 00:00:00 2001 From: Kendall Condon Date: Sun, 22 Mar 2026 17:29:03 -0400 Subject: [PATCH] zig fmt: call ais.resetLine after "zig fmt: on" --- lib/std/zig/Ast/Render.zig | 1 + lib/std/zig/parser_test.zig | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/std/zig/Ast/Render.zig b/lib/std/zig/Ast/Render.zig index 19abada4906223e4ede8841021d277f43df5de7b..7d367805d4896d8aea08da54adfa517abbe3b329 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 bc9256f1ddc0e9e0a2d004071533ea5aa2ba7e75..7a6dc3f2f2d4edad3c4f74582313e3d14bc6e455 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} -- 2.54.0