Skip to content

Commit

Permalink
add another test for the new restoreNode.
Browse files Browse the repository at this point in the history
  • Loading branch information
L3MON4D3 committed Oct 29, 2024
1 parent 3e30ca8 commit e89d49d
Showing 1 changed file with 89 additions and 0 deletions.
89 changes: 89 additions & 0 deletions tests/integration/restore_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,95 @@ screen:expect({
{0:~ }|
{2:-- SELECT --} |
]]
})
end)

-- make sure store and update_restore propagate.
it("correctly restores snippets (3).", function()

exec_lua([[
ls.setup({link_children = true})
ls.snip_expand(s("trig", {
i(1, "asdf"), t" ", d(2, function(args)
return sn(nil, {
r(1, "key", i(1)),
i(2, args[1])
})
end, {1})
}))
]])
exec_lua[[ls.jump(1)]]

local function exp()
exec_lua([[
ls.snip_expand(s("trig", {
t("("), r(1, "inside_pairs", dl(1, l.LS_SELECT_DEDENT)), t(")")
}))
]])
feed("i")
end

exp()
exec_lua"ls.jump(1)"
exp()
exec_lua"ls.jump(1)"
exp()
feed("<space><space>i<left><left>")
exp()
exp()
exp()
screen:expect({
grid = [[
asdf (i)(i)(i (i(i(i^))) i)asdf |
{0:~ }|
{2:-- INSERT --} |
]]
})
-- 11x to get back to the i1.
exec_lua"ls.jump(-1) ls.jump(-1) ls.jump(-1)"
exec_lua"ls.jump(-1) ls.jump(-1) ls.jump(-1)"
exec_lua"ls.jump(-1) ls.jump(-1) ls.jump(-1)"
exec_lua"ls.jump(-1) ls.jump(-1)"
feed("qwer")
exec_lua"ls.jump(1)"
screen:expect({
grid = [[
qwer ^({3:i)(i)(i (i(i(i))) i)}qwer |
{0:~ }|
{2:-- SELECT --} |
]]
})
exec_lua"ls.jump(1) ls.jump(1) ls.jump(1)"
screen:expect({
grid = [[
qwer (i)(^i)(i (i(i(i))) i)qwer |
{0:~ }|
{2:-- SELECT --} |
]]
})
exec_lua"ls.jump(1) ls.jump(1) ls.jump(1)"
screen:expect({
grid = [[
qwer (i)(i)(i (^i{3:(i(i))}) i)qwer |
{0:~ }|
{2:-- SELECT --} |
]]
})
exec_lua"ls.jump(1) ls.jump(1) ls.jump(1)"
screen:expect({
grid = [[
qwer (i)(i)(i (i(i(i)^)) i)qwer |
{0:~ }|
{2:-- INSERT --} |
]]
})
exec_lua"ls.jump(1) ls.jump(1) ls.jump(1) ls.jump(1)"
screen:expect({
grid = [[
qwer (i)(i)(i (i(i(i))) i)^q{3:wer} |
{0:~ }|
{2:-- SELECT --} |
]]
})
end)
end)

0 comments on commit e89d49d

Please sign in to comment.