Skip to content

Commit ce43f2e

Browse files
authored
Add func to check if a session in cwd exists (#143)
1 parent cbaebd9 commit ce43f2e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lua/session_manager/init.lua

+11
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,17 @@ function session_manager.load_current_dir_session(discard_current)
6767
return false
6868
end
6969

70+
--- Checks if a session for the current working directory exists.
71+
---@return boolean: `true` if session was found, `false` otherwise.
72+
function session_manager.current_dir_session_exists()
73+
local cwd = vim.uv.cwd()
74+
if cwd then
75+
local session = config.dir_to_session_filename(cwd)
76+
return session:exists()
77+
end
78+
return false
79+
end
80+
7081
--- If in a git repo, tries to load a session for the repo's root directory
7182
---@return boolean: `true` if session was loaded, `false` otherwise.
7283
function session_manager.load_git_session(discard_current)

0 commit comments

Comments
 (0)