2 Commits

Author SHA1 Message Date
c45ff862b5 chore(main): release 3.1.0 (#66)
🤖 I have created a release *beep* *boop*
---


##
[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](a93748acdb))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2024-07-07 21:24:56 +02:00
a93748acdb feat(load): fallback to regular session when branch session does not exist (yet) 2024-07-07 19:01:19 +02:00
2 changed files with 21 additions and 3 deletions

View File

@ -1,5 +1,12 @@
# 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)

View File

@ -7,9 +7,11 @@ M._active = false
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("[\\/:]+", "%%")
if Config.options.branch then
if Config.options.branch and opts.branch ~= false then
local branch = M.branch()
if branch and branch ~= "main" and branch ~= "master" then
name = name .. "%%" .. branch:gsub("[\\/:]+", "%%")
@ -71,7 +73,16 @@ end
---@param opts? { last?: boolean }
function M.load(opts)
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
M.fire("LoadPre")
vim.cmd("silent! source " .. e(file))