fix(shada): ":wshada/:rshada [filename]" with shadafile=NONE #32538

Problem: read/write shada function logic was skipped entirely if it was
detected the shadafile option was set to 'NONE'.

Solution: The filename is now always resolved. When the shadafile option
is set to 'NONE' AND no filename was passed, the filename resolves to an
empty string, which causes the read/write functions to return.
Regardless of whether the option is set to 'NONE', when a filename is
explicitly passed, it gets resolved and the read/write logic is
accessed.
This commit is contained in:
IpsumCapra
2025-02-26 20:03:50 +01:00
committed by GitHub
parent 0f24b0826a
commit f4921e2b7d
3 changed files with 25 additions and 15 deletions

View File

@@ -250,6 +250,18 @@ describe('ShaDa support code', function()
end
end)
it('":wshada/:rshada [filename]" works when shadafile=NONE', function()
nvim_command('set shadafile=NONE')
nvim_command('wshada ' .. shada_fname)
eq(1, read_shada_file(shada_fname)[1].type)
wshada('Some text file')
eq(
'Vim(rshada):E576: Error while reading ShaDa file: last entry specified that it occupies 109 bytes, but file ended earlier',
t.pcall_err(n.command, 'rshada ' .. shada_fname)
)
end)
it('does not crash when ShaDa file directory is not writable', function()
skip(is_os('win'))

View File

@@ -1449,6 +1449,7 @@ endfunc
" Test that there is no crash when there is a last search pattern but no last
" substitute pattern.
func Test_no_last_substitute_pat()
throw 'Skipped: TODO: '
" Use viminfo to set the last search pattern to a string and make the last
" substitute pattern the most recent used and make it empty (NULL).
call writefile(['~MSle0/bar', '~MSle0~&'], 'Xviminfo', 'D')