Skip to content

Commit 0a0d152

Browse files
committed
Add more tests for anonymous function indenting
1 parent b64018e commit 0a0d152

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

test/indent.vader

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,68 @@ Expect lua (indented chained anonymous function arguments):
5151
self:Func()
5252
end
5353

54+
55+
Given lua (anonymous function as third argument):
56+
local p = self.input:getActiveControls(
57+
5,
58+
10,
59+
function(value)
60+
local name_remap = {
61+
axis = {
62+
left = "Left Stick",
63+
},
64+
}
65+
return name_remap[value] or value
66+
end)
67+
print(p)
68+
69+
70+
Do (reindent):
71+
gg=G
72+
73+
Expect lua (function begin/end line up and body indents):
74+
local p = self.input:getActiveControls(
75+
5,
76+
10,
77+
function(value)
78+
local name_remap = {
79+
axis = {
80+
left = "Left Stick",
81+
},
82+
}
83+
return name_remap[value] or value
84+
end)
85+
print(p)
86+
87+
88+
Do (put first arg on call line):
89+
gggJ=G
90+
91+
Expect lua (indented function more than first newline argument):
92+
local p = self.input:getActiveControls(5,
93+
10,
94+
function(value)
95+
local name_remap = {
96+
axis = {
97+
left = "Left Stick",
98+
},
99+
}
100+
return name_remap[value] or value
101+
end)
102+
print(p)
103+
104+
105+
Do (put all args on one line):
106+
ggJx3J=G
107+
108+
Expect lua (function indent combines with parens indent):
109+
local p = self.input:getActiveControls(5, 10, function(value)
110+
local name_remap = {
111+
axis = {
112+
left = "Left Stick",
113+
},
114+
}
115+
return name_remap[value] or value
116+
end)
117+
print(p)
118+

0 commit comments

Comments
 (0)