mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-04-27 19:09:47 +03:00
zig fmt: properly revert nested asm indentation
This commit is contained in:
@@ -2775,6 +2775,8 @@ fn renderAsm(
|
||||
ais.forceLastIndent(); // Might have been dedented by a multiline string literal
|
||||
assert(ais.current_line_empty);
|
||||
|
||||
const prev_indent_delta = ais.indent_delta; // May be part of another asm expression
|
||||
// so indent_delta can't be unconditionally used
|
||||
ais.setIndentDelta(asm_indent_delta);
|
||||
const colon1 = tree.lastToken(asm_node.ast.template) + 1;
|
||||
|
||||
@@ -2856,7 +2858,7 @@ fn renderAsm(
|
||||
const clobbers = asm_node.ast.clobbers.unwrap().?;
|
||||
try renderExpression(r, clobbers, .none);
|
||||
ais.forceLastIndent(); // Might have been dedented by a multiline string literal
|
||||
ais.setIndentDelta(indent_delta);
|
||||
ais.setIndentDelta(prev_indent_delta);
|
||||
ais.popIndent();
|
||||
return renderToken(r, asm_node.ast.rparen, space); // rparen
|
||||
}
|
||||
|
||||
@@ -6859,6 +6859,18 @@ test "zig fmt: array init of labeled block" {
|
||||
);
|
||||
}
|
||||
|
||||
test "zig fmt: nested asm indentation" {
|
||||
try testCanonical(
|
||||
\\const A = asm (""
|
||||
\\ : [_] "" (_),
|
||||
\\ :
|
||||
\\ : asm (""
|
||||
\\ : [_] "" (_),
|
||||
\\ ));
|
||||
\\
|
||||
);
|
||||
}
|
||||
|
||||
test "recovery: top level" {
|
||||
try testError(
|
||||
\\test "" {inline}
|
||||
|
||||
Reference in New Issue
Block a user