Skip to content

Commit

Permalink
fix: tab-scoped cwd not being set (#21)
Browse files Browse the repository at this point in the history
* fix: tab-scoped cwd not being set

* chore: don't set global cwd twice
  • Loading branch information
Subjective authored Aug 20, 2023
1 parent d0ad06e commit c5f0b36
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions lua/resession/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ M.load = function(name, opts)
if not data.tab_scoped then
-- Set the options immediately
util.restore_global_options(data.global.options)
vim.cmd(string.format("cd %s", data.global.cwd))
end
local scale = {
vim.o.columns / data.global.width,
Expand Down Expand Up @@ -470,6 +469,11 @@ M.load = function(name, opts)
util.restore_buf_options(bufnr, buf.options)
end

-- Ensure the cwd is set correctly for each loaded buffer
if not data.tab_scoped then
vim.api.nvim_set_current_dir(data.global.cwd)
end

local curwin
for i, tab in ipairs(data.tabs) do
if i > 1 then
Expand All @@ -490,11 +494,6 @@ M.load = function(name, opts)
end
end

-- Ensure the cwd is set correctly for each loaded buffer
if not data.tab_scoped then
vim.api.nvim_set_current_dir(data.global.cwd)
end

-- This can be nil if we saved a session in a window with an unsupported buffer
if curwin then
vim.api.nvim_set_current_win(curwin)
Expand Down

0 comments on commit c5f0b36

Please sign in to comment.