diff --git a/lua/argonaut/types.lua b/lua/argonaut/types.lua index 57df519..b46a80c 100644 --- a/lua/argonaut/types.lua +++ b/lua/argonaut/types.lua @@ -255,7 +255,7 @@ function Param:slice(start, stop) local text = '' local cursors = {} - for i = start,stop do + for i = start, stop do text = text .. self.text:sub(i, i) table.insert(cursors, self.cursors[i]) end @@ -275,6 +275,22 @@ function Param:strip() self:slice(1, #self.text - #self.text:match('%s*$')) 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 end