@@ -173,7 +173,7 @@ local function suppress_session(session_dir)
173
173
174
174
-- If session_dir is set, use that otherwise use cwd
175
175
-- session_dir will be set when loading a session from a directory at lauch (i.e. from argv)
176
- local cwd = session_dir or vim .fn .getcwd ()
176
+ local cwd = session_dir or vim .fn .getcwd (- 1 )
177
177
178
178
if Lib .find_matching_directory (cwd , dirs ) then
179
179
Lib .logger .debug " suppress_session found a match, suppressing"
@@ -190,7 +190,7 @@ local function is_allowed_dir()
190
190
end
191
191
192
192
local dirs = Config .allowed_dirs or {}
193
- local cwd = vim .fn .getcwd ()
193
+ local cwd = vim .fn .getcwd (- 1 )
194
194
195
195
if Lib .find_matching_directory (cwd , dirs ) then
196
196
Lib .logger .debug " is_allowed_dir found a match, allowing"
209
209
--- @return string Returns the escaped version of the name with .vim appended.
210
210
local function get_session_file_name (session_name , legacy )
211
211
if not session_name or session_name == " " then
212
- session_name = vim .fn .getcwd ()
212
+ session_name = vim .fn .getcwd (- 1 )
213
213
Lib .logger .debug (" get_session_file_name no session_name, using cwd: " .. session_name )
214
214
215
215
local git_branch_name = get_git_branch_name ()
@@ -279,13 +279,13 @@ end
279
279
--- unless a session for the current working directory exists.
280
280
--- @return boolean True if a session exists for the cwd
281
281
function AutoSession .session_exists_for_cwd ()
282
- local session_file = get_session_file_name (vim .fn .getcwd ())
282
+ local session_file = get_session_file_name (vim .fn .getcwd (- 1 ))
283
283
if vim .fn .filereadable (AutoSession .get_root_dir () .. session_file ) ~= 0 then
284
284
return true
285
285
end
286
286
287
287
-- Check legacy sessions
288
- session_file = get_session_file_name (vim .fn .getcwd (), true )
288
+ session_file = get_session_file_name (vim .fn .getcwd (- 1 ), true )
289
289
return vim .fn .filereadable (AutoSession .get_root_dir () .. session_file ) ~= 0
290
290
end
291
291
@@ -482,7 +482,7 @@ function AutoSession.auto_restore_session_at_vim_enter()
482
482
483
483
-- We failed to load a session for the other directory. Unless session name matches cwd, we don't
484
484
-- want to enable autosaving since it might replace the session for the cwd
485
- if vim .fn .getcwd () ~= session_name then
485
+ if vim .fn .getcwd (- 1 ) ~= session_name then
486
486
Lib .logger .debug " Not enabling autosave because launch argument didn't load session and doesn't match cwd"
487
487
Config .auto_save = false
488
488
end
0 commit comments