mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
shada: Fix memory leak and double free when setting both &vi and &sd
This commit is contained in:
parent
937f6584d7
commit
3a4a941885
@ -1968,6 +1968,8 @@ static void redraw_titles(void) {
|
||||
redraw_tabline = TRUE;
|
||||
}
|
||||
|
||||
static int shada_idx = -1;
|
||||
|
||||
/*
|
||||
* Set a string option to a new value (without checking the effect).
|
||||
* The string is copied into allocated memory.
|
||||
@ -2001,6 +2003,8 @@ set_string_option_direct (
|
||||
if (options[idx].var == NULL) /* can't set hidden option */
|
||||
return;
|
||||
|
||||
assert((void *) options[idx].var != (void *) &p_shada);
|
||||
|
||||
s = vim_strsave(val);
|
||||
{
|
||||
varp = (char_u **)get_varp_scope(&(options[idx]),
|
||||
@ -2443,6 +2447,13 @@ did_set_string_option (
|
||||
errmsg = e_invarg;
|
||||
/* 'shada' */
|
||||
} else if (varp == &p_shada) {
|
||||
// TODO(ZyX-I): Remove this code in the future, alongside with &viminfo
|
||||
// option.
|
||||
opt_idx = ((options[opt_idx].fullname[0] == 'v')
|
||||
? (shada_idx == -1
|
||||
? ((shada_idx = findoption((char_u *) "shada")))
|
||||
: shada_idx)
|
||||
: opt_idx);
|
||||
for (s = p_shada; *s; ) {
|
||||
/* Check it's a valid character */
|
||||
if (vim_strchr((char_u *)"!\"%'/:<@cfhnrs", *s) == NULL) {
|
||||
|
@ -202,4 +202,31 @@ describe('ShaDa support code', function()
|
||||
nvim_command('wshada! ' .. shada_fname)
|
||||
eq({}, find_file(fname))
|
||||
end)
|
||||
|
||||
it('is able to set &shada after &viminfo', function()
|
||||
meths.set_option('viminfo', '\'10')
|
||||
eq('\'10', meths.get_option('viminfo'))
|
||||
eq('\'10', meths.get_option('shada'))
|
||||
meths.set_option('shada', '')
|
||||
eq('', meths.get_option('viminfo'))
|
||||
eq('', meths.get_option('shada'))
|
||||
end)
|
||||
|
||||
it('is able to set all& after setting &shada', function()
|
||||
meths.set_option('shada', '\'10')
|
||||
eq('\'10', meths.get_option('viminfo'))
|
||||
eq('\'10', meths.get_option('shada'))
|
||||
nvim_command('set all&')
|
||||
eq('!,\'100,<50,s10,h', meths.get_option('viminfo'))
|
||||
eq('!,\'100,<50,s10,h', meths.get_option('shada'))
|
||||
end)
|
||||
|
||||
it('is able to set &shada after &viminfo using :set', function()
|
||||
nvim_command('set viminfo=\'10')
|
||||
eq('\'10', meths.get_option('viminfo'))
|
||||
eq('\'10', meths.get_option('shada'))
|
||||
nvim_command('set shada=')
|
||||
eq('', meths.get_option('viminfo'))
|
||||
eq('', meths.get_option('shada'))
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user