mirror of
https://github.com/folke/persistence.nvim.git
synced 2025-06-29 20:14:42 +02:00
fix(start)!: session name is now based on the cwd when the session starts and not when the session ends. Fixes #1688
This commit is contained in:
parent
9730a073fd
commit
0361df7775
1 changed files with 5 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
||||||
local Config = require("persistence.config")
|
local Config = require("persistence.config")
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
---@type string?
|
||||||
|
M.current = nil
|
||||||
|
|
||||||
local e = vim.fn.fnameescape
|
local e = vim.fn.fnameescape
|
||||||
|
|
||||||
|
@ -27,6 +29,7 @@ function M.setup(opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.start()
|
function M.start()
|
||||||
|
M.current = M.get_current()
|
||||||
vim.api.nvim_create_autocmd("VimLeavePre", {
|
vim.api.nvim_create_autocmd("VimLeavePre", {
|
||||||
group = vim.api.nvim_create_augroup("persistence", { clear = true }),
|
group = vim.api.nvim_create_augroup("persistence", { clear = true }),
|
||||||
callback = function()
|
callback = function()
|
||||||
|
@ -55,13 +58,14 @@ function M.start()
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.stop()
|
function M.stop()
|
||||||
|
M.current = nil
|
||||||
pcall(vim.api.nvim_del_augroup_by_name, "persistence")
|
pcall(vim.api.nvim_del_augroup_by_name, "persistence")
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.save()
|
function M.save()
|
||||||
local tmp = vim.o.sessionoptions
|
local tmp = vim.o.sessionoptions
|
||||||
vim.o.sessionoptions = table.concat(Config.options.options, ",")
|
vim.o.sessionoptions = table.concat(Config.options.options, ",")
|
||||||
vim.cmd("mks! " .. e(M.get_current()))
|
vim.cmd("mks! " .. e(M.current or M.get_current()))
|
||||||
vim.o.sessionoptions = tmp
|
vim.o.sessionoptions = tmp
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue