Cleanup
This commit is contained in:
parent
9946a69217
commit
139d34a8c6
@ -207,7 +207,6 @@ local function parse_brace_range(brace_range)
|
|||||||
local pad_newline = false
|
local pad_newline = false
|
||||||
|
|
||||||
for row = brace_range.row1, brace_range.row2 do
|
for row = brace_range.row1, brace_range.row2 do
|
||||||
local lead_padding = true
|
|
||||||
local line = vim.fn.getline(row)
|
local line = vim.fn.getline(row)
|
||||||
|
|
||||||
local col1 = 1
|
local col1 = 1
|
||||||
@ -220,28 +219,30 @@ local function parse_brace_range(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 lead_padding then
|
if indenting then
|
||||||
if char:match('%s') then
|
if char:match('%s') then
|
||||||
if pad_newline and col == col1 then
|
if pad_newline and col == col1 then
|
||||||
char = ' '
|
char = ' '
|
||||||
else
|
else
|
||||||
char = nil
|
padding = true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
lead_padding = false
|
indenting = false
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if char then
|
|
||||||
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}),
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -252,12 +253,11 @@ local function parse_brace_range(brace_range)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
if #brace_range_elements > 0 then
|
if #brace_range_elements > 0 then
|
||||||
for _, brace_range_element in ipairs(brace_range_elements) do
|
for _, brace_range_element in ipairs(brace_range_elements) do
|
||||||
local append = true
|
local append = not brace_range_element.padding
|
||||||
if not brace_range_element.literal then
|
if append and 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()
|
||||||
|
Loading…
Reference in New Issue
Block a user