aboutsummaryrefslogtreecommitdiff
path: root/code_obj.moon
diff options
context:
space:
mode:
authorBruce Hill <bitbucket@bruce-hill.com>2018-06-19 00:44:17 -0700
committerBruce Hill <bitbucket@bruce-hill.com>2018-06-19 00:44:22 -0700
commitd7d86e026831f60aae8193f1cfda7f53bf26a61e (patch)
tree50e810d54a199eb86b751c1a1661ece401689fcf /code_obj.moon
parent6d8d617774b064dce4cc230f5e10027c58790c2d (diff)
Lots of cleanup.
Diffstat (limited to 'code_obj.moon')
-rw-r--r--code_obj.moon24
1 files changed, 17 insertions, 7 deletions
diff --git a/code_obj.moon b/code_obj.moon
index 9e2e324..73a1ba8 100644
--- a/code_obj.moon
+++ b/code_obj.moon
@@ -66,20 +66,30 @@ class Code
indents[#bits] = @current_indent
@__str = nil
- concat_append: (values, joiner)=>
+ concat_append: (values, joiner, wrapping_joiner)=>
+ wrapping_joiner or= joiner
bits, indents = @bits, @indents
match = string.match
+ line_len = 0
for i=1,#values
b = values[i]
- assert(b)
if i > 1
- bits[#bits+1] = joiner
+ if line_len > 80
+ bits[#bits+1] = wrapping_joiner
+ line_len = 0
+ else
+ bits[#bits+1] = joiner
bits[#bits+1] = b
- if type(b) == 'string'
- if spaces = match(b, "\n([ ]*)[^\n]*$")
- @current_indent = #spaces
- elseif @current_indent != 0
+ if type(b) != 'string' and @current_indent != 0
indents[#bits] = @current_indent
+ b_str = tostring(b)
+ line, spaces = match(b_str, "\n(([ ]*)[^\n]*)$")
+ if spaces
+ if type(b) == 'string'
+ @current_indent = #spaces
+ line_len = #line
+ else
+ line_len += #b
@__str = nil
prepend: (...)=>