-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: autosave manually named sessions, fixes #386
If you're using a manually named session (either through ':SessionSave mysession', `:SessionSearch`, or `:SessionRestore mysession`) then we'll now auto-save to that session on exit instead of always autosaving to the session derived from the cwd.
- Loading branch information
Showing
2 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
---@diagnostic disable: undefined-field | ||
local TL = require "tests/test_lib" | ||
|
||
describe("Manually named sessions", function() | ||
require("auto-session").setup {} | ||
|
||
it("can autosave", function() | ||
TL.clearSessionFilesAndBuffers() | ||
vim.cmd("e " .. TL.test_file) | ||
|
||
require("auto-session").SaveSession(TL.named_session_name) | ||
|
||
vim.cmd("e " .. TL.other_file) | ||
|
||
require("auto-session").AutoSaveSession() | ||
|
||
-- Make sure the session was not created | ||
assert.equals(0, vim.fn.filereadable(TL.default_session_path)) | ||
assert.equals(1, vim.fn.filereadable(TL.named_session_path)) | ||
TL.assertSessionHasFile(TL.named_session_path, TL.test_file) | ||
TL.assertSessionHasFile(TL.named_session_path, TL.other_file) | ||
end) | ||
|
||
it("autosaving doesn't break normal autosaving", function() | ||
TL.clearSessionFilesAndBuffers() | ||
vim.cmd("e " .. TL.test_file) | ||
|
||
require("auto-session").SaveSession() | ||
|
||
vim.cmd("e " .. TL.other_file) | ||
assert.equals(1, vim.fn.bufexists(TL.other_file)) | ||
|
||
require("auto-session").AutoSaveSession() | ||
|
||
-- Make sure the session was not created | ||
assert.equals(0, vim.fn.filereadable(TL.named_session_path)) | ||
assert.equals(1, vim.fn.filereadable(TL.default_session_path)) | ||
TL.assertSessionHasFile(TL.default_session_path, TL.test_file) | ||
TL.assertSessionHasFile(TL.default_session_path, TL.other_file) | ||
end) | ||
end) |