From 0b96b3cd52b48d981f9402f7669d3a653eddbcd3 Mon Sep 17 00:00:00 2001 From: Guilherme Batalheiro <57897031+guilherme-batalheiro@users.noreply.github.com> Date: Sat, 16 May 2026 18:53:34 +0100 Subject: [PATCH] fix(shada): set correct buffer number for local marks on read #39712 Problem: After closing and reopening Neovim, ]' and [' fail with E92: Buffer 0 not found for marks restored from ShaDa. Direct jumps like 'a work because mark_get_local() rewrites fnum before returning, but ]' uses getnextmark() which does not, leaving fnum = 0. Solution: Set .fnum = buf->b_fnum when restoring local marks from ShaDa. --- src/nvim/shada.c | 2 +- test/functional/shada/marks_spec.lua | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 7034c84908..4ca8ead9fa 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -1180,7 +1180,7 @@ static void shada_read(FileDescriptor *const sd_reader, const int flags) } const fmark_T fm = (fmark_T) { .mark = cur_entry.data.filemark.mark, - .fnum = 0, + .fnum = buf->b_fnum, .timestamp = cur_entry.timestamp, .view = INIT_FMARKV, .additional_data = cur_entry.additional_data, diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index e7215a8a40..8ec73b8daf 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -189,6 +189,17 @@ describe('ShaDa support code', function() eq(2, nvim_current_line()) end) + it("is able to dump, read back local mark and use `]'`", function() + nvim_command('edit ' .. testfilename) + nvim_command('2') + nvim_command('mark a') + expect_exit(nvim_command, 'qall') + reset({ args = { testfilename } }) + eq(1, nvim_current_line()) + nvim_command("normal! ]'") + eq(2, nvim_current_line()) + end) + it('is able to dump and read back mark " from a closed tab', function() nvim_command('edit ' .. testfilename) nvim_command('tabedit ' .. testfilename_2)