diff --git a/lua/treesj/langs/elixir.lua b/lua/treesj/langs/elixir.lua index 6af32eb..68dc791 100644 --- a/lua/treesj/langs/elixir.lua +++ b/lua/treesj/langs/elixir.lua @@ -44,7 +44,10 @@ return { local pairs = tsj:children({ 'pair' }) for _, pair in ipairs(pairs) do for keyword in pair:iter_children() do - if keyword:type() == 'map' then + local type = keyword:type() + local needs_padding = + type == 'map' or type == 'list' or type == 'tuple' + if needs_padding then -- Grab the previous node which is the map key local map_key = keyword:prev() -- Add an extra space to account for keyword + map quirkness diff --git a/tests/langs/elixir/join_spec.lua b/tests/langs/elixir/join_spec.lua index 5ff9623..697c45a 100644 --- a/tests/langs/elixir/join_spec.lua +++ b/tests/langs/elixir/join_spec.lua @@ -63,9 +63,9 @@ local data_for_join = { mode = 'join', lang = LANG, desc = 'lang "%s", node "map" with "keywords" and "map_content", preset default', - cursor = { 65, 8 }, - expected = { 61, 62 }, - result = { 64, 65 }, + cursor = { 67, 8 }, + expected = { 63, 64 }, + result = { 66, 67 }, }, { path = PATH, diff --git a/tests/langs/elixir/split_spec.lua b/tests/langs/elixir/split_spec.lua index 2d1127f..518a88c 100644 --- a/tests/langs/elixir/split_spec.lua +++ b/tests/langs/elixir/split_spec.lua @@ -55,35 +55,35 @@ local data_for_split = { lang = LANG, desc = 'lang "%s", node "keywords", preset default', cursor = { 53, 9 }, - expected = { 55, 59 }, - result = { 52, 56 }, + expected = { 55, 61 }, + result = { 52, 58 }, }, { path = PATH, mode = 'split', lang = LANG, desc = 'lang "%s", node "map" with "keywords" and "map_content", preset default', - cursor = { 62, 8 }, - expected = { 64, 69 }, - result = { 61, 66 }, + cursor = { 64, 8 }, + expected = { 66, 71 }, + result = { 63, 68 }, }, { path = PATH, mode = 'split', lang = LANG, desc = 'lang "%s", node "list" with "keywords" and "map", preset default', - cursor = { 72, 9 }, - expected = { 74, 80 }, - result = { 71, 77 }, + cursor = { 74, 9 }, + expected = { 76, 82 }, + result = { 73, 79 }, }, { path = PATH, mode = 'split', lang = LANG, desc = 'lang "%s", node "map" nested "keywords" and "maps", preset default', - cursor = { 83, 15 }, - expected = { 85, 91 }, - result = { 82, 88 }, + cursor = { 85, 15 }, + expected = { 87, 93 }, + result = { 84, 90 }, }, } diff --git a/tests/sample/index.ex b/tests/sample/index.ex index ed48170..91ba764 100644 --- a/tests/sample/index.ex +++ b/tests/sample/index.ex @@ -50,12 +50,14 @@ test( } # RESULT OF JOIN (node "keywords", preset default) -map = %{foo: "bar", baz: "bar"} +map = %{foo: "bar", baz: [], abc: %{}, def: {}} # RESULT OF SPLIT (node "keywords", preset default) map = %{ foo: "bar", - baz: "bar" + baz: [], + abc: %{}, + def: {} } # RESULT OF JOIN (node "map" with "keywords" and "map_content", preset default)