diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-09 19:32:13 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-09 19:32:20 -0800 |
| commit | 771007bc4dbcde1698fd86d87374df21651585a5 (patch) | |
| tree | f97a5bcabb00c5736d5621f8b398fb63f61eb188 /nomsu_decompiler.lua | |
| parent | b5a5b7f90d576b0a926e9630a3efb1ebfd5539d7 (diff) | |
Fixed word clumping with linebreaks.
Diffstat (limited to 'nomsu_decompiler.lua')
| -rw-r--r-- | nomsu_decompiler.lua | 20 |
1 files changed, 11 insertions, 9 deletions
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) |
