feat: delete a session in a schedule.wrap func

main
olimorris 2023-02-23 20:44:05 +00:00
parent 587b90bddc
commit 383b5ba6b5
2 changed files with 16 additions and 10 deletions

View File

@ -150,7 +150,6 @@ function M.save()
return
end
if vim.g.persisting_session == nil then
vim.cmd("mks! " .. e(get_current()))
else
@ -173,8 +172,10 @@ end
function M.delete()
local session = get_current()
if session and vim.loop.fs_stat(session) ~= 0 then
vim.schedule(function()
M.stop()
vim.fn.system("rm " .. e(session))
end)
end
end

View File

@ -53,11 +53,16 @@ describe("With default settings:", function()
assert.equals(path:is_path(), true)
end)
end)
it("it deletes a session", function()
local async = require("plenary.async.tests")
local util = require("plenary.async.util")
async.describe("With default settings:", function()
async.it("it deletes a session", function()
require("persisted").delete()
util.scheduler()
assert.equals(vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""), "0")
assert.equals("0", vim.fn.system("ls tests/default_data | wc -l"):gsub("%s+", ""))
end)
end)