aboutsummaryrefslogtreecommitdiff
path: root/code_obj.moon
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.moon
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.moon')
-rw-r--r--code_obj.moon20
1 files changed, 6 insertions, 14 deletions
diff --git a/code_obj.moon b/code_obj.moon
index 35d1027..3d376bb 100644
--- a/code_obj.moon
+++ b/code_obj.moon
@@ -73,19 +73,7 @@ class Code
trailing_line_len: =>
if @_trailing_line_len == nil
- bits, match = @bits, string.match
- len = 0
- for i=#bits,1,-1
- b = bits[i]
- if type(b) == 'string'
- if line = match(b, "\n([^\n]*)$")
- len += #line
- break
- else len += #b
- else
- len += b\trailing_line_len!
- break if b\is_multiline!
- @_trailing_line_len = len
+ @_trailing_line_len = #tostring(@)\match("[^\n]*$")
return @_trailing_line_len
is_multiline: =>
@@ -93,7 +81,11 @@ class Code
match = string.match
@_is_multiline = false
for b in *@bits
- if type(b) != 'string' or match(b, "\n")
+ if type(b) == 'string'
+ if match(b, '\n')
+ @_is_multiline = true
+ break
+ elseif b\is_multiline!
@_is_multiline = true
break
return @_is_multiline