aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-08-23 17:59:54 +0800
committerzeertzjq <zeertzjq@outlook.com>2023-08-23 18:24:14 +0800
commit3f32cb88c2cf2bcc1ca95fe24a800abd9d731827 (patch)
tree458e1570cd195faae26ecd7fdafd2e2e1879d3c7 /src
parent0ba27bb51d3297aec43e78050cc3adcf6879db22 (diff)
downloadrneovim-3f32cb88c2cf2bcc1ca95fe24a800abd9d731827.tar.gz
rneovim-3f32cb88c2cf2bcc1ca95fe24a800abd9d731827.tar.bz2
rneovim-3f32cb88c2cf2bcc1ca95fe24a800abd9d731827.zip
vim-patch:9.0.1781: Problems when setting bin/paste option
Problem: Problems when setting bin/paste option Solution: When setting binary/paste, remember that this also affects depending options, so that :verbose set returns the right location. Mention if depending options for 'binary' or 'paste' have been reset indirectly. Add a test to verify it works. Also noticed as small bug, that the global option value for expandtab was not reset when paste option is set, so fix that while at it. closes: vim/vim#12837 closes: vim/vim#12879 https://github.com/vim/vim/commit/757593c07a4f4ac43eb6c6e52fc299abc9bc08bc Co-authored-by: Christian Brabandt <cb@256bit.org>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/option.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index 56881cbe58..3648601ab8 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -160,6 +160,14 @@ typedef enum {
# include "options.generated.h"
#endif
+static char *(p_bin_dep_opts[]) = {
+ "textwidth", "wrapmargin", "modeline", "expandtab", NULL
+};
+static char *(p_paste_dep_opts[]) = {
+ "autoindent", "expandtab", "ruler", "showmatch", "smarttab",
+ "softtabstop", "textwidth", "wrapmargin", "revins", "varsofttabstop", NULL
+};
+
void set_init_tablocal(void)
{
// susy baka: cmdheight calls itself OPT_GLOBAL but is really tablocal!
@@ -1681,6 +1689,9 @@ void set_options_bin(int oldval, int newval, int opt_flags)
p_et = p_et_nobin;
}
}
+
+ // Remember where the dependent option were reset
+ didset_options_sctx(opt_flags, p_bin_dep_opts);
}
/// Find the parameter represented by the given character (eg ', :, ", or /),
@@ -5608,6 +5619,7 @@ static void paste_option_changed(void)
p_wm = 0;
p_sts = 0;
p_ai = 0;
+ p_et = 0;
if (p_vsts) {
free_string_option(p_vsts);
}
@@ -5655,6 +5667,9 @@ static void paste_option_changed(void)
}
old_p_paste = p_paste;
+
+ // Remember where the dependent options were reset
+ didset_options_sctx((OPT_LOCAL | OPT_GLOBAL), p_paste_dep_opts);
}
/// vimrc_found() - Called when a vimrc or "VIMINIT" has been found.
@@ -5820,6 +5835,20 @@ int option_set_callback_func(char *optval, Callback *optcb)
return OK;
}
+static void didset_options_sctx(int opt_flags, char **buf)
+{
+ for (int i = 0;; i++) {
+ if (buf[i] == NULL) {
+ break;
+ }
+
+ int idx = findoption(buf[i]);
+ if (idx >= 0) {
+ set_option_sctx_idx(idx, opt_flags, current_sctx);
+ }
+ }
+}
+
/// Check if backspacing over something is allowed.
/// @param what BS_INDENT, BS_EOL, BS_START, or BS_NOSTOP
bool can_bs(int what)