feat(shada): don't store jumplist if '0 in 'shada'

This commit is contained in:
Andre Toerien
2025-04-19 14:47:44 +02:00
parent c1d21492a6
commit 71455173b4
5 changed files with 41 additions and 8 deletions

View File

@@ -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 ' Maximum number of previously edited files for which the marks
are remembered. This parameter must always be included when are remembered. This parameter must always be included when
'shada' is non-empty. 'shada' is non-empty.
Including this item also means that the |jumplist| and the If non-zero, then the |jumplist| and the |changelist| are also
|changelist| are stored in the shada file. stored in the shada file.
*shada-/* *shada-/*
/ Maximum number of items in the search pattern history to be / Maximum number of items in the search pattern history to be
saved. If non-zero, then the previous search and substitute saved. If non-zero, then the previous search and substitute

View File

@@ -5441,8 +5441,8 @@ vim.go.ssop = vim.go.sessionoptions
--- ' Maximum number of previously edited files for which the marks --- ' Maximum number of previously edited files for which the marks
--- are remembered. This parameter must always be included when --- are remembered. This parameter must always be included when
--- 'shada' is non-empty. --- 'shada' is non-empty.
--- Including this item also means that the `jumplist` and the --- If non-zero, then the `jumplist` and the `changelist` are also
--- `changelist` are stored in the shada file. --- stored in the shada file.
--- *shada-/* --- *shada-/*
--- / Maximum number of items in the search pattern history to be --- / Maximum number of items in the search pattern history to be
--- saved. If non-zero, then the previous search and substitute --- saved. If non-zero, then the previous search and substitute

View File

@@ -7296,8 +7296,8 @@ local options = {
' Maximum number of previously edited files for which the marks ' Maximum number of previously edited files for which the marks
are remembered. This parameter must always be included when are remembered. This parameter must always be included when
'shada' is non-empty. 'shada' is non-empty.
Including this item also means that the |jumplist| and the If non-zero, then the |jumplist| and the |changelist| are also
|changelist| are stored in the shada file. stored in the shada file.
*shada-/* *shada-/*
/ Maximum number of items in the search pattern history to be / Maximum number of items in the search pattern history to be
saved. If non-zero, then the previous search and substitute saved. If non-zero, then the previous search and substitute

View File

@@ -2396,8 +2396,10 @@ static ShaDaWriteResult shada_write(FileDescriptor *const sd_writer,
} while (var_iter != NULL); } while (var_iter != NULL);
} }
// Initialize jump list if (num_marked_files > 0) { // Skip if '0 in 'shada'
wms->jumps_size = shada_init_jumps(wms->jumps, &removable_bufs); // Initialize jump list
wms->jumps_size = shada_init_jumps(wms->jumps, &removable_bufs);
}
const bool search_highlighted = !(no_hlsearch const bool search_highlighted = !(no_hlsearch
|| find_shada_parameter('h') != NULL); || find_shada_parameter('h') != NULL);

View File

@@ -152,6 +152,37 @@ describe('ShaDa support code', function()
eq(saved, exec_capture('jumps')) eq(saved, exec_capture('jumps'))
end) 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() it('when dumping jump list also dumps current position', function()
nvim_command('edit ' .. testfilename) nvim_command('edit ' .. testfilename)
nvim_command('normal! G') nvim_command('normal! G')