commit ed3ca0f570e052adbed291a79e9a11bba5d3f7d0 (tree)
parent d70a9ea5d759fd5e61c8cd7404343c34280fe87e
Author: Kendall Condon <goon.pri.low@gmail.com>
Date: Sun, 22 Mar 2026 17:29:03 -0400
zig fmt: call ais.resetLine after "zig fmt: on"
Diffstat:
2 files changed, 11 insertions(+), 0 deletions(-)
diff --git 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
@@ -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}