tab_buf_filter example from README doesn't work with partial matches
What is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
From the README
This will save only the current tabpage layout, but will save all of the open buffers. You can provide a filter to exclude buffers. For example, if you are using :tcd to have tabs open for different directories, this will only save buffers in the current tabpage directory:
require("resession").setup({
tab_buf_filter = function(tabpage, bufnr)
local dir = vim.fn.getcwd(-1, vim.api.nvim_tabpage_get_number(tabpage))
return vim.startswith(vim.api.nvim_buf_get_name(bufnr), dir)
end,
})
That code snippet doesn't work with partial matches in folder names.
If tab:1 has :tcd app-1 and tab:2 has :tcd app-12, saving session on tab:1 will also save files from tab:2 because any filename from tab:2 will match both app-12 folder and app-1 folder.
Sorry if I'm not providing a repro, but this can be reproduced easily from the nvim commands.
tab_buf_filter = function(tabpage, bufnr)
local dir = vim.fn.getcwd(-1, vim.api.nvim_tabpage_get_number(tabpage))
if dir:sub(-1) ~= "/" then dir = dir .. "/" end
return vim.api.nvim_buf_get_name(bufnr):sub(1, #dir) == dir
end,
...
Thanks for this beautiful plugin π
Expected Behavior
only save buffers for current tab with the snipped provided in the README.
Did you check the docs and existing issues?
Neovim version (nvim -v)
NVIM v0.10.0-dev-2039+g583c1de17
Operating system/version
arch linux
Describe the bug
tab_buf_filter
example from README doesn't work with partial matchesWhat is the severity of this bug?
breaking (some functionality is broken)
Steps To Reproduce
From the README
That code snippet doesn't work with partial matches in folder names. If tab:1 has
:tcd app-1
and tab:2 has:tcd app-12
, saving session on tab:1 will also save files from tab:2 because any filename from tab:2 will match bothapp-12
folder andapp-1
folder.Sorry if I'm not providing a repro, but this can be reproduced easily from the nvim commands.
I'm using this on my config to fix this:
Thanks for this beautiful plugin π
Expected Behavior
only save buffers for current tab with the snipped provided in the README.
Directory structure
βββ app-1 βββ app-12 βββ repro.lua
Repro
Did you check the bug with a clean config?
nvim -u repro.lua
using the repro.lua file above.