aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/option.c11
-rw-r--r--test/functional/shada/shada_spec.lua27
2 files changed, 38 insertions, 0 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 653b217485..cbb22a0546 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -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) {
diff --git a/test/functional/shada/shada_spec.lua b/test/functional/shada/shada_spec.lua
index 7a30d3b87d..2bc855a239 100644
--- a/test/functional/shada/shada_spec.lua
+++ b/test/functional/shada/shada_spec.lua
@@ -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)