summaryrefslogtreecommitdiff
path: root/src/option.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2018-10-02 14:45:10 +0200
committerBram Moolenaar <Bram@vim.org>2018-10-02 14:45:10 +0200
commit35bc7d6c52f516b60d683bf9f0f57266d86e25b9 (patch)
tree65626a9c0ed7f4562d1168aeb25b7f31d0a64963 /src/option.c
parent54ade9f7e3b5cfd582aee03591a2b0884b9a96ab (diff)
downloadvim-git-8.1.0445.tar.gz
patch 8.1.0445: setting 'term' does not store location for termcap optionsv8.1.0445
Problem: Setting 'term' does not store location for termcap options. Solution: Set the script context for termcap options that are changed when 'term' is set.
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c68
1 files changed, 55 insertions, 13 deletions
diff --git a/src/option.c b/src/option.c
index 69e026db2..d70dc7b5d 100644
--- a/src/option.c
+++ b/src/option.c
@@ -1755,12 +1755,12 @@ static struct vimoption options[] =
{"langmap", "lmap", P_STRING|P_VI_DEF|P_ONECOMMA|P_NODUP|P_SECURE,
#ifdef FEAT_LANGMAP
(char_u *)&p_langmap, PV_NONE,
- {(char_u *)"", /* unmatched } */
+ {(char_u *)"", (char_u *)0L}
#else
(char_u *)NULL, PV_NONE,
- {(char_u *)NULL,
+ {(char_u *)NULL, (char_u *)0L}
#endif
- (char_u *)0L} SCTX_INIT},
+ SCTX_INIT},
{"langmenu", "lm", P_STRING|P_VI_DEF|P_NFNAME,
#if defined(FEAT_MENU) && defined(FEAT_MULTI_LANG)
(char_u *)&p_lm, PV_NONE,
@@ -5790,20 +5790,32 @@ check_string_option(char_u **pp)
}
/*
- * Mark a terminal option as allocated, found by a pointer into term_strings[].
+ * Return the option index found by a pointer into term_strings[].
+ * Return -1 if not found.
*/
- void
-set_term_option_alloced(char_u **p)
+ int
+get_term_opt_idx(char_u **p)
{
- int opt_idx;
+ int opt_idx;
for (opt_idx = 1; options[opt_idx].fullname != NULL; opt_idx++)
if (options[opt_idx].var == (char_u *)p)
- {
- options[opt_idx].flags |= P_ALLOCED;
- return;
- }
- return; /* cannot happen: didn't find it! */
+ return opt_idx;
+ return -1; // cannot happen: didn't find it!
+}
+
+/*
+ * Mark a terminal option as allocated, found by a pointer into term_strings[].
+ * Return the option index or -1 if not found.
+ */
+ int
+set_term_option_alloced(char_u **p)
+{
+ int opt_idx = get_term_opt_idx(p);
+
+ if (opt_idx >= 0)
+ options[opt_idx].flags |= P_ALLOCED;
+ return opt_idx;
}
#if defined(FEAT_EVAL) || defined(PROTO)
@@ -8237,6 +8249,32 @@ set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx)
curwin->w_p_script_ctx[indir & PV_MASK] = new_script_ctx;
}
}
+
+/*
+ * Set the script_ctx for a termcap option.
+ * "name" must be the two character code, e.g. "RV".
+ * When "name" is NULL use "opt_idx".
+ */
+ void
+set_term_option_sctx_idx(char *name, int opt_idx)
+{
+ char_u buf[5];
+ int idx;
+
+ if (name == NULL)
+ idx = opt_idx;
+ else
+ {
+ buf[0] = 't';
+ buf[1] = '_';
+ buf[2] = name[0];
+ buf[3] = name[1];
+ buf[4] = 0;
+ idx = findoption(buf);
+ }
+ if (idx >= 0)
+ set_option_sctx_idx(idx, OPT_GLOBAL, current_sctx);
+}
#endif
/*
@@ -10445,7 +10483,7 @@ free_termoptions(void)
{
struct vimoption *p;
- for (p = &options[0]; p->fullname != NULL; p++)
+ for (p = options; p->fullname != NULL; p++)
if (istermoption(p))
{
if (p->flags & P_ALLOCED)
@@ -10455,6 +10493,10 @@ free_termoptions(void)
*(char_u **)(p->var) = empty_option;
p->def_val[VI_DEFAULT] = empty_option;
p->flags &= ~(P_ALLOCED|P_DEF_ALLOCED);
+#ifdef FEAT_EVAL
+ // remember where the option was cleared
+ set_option_sctx_idx((int)(p - options), OPT_GLOBAL, current_sctx);
+#endif
}
clear_termcodes();
}