From 9d6627aee52d764f14bab55fee202af84baf0065 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 19 Jul 2018 21:09:44 -0700 Subject: Hopefully last correctness fix for trailing_line_len(), now it's just dumb and slow, but correct. Also simplified recursion options a bit for tree_to_nomsu() --- code_obj.lua | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'code_obj.lua') diff --git a/code_obj.lua b/code_obj.lua index 470cd11..51d9b00 100644 --- a/code_obj.lua +++ b/code_obj.lua @@ -113,28 +113,7 @@ do end, trailing_line_len = function(self) if self._trailing_line_len == nil then - local bits, match = self.bits, string.match - local len = 0 - for i = #bits, 1, -1 do - local b = bits[i] - if type(b) == 'string' then - do - local line = match(b, "\n([^\n]*)$") - if line then - len = len + #line - break - else - len = len + #b - end - end - else - len = len + b:trailing_line_len() - if b:is_multiline() then - break - end - end - end - self._trailing_line_len = len + self._trailing_line_len = #tostring(self):match("[^\n]*$") end return self._trailing_line_len end, @@ -145,7 +124,12 @@ do local _list_0 = self.bits for _index_0 = 1, #_list_0 do local b = _list_0[_index_0] - if type(b) ~= 'string' or match(b, "\n") then + if type(b) == 'string' then + if match(b, '\n') then + self._is_multiline = true + break + end + elseif b:is_multiline() then self._is_multiline = true break end -- cgit v1.2.3