From 0361df7775f5b4ed51a6d7fe159438573b7f07a6 Mon Sep 17 00:00:00 2001 From: Folke Lemaitre <folke.lemaitre@gmail.com> Date: Sun, 15 Oct 2023 21:40:15 +0200 Subject: [PATCH] fix(start)!: session name is now based on the cwd when the session starts and not when the session ends. Fixes #1688 --- lua/persistence/init.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lua/persistence/init.lua b/lua/persistence/init.lua index d962a7a..6857a22 100644 --- a/lua/persistence/init.lua +++ b/lua/persistence/init.lua @@ -1,6 +1,8 @@ local Config = require("persistence.config") local M = {} +---@type string? +M.current = nil local e = vim.fn.fnameescape @@ -27,6 +29,7 @@ function M.setup(opts) end function M.start() + M.current = M.get_current() vim.api.nvim_create_autocmd("VimLeavePre", { group = vim.api.nvim_create_augroup("persistence", { clear = true }), callback = function() @@ -55,13 +58,14 @@ function M.start() end function M.stop() + M.current = nil pcall(vim.api.nvim_del_augroup_by_name, "persistence") end function M.save() local tmp = vim.o.sessionoptions 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 end