fix(wgsl): indent first parameter of function definition

This commit is contained in:
Riley Bruins 2024-11-03 21:13:52 -08:00 committed by Christian Clason
parent 7dc8aabe86
commit 0d3426a2e8
3 changed files with 37 additions and 2 deletions

View file

@ -1,10 +1,23 @@
[
(parameter_list)
(compound_statement)
(loop_statement)
(struct_declaration)
] @indent.begin
((parameter_list) @indent.begin
(#set! indent.immediate)
(#set! indent.start_at_same_line))
(function_declaration
"(" @indent.begin
(#set! indent.immediate))
(ERROR
"fn"
(identifier)
"(" @indent.begin
(#set! indent.immediate))
(compound_statement
"}" @indent.end)

View file

@ -41,3 +41,20 @@ fn vertex(vertex: Vertex,
out.b = 2;
return out;
}
fn foo(
a: u32,
b: u32,
) {
return a;
}
fn bar(
) {}
fn baz(
a: u32,
) {}
fn qux(
)

View file

@ -15,5 +15,10 @@ describe("indent WGSL:", function()
})
end)
describe("new line:", function() end)
describe("new line:", function()
run:new_line("basic.wgsl", { on_line = 47, text = "c: u32,", indent = 2 })
run:new_line("basic.wgsl", { on_line = 52, text = "c: u32,", indent = 2 })
run:new_line("basic.wgsl", { on_line = 56, text = "c: u32,", indent = 2 })
run:new_line("basic.wgsl", { on_line = 59, text = "c: u32,", indent = 2 })
end)
end)