From 771007bc4dbcde1698fd86d87374df21651585a5 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Fri, 9 Nov 2018 19:32:13 -0800 Subject: Fixed word clumping with linebreaks. --- nomsu_decompiler.lua | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'nomsu_decompiler.lua') diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua index b6cb659..17ac7eb 100644 --- a/nomsu_decompiler.lua +++ b/nomsu_decompiler.lua @@ -281,16 +281,18 @@ tree_to_nomsu = function(tree) end for i, bit in ipairs(tree) do if type(bit) == "string" then - local clump_words - if type(tree[i - 1]) == 'string' then - clump_words = is_operator(bit) ~= is_operator(tree[i - 1]) - else - clump_words = bit == "'" - end - if i > 1 and not clump_words then - nomsu:append(" ") + if next_space == " " then + local clump_words + if type(tree[i - 1]) == 'string' then + clump_words = is_operator(bit) ~= is_operator(tree[i - 1]) + else + clump_words = bit == "'" + end + if clump_words then + next_space = "" + end end - nomsu:append(bit) + nomsu:append(next_space, bit) next_space = nomsu:trailing_line_len() > MAX_LINE and " \\\n.." or " " else local bit_nomsu = recurse(bit) -- cgit v1.2.3