1
This commit is contained in:
Alex Yatskov 2024-01-21 20:10:40 -08:00
parent 5410200d69
commit 192b09345c

View File

@ -227,44 +227,22 @@ local function parse_brace_range_params(brace_range)
col2 = brace_range.col2 - 1 col2 = brace_range.col2 - 1
end end
local indenting = true
for col = col1, col2 do for col = col1, col2 do
local char = line:sub(col, col) local char = line:sub(col, col)
local padding = false
assert(#char > 0) assert(#char > 0)
if indenting then
if char:match('%s') then
if pad_newline and col == col1 then
char = ' '
else
padding = true
end
else
indenting = false
end
end
table.insert(brace_range_elements, { table.insert(brace_range_elements, {
row = row, row = row,
col = col, col = col,
char = char, char = char,
brace = brace_range.brace, brace = brace_range.brace,
padding = padding,
literal = is_string_literal({row = row, col = col}), literal = is_string_literal({row = row, col = col}),
}) })
if char == ',' then
pad_newline = true
else
pad_newline = false
end
end end
end end
for _, brace_range_element in ipairs(brace_range_elements) do for _, brace_range_element in ipairs(brace_range_elements) do
local append = not brace_range_element.padding local append = true
if append and not brace_range_element.literal then if not brace_range_element.literal then
update_brace_stack(brace_range_element.char) update_brace_stack(brace_range_element.char)
if #brace_stack == 0 and brace_range_element.char == ',' then if #brace_stack == 0 and brace_range_element.char == ',' then
flush_brace_range_param() flush_brace_range_param()