Compare commits
2 Commits
9d241775a9
...
5de6deae99
Author | SHA1 | Date | |
---|---|---|---|
5de6deae99 | |||
50216e52a9 |
@ -234,6 +234,9 @@ function Param.new(pair, opt)
|
||||
text = '',
|
||||
literals = {},
|
||||
offset = nil,
|
||||
start = nil,
|
||||
stop = nil,
|
||||
terminator = nil,
|
||||
}
|
||||
|
||||
return setmetatable(param, Param)
|
||||
@ -248,6 +251,19 @@ function Param:append(char, cursor)
|
||||
if cursor == Cursor.get_current() then
|
||||
self.offset = #self.text
|
||||
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
|
||||
|
||||
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: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)
|
||||
end
|
||||
|
||||
@ -326,11 +342,16 @@ function ParamList.new(range, opt)
|
||||
return setmetatable(params, ParamList)
|
||||
end
|
||||
|
||||
function ParamList:flush()
|
||||
function ParamList:flush(cursor)
|
||||
if self.current then
|
||||
if cursor then
|
||||
self.current:terminate(cursor)
|
||||
end
|
||||
|
||||
if self.current:trim() then
|
||||
table.insert(self.parsed, self.current)
|
||||
end
|
||||
|
||||
self.current = nil
|
||||
end
|
||||
end
|
||||
@ -339,7 +360,7 @@ function ParamList:update(char, brace_stack, cursor)
|
||||
if not cursor:is_literal() then
|
||||
brace_stack:update(char)
|
||||
if brace_stack:empty() and char == ',' then
|
||||
self:flush()
|
||||
self:flush(cursor)
|
||||
return
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user