aboutsummaryrefslogtreecommitdiff
path: root/code_obj.lua
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-07-19 21:09:44 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-07-19 21:10:19 -0700
commit9d6627aee52d764f14bab55fee202af84baf0065 (patch)
tree4f26aa76447e0223235436de1635e5d30e3a7f27 /code_obj.lua
parent47db74229deaf281ad02c8305c4e4d4c8dbd3d7d (diff)
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()
Diffstat (limited to 'code_obj.lua')
-rw-r--r--code_obj.lua30
1 files changed, 7 insertions, 23 deletions
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