fix(shada): preserve marks after delete across sessions (#35795)

Problem: Marks are lost after `:bdelete` because `ignore_buf()` filters
out unlisted buffers during shada mark processing.

Solution: Revert to original buffer checks for mark operations, avoiding
`!buf->b_p_bl` condition that incorrectly ignores deleted buffers.
This commit is contained in:
glepnir
2025-09-30 13:28:35 +08:00
committed by GitHub
parent 35fc4fda99
commit 198c9e9bca
2 changed files with 28 additions and 1 deletions

View File

@@ -2443,7 +2443,8 @@ static ShaDaWriteResult shada_write(FileDescriptor *const sd_writer,
fname = fm.fname;
} else {
const buf_T *const buf = buflist_findnr(fm.fmark.fnum);
if (ignore_buf(buf, &removable_bufs)) {
if (buf == NULL || buf->b_ffname == NULL
|| set_has(ptr_t, &removable_bufs, (ptr_t)buf)) {
continue;
}
fname = buf->b_ffname;

View File

@@ -418,4 +418,30 @@ describe('ShaDa support code', function()
-- Make sure that uppercase marks aren't deleted.
nvim_command('normal! `A')
end)
it('preserves marks after :bdelete #35770', function()
nvim_command('edit foo')
nvim_command('mark X')
nvim_command('bdelete')
nvim_command('wshada')
reset()
local mX = api.nvim_get_mark('X', {})
t.matches(vim.pesc('foo'), mX[4])
nvim_command('delmarks X')
nvim_command('edit foo')
nvim_command('mark X')
nvim_command('edit bar')
nvim_command('mark Y')
nvim_command('bufdo bdelete')
nvim_command('edit foo')
nvim_command('wshada')
reset()
mX = api.nvim_get_mark('X', {})
local mY = api.nvim_get_mark('Y', {})
t.matches(vim.pesc('foo'), mX[4])
t.matches(vim.pesc('bar'), mY[4])
end)
end)