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
|
||||
--- 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()
|
||||
local name = M.name()
|
||||
if M.exists(name) then
|
||||
if vim.fn.argc(-1) > 0 then return end
|
||||
if M.exists(M.name()) then
|
||||
M.load { silence_errors = true }
|
||||
else
|
||||
-- defer so the picker opens after startup finished drawing the UI
|
||||
|
||||
@@ -169,10 +169,8 @@ return {
|
||||
event = "VimEnter",
|
||||
desc = "Restore worktree/branch session, else open the git files picker",
|
||||
nested = true, -- trigger other autocommands as buffers open
|
||||
callback = function()
|
||||
-- only when nvim was started without file arguments
|
||||
if vim.fn.argc(-1) == 0 then require("config.session").restore() end
|
||||
end,
|
||||
-- no-op when nvim was started with file arguments, see config.session
|
||||
callback = function() require("config.session").restore() end,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user