Skip to content

Commit afa735f

Browse files
authored
Merge pull request #345 from cameronr/main
2 parents fe705ee + 5cd13a5 commit afa735f

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

lua/auto-session/init.lua

+6
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,12 @@ end
482482
---@return boolean True if a session exists for the cwd
483483
function AutoSession.session_exists_for_cwd()
484484
local session_file = get_session_file_name(vim.fn.getcwd())
485+
if vim.fn.filereadable(AutoSession.get_root_dir() .. session_file) ~= 0 then
486+
return true
487+
end
488+
489+
-- Check legacy sessions
490+
local session_file = get_session_file_name(vim.fn.getcwd(), true)
485491
return vim.fn.filereadable(AutoSession.get_root_dir() .. session_file) ~= 0
486492
end
487493

tests/cmds_spec.lua

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ describe("The default config", function()
1717
end)
1818

1919
it("can save a session for the cwd", function()
20+
assert.False(as.session_exists_for_cwd())
2021
vim.cmd("e " .. TL.test_file)
2122

2223
vim.cmd "SessionSave"

tests/legacy_file_names_spec.lua

+5
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,16 @@ describe("Legacy file name support", function()
2525

2626
-- save a default session in new format
2727
as.SaveSession()
28+
29+
assert.True(as.session_exists_for_cwd())
2830
assert.equals(1, vim.fn.filereadable(TL.default_session_path))
2931
assert.equals(1, vim.fn.filereadable(default_extra_cmds_path))
3032

3133
vim.loop.fs_rename(TL.default_session_path, TL.default_session_path_legacy)
3234
vim.loop.fs_rename(default_extra_cmds_path, legacy_extra_cmds_path)
3335

3436
print(TL.default_session_path_legacy)
37+
assert.True(as.session_exists_for_cwd())
3538
assert.equals(1, vim.fn.filereadable(TL.default_session_path_legacy))
3639
assert.equals(0, vim.fn.filereadable(TL.default_session_path))
3740
assert.equals(1, vim.fn.filereadable(legacy_extra_cmds_path))
@@ -54,6 +57,8 @@ describe("Legacy file name support", function()
5457
-- and no old file name?
5558
assert.equals(0, vim.fn.filereadable(TL.default_session_path_legacy))
5659
assert.equals(0, vim.fn.filereadable(legacy_extra_cmds_path))
60+
61+
assert.True(as.session_exists_for_cwd())
5762
end)
5863

5964
it("can convert a session to the new format during a delete", function()

0 commit comments

Comments
 (0)