Skip to content

Commit a0b9d25

Browse files
authored
Add silent option for utils.get_sessions (#119)
1 parent 892c55f commit a0b9d25

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lua/session_manager/utils.lua

+4-3
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,11 @@ function utils.delete_session(filename)
9999
end
100100
end
101101

102+
---@param opts table?: Additional arguments. Currently only `silent` is supported.
102103
---@return table
103-
function utils.get_sessions()
104+
function utils.get_sessions(opts)
104105
local sessions = {}
105-
for _, session_filename in ipairs(scandir.scan_dir(tostring(config.sessions_dir))) do
106+
for _, session_filename in ipairs(scandir.scan_dir(tostring(config.sessions_dir), opts)) do
106107
local dir = config.session_filename_to_dir(session_filename)
107108
if dir:is_dir() then
108109
table.insert(sessions, { timestamp = vim.fn.getftime(session_filename), filename = session_filename, dir = dir })
@@ -122,7 +123,7 @@ function utils.get_sessions()
122123
end
123124

124125
-- If no sessions to list, send a notification.
125-
if #sessions == 0 then
126+
if not (opts and opts.silent) and #sessions == 0 then
126127
vim.notify('The only available session is your current session. Nothing to select from.', vim.log.levels.INFO)
127128
end
128129

0 commit comments

Comments
 (0)