Compare commits
2 Commits
9d241775a9
...
5de6deae99
Author | SHA1 | Date | |
---|---|---|---|
5de6deae99 | |||
50216e52a9 |
@ -234,6 +234,9 @@ function Param.new(pair, opt)
|
|||||||
text = '',
|
text = '',
|
||||||
literals = {},
|
literals = {},
|
||||||
offset = nil,
|
offset = nil,
|
||||||
|
start = nil,
|
||||||
|
stop = nil,
|
||||||
|
terminator = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(param, Param)
|
return setmetatable(param, Param)
|
||||||
@ -248,6 +251,19 @@ function Param:append(char, cursor)
|
|||||||
if cursor == Cursor.get_current() then
|
if cursor == Cursor.get_current() then
|
||||||
self.offset = #self.text
|
self.offset = #self.text
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not self.start then
|
||||||
|
self.start = cursor
|
||||||
|
end
|
||||||
|
|
||||||
|
self.stop = cursor
|
||||||
|
end
|
||||||
|
|
||||||
|
function Param:terminate(cursor)
|
||||||
|
self.terminator = cursor
|
||||||
|
if self.terminator == Cursor.get_current() then
|
||||||
|
self.offset = #self.text
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Param:is_active()
|
function Param:is_active()
|
||||||
@ -280,7 +296,7 @@ function Param:trim()
|
|||||||
self:slice(1, #self.text - #self.text:match('%s*$'))
|
self:slice(1, #self.text - #self.text:match('%s*$'))
|
||||||
self:slice(1 + #self.text:match('^%s*'), #self.text)
|
self:slice(1 + #self.text:match('^%s*'), #self.text)
|
||||||
|
|
||||||
if #self.opt.line_prefix > 0 and self.text:match('^' .. self.opt.line_prefix) then
|
if self.text:match('^' .. self.opt.line_prefix) then
|
||||||
self:slice(1 + #self.opt.line_prefix, #self.text)
|
self:slice(1 + #self.opt.line_prefix, #self.text)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -290,7 +306,7 @@ function Param:trim()
|
|||||||
local offset = self.offset
|
local offset = self.offset
|
||||||
|
|
||||||
for i = 1, #self.text do
|
for i = 1, #self.text do
|
||||||
local char = self.text:sub(i, i)
|
local char = self.text:sub(i, i)
|
||||||
local literal = self.literals[i]
|
local literal = self.literals[i]
|
||||||
|
|
||||||
if literal or not char:match('%s') or not text:match('%s$') then
|
if literal or not char:match('%s') or not text:match('%s$') then
|
||||||
@ -326,11 +342,16 @@ function ParamList.new(range, opt)
|
|||||||
return setmetatable(params, ParamList)
|
return setmetatable(params, ParamList)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ParamList:flush()
|
function ParamList:flush(cursor)
|
||||||
if self.current then
|
if self.current then
|
||||||
|
if cursor then
|
||||||
|
self.current:terminate(cursor)
|
||||||
|
end
|
||||||
|
|
||||||
if self.current:trim() then
|
if self.current:trim() then
|
||||||
table.insert(self.parsed, self.current)
|
table.insert(self.parsed, self.current)
|
||||||
end
|
end
|
||||||
|
|
||||||
self.current = nil
|
self.current = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -339,7 +360,7 @@ function ParamList:update(char, brace_stack, cursor)
|
|||||||
if not cursor:is_literal() then
|
if not cursor:is_literal() then
|
||||||
brace_stack:update(char)
|
brace_stack:update(char)
|
||||||
if brace_stack:empty() and char == ',' then
|
if brace_stack:empty() and char == ',' then
|
||||||
self:flush()
|
self:flush(cursor)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user