From d7d86e026831f60aae8193f1cfda7f53bf26a61e Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Tue, 19 Jun 2018 00:44:17 -0700 Subject: Lots of cleanup. --- code_obj.moon | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) (limited to 'code_obj.moon') 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: (...)=> -- cgit v1.2.3