Better wrapping on comma
This commit is contained in:
parent
50216e52a9
commit
5de6deae99
@ -236,6 +236,7 @@ function Param.new(pair, opt)
|
|||||||
offset = nil,
|
offset = nil,
|
||||||
start = nil,
|
start = nil,
|
||||||
stop = nil,
|
stop = nil,
|
||||||
|
terminator = nil,
|
||||||
}
|
}
|
||||||
|
|
||||||
return setmetatable(param, Param)
|
return setmetatable(param, Param)
|
||||||
@ -258,6 +259,13 @@ function Param:append(char, cursor)
|
|||||||
self.stop = cursor
|
self.stop = cursor
|
||||||
end
|
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()
|
function Param:is_active()
|
||||||
return self.offset ~= nil
|
return self.offset ~= nil
|
||||||
end
|
end
|
||||||
@ -334,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
|
||||||
@ -347,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