mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
Fix formatting for multiline asm expressions
This commit is contained in:
parent
66d86eccbe
commit
08d41da916
@ -2129,6 +2129,47 @@ test "zig fmt: comptime block in container" {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "zig fmt: inline asm parameter alignment" {
|
||||||
|
try testCanonical(
|
||||||
|
\\pub fn main() void {
|
||||||
|
\\ asm volatile (
|
||||||
|
\\ \\ foo
|
||||||
|
\\ \\ bar
|
||||||
|
\\ );
|
||||||
|
\\ asm volatile (
|
||||||
|
\\ \\ foo
|
||||||
|
\\ \\ bar
|
||||||
|
\\ : [_] "" (-> usize),
|
||||||
|
\\ [_] "" (-> usize)
|
||||||
|
\\ );
|
||||||
|
\\ asm volatile (
|
||||||
|
\\ \\ foo
|
||||||
|
\\ \\ bar
|
||||||
|
\\ :
|
||||||
|
\\ : [_] "" (0),
|
||||||
|
\\ [_] "" (0)
|
||||||
|
\\ );
|
||||||
|
\\ asm volatile (
|
||||||
|
\\ \\ foo
|
||||||
|
\\ \\ bar
|
||||||
|
\\ :
|
||||||
|
\\ :
|
||||||
|
\\ : "", ""
|
||||||
|
\\ );
|
||||||
|
\\ asm volatile (
|
||||||
|
\\ \\ foo
|
||||||
|
\\ \\ bar
|
||||||
|
\\ : [_] "" (-> usize),
|
||||||
|
\\ [_] "" (-> usize)
|
||||||
|
\\ : [_] "" (0),
|
||||||
|
\\ [_] "" (0)
|
||||||
|
\\ : "", ""
|
||||||
|
\\ );
|
||||||
|
\\}
|
||||||
|
\\
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const std = @import("std");
|
const std = @import("std");
|
||||||
const mem = std.mem;
|
const mem = std.mem;
|
||||||
const warn = std.debug.warn;
|
const warn = std.debug.warn;
|
||||||
|
|||||||
@ -1549,7 +1549,14 @@ fn renderExpression(
|
|||||||
try renderExpression(allocator, stream, tree, indent, start_col, asm_node.template, Space.Newline);
|
try renderExpression(allocator, stream, tree, indent, start_col, asm_node.template, Space.Newline);
|
||||||
|
|
||||||
const indent_once = indent + indent_delta;
|
const indent_once = indent + indent_delta;
|
||||||
|
|
||||||
|
if (asm_node.template.id == ast.Node.Id.MultilineStringLiteral) {
|
||||||
|
// After rendering a multiline string literal the cursor is
|
||||||
|
// already offset by indent
|
||||||
|
try stream.writeByteNTimes(' ', indent_delta);
|
||||||
|
} else {
|
||||||
try stream.writeByteNTimes(' ', indent_once);
|
try stream.writeByteNTimes(' ', indent_once);
|
||||||
|
}
|
||||||
|
|
||||||
const colon1 = tree.nextToken(asm_node.template.lastToken());
|
const colon1 = tree.nextToken(asm_node.template.lastToken());
|
||||||
const indent_extra = indent_once + 2;
|
const indent_extra = indent_once + 2;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user