From d06d6865df6acf745a8a1c1b8270d414290a8696 Mon Sep 17 00:00:00 2001 From: Alex Yatskov Date: Tue, 30 Apr 2024 18:31:16 -0700 Subject: [PATCH] Cleanup --- lua/argonaut/types.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lua/argonaut/types.lua b/lua/argonaut/types.lua index 6bd7cd9..8196576 100644 --- a/lua/argonaut/types.lua +++ b/lua/argonaut/types.lua @@ -246,12 +246,18 @@ function Param:is_active() end function Param:flush() + self.text = self.text:match('^(.-)%s*$') if self.offset then - self.offset = math.min(self.offset, #self.text:match('(.-)%s*$')) - self.offset = math.max(self.offset - #self.text:match('^%s*'), 1) + self.offset = math.min(self.offset, #self.text) + end + + local length_prev = #self.text + self.text = self.text:match('^%s*(.-)$') + if self.offset then + local length_diff = length_prev - #self.text + self.offset = math.max(self.offset - length_diff, 1) end - self.text = self.text:match('^%s*(.-)%s*$') return #self.text > 0 end