feat(session): skip session restore on startup with file arguments
This commit is contained in:
1 parent
d9a7970d3e
commit
aee8fe3b2d
2 files changed
+8
-6
No files matched your search
@@ -75,9 +75,13 @@ end
|
|||||||
|
|
||||||
--- VimEnter entry point: restore this worktree/branch session, or fall back to
|
--- VimEnter entry point: restore this worktree/branch session, or fall back to
|
||||||
--- the file picker when none has been saved yet.
|
--- the file picker when none has been saved yet.
|
||||||
|
---
|
||||||
|
--- Exception: when nvim was started with file arguments (`nvim foo.lua`, a
|
||||||
|
--- directory, or `-`) the requested buffer is what the user asked for, so
|
||||||
|
--- neither the session nor the picker may take the screen.
|
||||||
function M.restore()
|
function M.restore()
|
||||||
local name = M.name()
|
if vim.fn.argc(-1) > 0 then return end
|
||||||
if M.exists(name) then
|
if M.exists(M.name()) then
|
||||||
M.load { silence_errors = true }
|
M.load { silence_errors = true }
|
||||||
else
|
else
|
||||||
-- defer so the picker opens after startup finished drawing the UI
|
-- defer so the picker opens after startup finished drawing the UI
|
||||||
|
|||||||
@@ -169,10 +169,8 @@ return {
|
|||||||
event = "VimEnter",
|
event = "VimEnter",
|
||||||
desc = "Restore worktree/branch session, else open the git files picker",
|
desc = "Restore worktree/branch session, else open the git files picker",
|
||||||
nested = true, -- trigger other autocommands as buffers open
|
nested = true, -- trigger other autocommands as buffers open
|
||||||
callback = function()
|
-- no-op when nvim was started with file arguments, see config.session
|
||||||
-- only when nvim was started without file arguments
|
callback = function() require("config.session").restore() end,
|
||||||
if vim.fn.argc(-1) == 0 then require("config.session").restore() end
|
|
||||||
end,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in new issue
Block a user