Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
c45ff862b5 | |||
a93748acdb |
@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [3.1.0](https://github.com/folke/persistence.nvim/compare/v3.0.1...v3.1.0) (2024-07-07)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **load:** fallback to regular session when branch session does not exist (yet) ([a93748a](https://github.com/folke/persistence.nvim/commit/a93748acdb2e7bc4389b3738b4c787b764c3b2a6))
|
||||||
|
|
||||||
## [3.0.1](https://github.com/folke/persistence.nvim/compare/v3.0.0...v3.0.1) (2024-07-07)
|
## [3.0.1](https://github.com/folke/persistence.nvim/compare/v3.0.0...v3.0.1) (2024-07-07)
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,9 +7,11 @@ M._active = false
|
|||||||
|
|
||||||
local e = vim.fn.fnameescape
|
local e = vim.fn.fnameescape
|
||||||
|
|
||||||
function M.current()
|
---@param opts? {branch?: boolean}
|
||||||
|
function M.current(opts)
|
||||||
|
opts = opts or {}
|
||||||
local name = vim.fn.getcwd():gsub("[\\/:]+", "%%")
|
local name = vim.fn.getcwd():gsub("[\\/:]+", "%%")
|
||||||
if Config.options.branch then
|
if Config.options.branch and opts.branch ~= false then
|
||||||
local branch = M.branch()
|
local branch = M.branch()
|
||||||
if branch and branch ~= "main" and branch ~= "master" then
|
if branch and branch ~= "main" and branch ~= "master" then
|
||||||
name = name .. "%%" .. branch:gsub("[\\/:]+", "%%")
|
name = name .. "%%" .. branch:gsub("[\\/:]+", "%%")
|
||||||
@ -71,7 +73,16 @@ end
|
|||||||
---@param opts? { last?: boolean }
|
---@param opts? { last?: boolean }
|
||||||
function M.load(opts)
|
function M.load(opts)
|
||||||
opts = opts or {}
|
opts = opts or {}
|
||||||
local file = opts.last and M.last() or M.current()
|
---@type string
|
||||||
|
local file
|
||||||
|
if opts.last then
|
||||||
|
file = M.last()
|
||||||
|
else
|
||||||
|
file = M.current()
|
||||||
|
if vim.fn.filereadable(file) == 0 then
|
||||||
|
file = M.current({ branch = false })
|
||||||
|
end
|
||||||
|
end
|
||||||
if file and vim.fn.filereadable(file) ~= 0 then
|
if file and vim.fn.filereadable(file) ~= 0 then
|
||||||
M.fire("LoadPre")
|
M.fire("LoadPre")
|
||||||
vim.cmd("silent! source " .. e(file))
|
vim.cmd("silent! source " .. e(file))
|
||||||
|
Reference in New Issue
Block a user