aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFamiu Haque <famiuhaque@proton.me>2023-10-16 12:15:33 +0600
committerFamiu Haque <famiuhaque@proton.me>2023-10-17 00:08:47 +0600
commit3642f2fb44b6a3681e6a637671690258aa83cc62 (patch)
tree862343ee373ec656b0647b93465e255aec44b688
parentf1a58a8dcc241e18305e7c103fb97cec64a3e46d (diff)
downloadrneovim-3642f2fb44b6a3681e6a637671690258aa83cc62.tar.gz
rneovim-3642f2fb44b6a3681e6a637671690258aa83cc62.tar.bz2
rneovim-3642f2fb44b6a3681e6a637671690258aa83cc62.zip
refactor(options): make `did_set_shada` a normal option callback
-rw-r--r--src/nvim/options.lua1
-rw-r--r--src/nvim/optionstr.c21
2 files changed, 6 insertions, 16 deletions
diff --git a/src/nvim/options.lua b/src/nvim/options.lua
index ec8450ba17..8d12d860d8 100644
--- a/src/nvim/options.lua
+++ b/src/nvim/options.lua
@@ -6824,6 +6824,7 @@ return {
},
{
abbreviation = 'sd',
+ cb = 'did_set_shada',
defaults = {
if_true = "!,'100,<50,s10,h",
doc = [[for
diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c
index 936062b806..2e90b6b4ae 100644
--- a/src/nvim/optionstr.c
+++ b/src/nvim/optionstr.c
@@ -2119,20 +2119,11 @@ int expand_set_sessionoptions(optexpand_T *args, int *numMatches, char ***matche
matches);
}
-static const char *did_set_shada(vimoption_T **opt, int *opt_idx, bool *free_oldval, char *errbuf,
- size_t errbuflen)
-{
- static int shada_idx = -1;
- // TODO(ZyX-I): Remove this code in the future, alongside with &viminfo
- // option.
- *opt_idx = (((*opt)->fullname[0] == 'v')
- ? (shada_idx == -1 ? ((shada_idx = findoption("shada"))) : shada_idx)
- : *opt_idx);
- *opt = get_option(*opt_idx);
- // Update free_oldval now that we have the opt_idx for 'shada', otherwise
- // there would be a disconnect between the check for P_ALLOCED at the start
- // of the function and the set of P_ALLOCED at the end of the function.
- *free_oldval = ((*opt)->flags & P_ALLOCED);
+const char *did_set_shada(optset_T *args)
+{
+ char *errbuf = args->os_errbuf;
+ size_t errbuflen = args->os_errbuflen;
+
for (char *s = p_shada; *s;) {
// Check it's a valid character
if (vim_strchr("!\"%'/:<@cfhnrs", (uint8_t)(*s)) == NULL) {
@@ -2784,8 +2775,6 @@ const char *did_set_string_option(buf_T *buf, win_T *win, int opt_idx, char **va
// The 'isident', 'iskeyword', 'isprint' and 'isfname' options may
// change the character table. On failure, this needs to be restored.
restore_chartab = args.os_restore_chartab;
- } else if (varp == &p_shada) { // 'shada'
- errmsg = did_set_shada(&opt, &opt_idx, &free_oldval, errbuf, errbuflen);
}
// If an error is detected, restore the previous value.