1

Text stripping

This commit is contained in:
Alex Yatskov 2024-05-02 18:10:16 -07:00
parent ca45fc2fdb
commit 75cc3a3cb5

View File

@ -275,6 +275,22 @@ function Param:strip()
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)
local text = ''
local cursors = {}
for i = 1, #self.text do
local char = self.text:sub(i, i)
local cursor = self.cursors[i]
if cursor:is_literal() or not char:match('%s') or not text:match('%s$') then
text = text .. char
table.insert(cursors, cursor)
end
end
self.text = text
self.cursors = cursors
return #self.text > 0 return #self.text > 0
end end