1

Better wrapping on comma

This commit is contained in:
Alex Yatskov 2024-05-04 10:27:52 -07:00
parent 50216e52a9
commit 5de6deae99

View File

@ -236,6 +236,7 @@ function Param.new(pair, opt)
offset = nil,
start = nil,
stop = nil,
terminator = nil,
}
return setmetatable(param, Param)
@ -258,6 +259,13 @@ function Param:append(char, cursor)
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()
return self.offset ~= nil
end
@ -334,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
@ -347,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