diff --git a/runtime/doc/options.txt b/runtime/doc/options.txt index 6779c867ce4..10f66109aef 100644 --- a/runtime/doc/options.txt +++ b/runtime/doc/options.txt @@ -5187,8 +5187,8 @@ A jump table for the options with a short description can be found at |Q_op|. ' Maximum number of previously edited files for which the marks are remembered. This parameter must always be included when 'shada' is non-empty. - Including this item also means that the |jumplist| and the - |changelist| are stored in the shada file. + If non-zero, then the |jumplist| and the |changelist| are also + stored in the shada file. *shada-/* / Maximum number of items in the search pattern history to be saved. If non-zero, then the previous search and substitute diff --git a/runtime/lua/vim/_meta/options.lua b/runtime/lua/vim/_meta/options.lua index 1e0e40a3a35..25fbaae5a39 100644 --- a/runtime/lua/vim/_meta/options.lua +++ b/runtime/lua/vim/_meta/options.lua @@ -5441,8 +5441,8 @@ vim.go.ssop = vim.go.sessionoptions --- ' Maximum number of previously edited files for which the marks --- are remembered. This parameter must always be included when --- 'shada' is non-empty. ---- Including this item also means that the `jumplist` and the ---- `changelist` are stored in the shada file. +--- If non-zero, then the `jumplist` and the `changelist` are also +--- stored in the shada file. --- *shada-/* --- / Maximum number of items in the search pattern history to be --- saved. If non-zero, then the previous search and substitute diff --git a/src/nvim/options.lua b/src/nvim/options.lua index 624e4166a9e..fdbd361bc8b 100644 --- a/src/nvim/options.lua +++ b/src/nvim/options.lua @@ -7296,8 +7296,8 @@ local options = { ' Maximum number of previously edited files for which the marks are remembered. This parameter must always be included when 'shada' is non-empty. - Including this item also means that the |jumplist| and the - |changelist| are stored in the shada file. + If non-zero, then the |jumplist| and the |changelist| are also + stored in the shada file. *shada-/* / Maximum number of items in the search pattern history to be saved. If non-zero, then the previous search and substitute diff --git a/src/nvim/shada.c b/src/nvim/shada.c index 8496df73ad3..66cdf4911ad 100644 --- a/src/nvim/shada.c +++ b/src/nvim/shada.c @@ -2396,8 +2396,10 @@ static ShaDaWriteResult shada_write(FileDescriptor *const sd_writer, } while (var_iter != NULL); } - // Initialize jump list - wms->jumps_size = shada_init_jumps(wms->jumps, &removable_bufs); + if (num_marked_files > 0) { // Skip if '0 in 'shada' + // Initialize jump list + wms->jumps_size = shada_init_jumps(wms->jumps, &removable_bufs); + } const bool search_highlighted = !(no_hlsearch || find_shada_parameter('h') != NULL); diff --git a/test/functional/shada/marks_spec.lua b/test/functional/shada/marks_spec.lua index 837978dee15..528fa3a008a 100644 --- a/test/functional/shada/marks_spec.lua +++ b/test/functional/shada/marks_spec.lua @@ -152,6 +152,37 @@ describe('ShaDa support code', function() eq(saved, exec_capture('jumps')) end) + it("does not dump jumplist if `'0` in shada", function() + local empty_jumps = exec_capture('jumps') + nvim_command("set shada='0") + nvim_command('edit ' .. testfilename_2) + nvim_command('normal! G') + nvim_command('normal! gg') + nvim_command('edit ' .. testfilename) + nvim_command('normal! G') + nvim_command('normal! gg') + nvim_command('enew') + nvim_command('normal! gg') + expect_exit(nvim_command, 'qall') + reset() + eq(empty_jumps, exec_capture('jumps')) + end) + + it("does read back jumplist even with `'0` in shada", function() + nvim_command('edit ' .. testfilename_2) + nvim_command('normal! G') + nvim_command('normal! gg') + nvim_command('edit ' .. testfilename) + nvim_command('normal! G') + nvim_command('normal! gg') + nvim_command('enew') + nvim_command('normal! gg') + local saved = exec_capture('jumps') + expect_exit(nvim_command, 'qall') + reset("set shada='0") + eq(saved, exec_capture('jumps')) + end) + it('when dumping jump list also dumps current position', function() nvim_command('edit ' .. testfilename) nvim_command('normal! G')