8000 Do not show the latest session on top if not inside the session (#92) · Shatur/neovim-session-manager@fbceeec · GitHub
[go: up one dir, main page]

Skip to content

Commit fbceeec

Browse files
authored
Do not show the latest session on top if not inside the session (#92)
1 parent 5182726 commit fbceeec

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

lua/session_manager/utils.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,13 @@ function utils.get_sessions()
126126
end
127127
table.sort(sessions, function(a, b) return a.timestamp > b.timestamp end)
128128

129-
-- If the last session is the current one, then preselect the previous one.
130-
local cwd = vim.loop.cwd()
131-
if #sessions >= 2 and cwd and config.dir_to_session_filename(cwd).filename == sessions[1].filename then
132-
sessions[1], sessions[2] = sessions[2], sessions[1]
129+
-- If we are in a session already, show the penultimate saved session on top.
130+
-- If we are not inside a session, show the latest saved session on top.
131+
if utils.is_session then
132+
local cwd = vim.loop.cwd()
133+
if #sessions >= 2 and cwd and config.dir_to_session_filename(cwd).filename == sessions[1].filename then
134+
sessions[1], sessions[2] = sessions[2], sessions[1]
135+
end
133136
end
134137

135138
return sessions

0 commit comments

Comments
 (0)
0