commit 198c9e9bca7549cf7110be8c6f1df1c38d4e747f
parent 35fc4fda999f06ad1cd0d6cd07e06b21b2bd3dc6
Author: glepnir <glephunter@gmail.com>
Date: Tue, 30 Sep 2025 13:28:35 +0800
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.
Diffstat:
2 files changed, 28 insertions(+), 1 deletion(-)
diff --git a/src/nvim/shada.c b/src/nvim/shada.c
@@ -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;
diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua
@@ -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)