diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-09 17:43:06 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-09 17:43:25 -0800 |
| commit | 6fa1cb23d151463b7d85dcf9d5c413420d11ecad (patch) | |
| tree | 9c9f7a340ae840636ea154fbcbf373beced85cb6 | |
| parent | b236ad88a9e6c5dc5d77f889ac7641fc666bd19f (diff) | |
Fixed decompile issue with short actions not getting indented.
| -rw-r--r-- | nomsu_decompiler.lua | 8 | ||||
| -rw-r--r-- | nomsu_decompiler.moon | 7 |
2 files changed, 11 insertions, 4 deletions
diff --git a/nomsu_decompiler.lua b/nomsu_decompiler.lua index 6db2ec4..9ff62b1 100644 --- a/nomsu_decompiler.lua +++ b/nomsu_decompiler.lua @@ -287,7 +287,11 @@ tree_to_nomsu = function(tree) bit_nomsu:parenthesize() end if next_space == " " and not bit_nomsu:is_multiline() and nomsu:trailing_line_len() + #bit_nomsu:text() > MAX_LINE then - next_space = " \\\n.." + if bit.type == 'Action' then + bit_nomsu = NomsuCode:from(bit.source, "(..)\n ", tree_to_nomsu(bit)) + else + next_space = " \\\n.." + end end if not (next_space == " " and bit.type == "Block") then nomsu:append(next_space) @@ -302,7 +306,7 @@ tree_to_nomsu = function(tree) if tree[1].type == 'Block' and not nomsu:is_multiline() then nomsu:parenthesize() end - return NomsuCode(tree.source, "\\", nomsu) + return NomsuCode:from(tree.source, "\\", nomsu) elseif "Block" == _exp_0 then for i, line in ipairs(tree) do local line_nomsu = tree_to_nomsu(line) diff --git a/nomsu_decompiler.moon b/nomsu_decompiler.moon index f44b628..0bc4805 100644 --- a/nomsu_decompiler.moon +++ b/nomsu_decompiler.moon @@ -217,7 +217,10 @@ tree_to_nomsu = (tree)-> bit_nomsu\parenthesize! if next_space == " " and not bit_nomsu\is_multiline! and nomsu\trailing_line_len! + #bit_nomsu\text! > MAX_LINE - next_space = " \\\n.." + if bit.type == 'Action' + bit_nomsu = NomsuCode\from bit.source, "(..)\n ", tree_to_nomsu(bit) + else + next_space = " \\\n.." unless next_space == " " and bit.type == "Block" nomsu\append next_space @@ -230,7 +233,7 @@ tree_to_nomsu = (tree)-> nomsu = recurse(tree[1]) if tree[1].type == 'Block' and not nomsu\is_multiline! nomsu\parenthesize! - return NomsuCode tree.source, "\\", nomsu + return NomsuCode\from tree.source, "\\", nomsu when "Block" for i, line in ipairs tree |
