Include brace range inside of ParamList
This commit is contained in:
parent
cfafbb7e14
commit
a027e9c16e
@ -262,8 +262,9 @@ end
|
|||||||
local ParamList = {}
|
local ParamList = {}
|
||||||
ParamList.__index = ParamList
|
ParamList.__index = ParamList
|
||||||
|
|
||||||
function ParamList.new()
|
function ParamList.new(range)
|
||||||
local params = {
|
local params = {
|
||||||
|
range = range,
|
||||||
current = nil,
|
current = nil,
|
||||||
parsed = {},
|
parsed = {},
|
||||||
}
|
}
|
||||||
@ -280,7 +281,7 @@ function ParamList:flush()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ParamList:update(char, brace_stack, range, cursor)
|
function ParamList:update(char, brace_stack, cursor)
|
||||||
if not cursor:is_string() then
|
if not cursor:is_string() then
|
||||||
brace_stack:update(char)
|
brace_stack:update(char)
|
||||||
if brace_stack:empty() and char == ',' then
|
if brace_stack:empty() and char == ',' then
|
||||||
@ -292,7 +293,7 @@ function ParamList:update(char, brace_stack, range, cursor)
|
|||||||
if self.current then
|
if self.current then
|
||||||
self.current:append(char)
|
self.current:append(char)
|
||||||
else
|
else
|
||||||
self.current = Param.new(char, range)
|
self.current = Param.new(char, self.range)
|
||||||
end
|
end
|
||||||
|
|
||||||
if cursor == Cursor.get_current() then
|
if cursor == Cursor.get_current() then
|
||||||
@ -300,24 +301,24 @@ function ParamList:update(char, brace_stack, range, cursor)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function ParamList:parse(range)
|
function ParamList:parse()
|
||||||
local brace_stack = BraceStack:new()
|
local brace_stack = BraceStack:new()
|
||||||
|
|
||||||
for row = range.start.row, range.stop.row do
|
for row = self.range.start.row, self.range.stop.row do
|
||||||
local line = vim.fn.getline(row)
|
local line = vim.fn.getline(row)
|
||||||
|
|
||||||
local start_col = 1
|
local start_col = 1
|
||||||
if row == range.start.row then
|
if row == self.range.start.row then
|
||||||
start_col = range.start.col + 1
|
start_col = self.range.start.col + 1
|
||||||
end
|
end
|
||||||
|
|
||||||
local stop_col = #line
|
local stop_col = #line
|
||||||
if row == range.stop.row then
|
if row == self.range.stop.row then
|
||||||
stop_col = range.stop.col - 1
|
stop_col = self.range.stop.col - 1
|
||||||
end
|
end
|
||||||
|
|
||||||
for col = start_col, stop_col do
|
for col = start_col, stop_col do
|
||||||
self:update(line:sub(col, col), brace_stack, range, Cursor.new(row, col))
|
self:update(line:sub(col, col), brace_stack, Cursor.new(row, col))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -357,8 +358,8 @@ function WrapContext:parse()
|
|||||||
local last_line = vim.fn.getline(self.range.stop.row)
|
local last_line = vim.fn.getline(self.range.stop.row)
|
||||||
self.suffix = last_line:sub(self.range.stop.col)
|
self.suffix = last_line:sub(self.range.stop.col)
|
||||||
|
|
||||||
self.params = ParamList.new()
|
self.params = ParamList.new(self.range)
|
||||||
self.params:parse(self.range)
|
self.params:parse()
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user