aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/option.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r--src/nvim/option.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c
index ed9128dbbf..07d3561990 100644
--- a/src/nvim/option.c
+++ b/src/nvim/option.c
@@ -200,7 +200,7 @@ typedef struct vimoption {
// local option: indirect option index
char_u *def_val[2]; // default values for variable (vi and vim)
LastSet last_set; // script in which the option was last set
-# define SCRIPTID_INIT , 0
+# define SCTX_INIT , { 0, 0 }
} vimoption_T;
#define VI_DEFAULT 0 // def_val[VI_DEFAULT] is Vi default value
@@ -896,7 +896,7 @@ set_option_default(
*flagsp = *flagsp & ~P_INSECURE;
}
- set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
+ set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
}
/*
@@ -1384,10 +1384,10 @@ int do_set(
if (varp == options[opt_idx].var) {
option_last_set_msg(options[opt_idx].last_set);
} else if ((int)options[opt_idx].indir & PV_WIN) {
- option_last_set_msg(curwin->w_p_scriptID[
+ option_last_set_msg(curwin->w_p_script_ctx[
(int)options[opt_idx].indir & PV_MASK]);
} else if ((int)options[opt_idx].indir & PV_BUF) {
- option_last_set_msg(curbuf->b_p_scriptID[
+ option_last_set_msg(curbuf->b_p_script_ctx[
(int)options[opt_idx].indir & PV_MASK]);
}
}
@@ -2359,13 +2359,12 @@ static void redraw_titles(void)
static int shada_idx = -1;
-/*
- * Set a string option to a new value (without checking the effect).
- * The string is copied into allocated memory.
- * if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
- * When "set_sid" is zero set the scriptID to current_SID. When "set_sid" is
- * SID_NONE don't set the scriptID. Otherwise set the scriptID to "set_sid".
- */
+// Set a string option to a new value (without checking the effect).
+// The string is copied into allocated memory.
+// if ("opt_idx" == -1) "name" is used, otherwise "opt_idx" is used.
+// When "set_sid" is zero set the scriptID to current_sctx.sc_sid. When
+// "set_sid" is SID_NONE don't set the scriptID. Otherwise set the scriptID to
+// "set_sid".
void
set_string_option_direct(
char_u *name,
@@ -2417,9 +2416,17 @@ set_string_option_direct(
free_string_option(*varp);
*varp = empty_option;
}
- if (set_sid != SID_NONE)
- set_option_scriptID_idx(idx, opt_flags,
- set_sid == 0 ? current_SID : set_sid);
+ if (set_sid != SID_NONE) {
+ sctx_T script_ctx;
+
+ if (set_sid == 0) {
+ script_ctx = current_sctx;
+ } else {
+ script_ctx.sc_sid = set_sid;
+ script_ctx.sc_lnum = 0;
+ }
+ set_option_sctx_idx(idx, opt_flags, script_ctx);
+ }
}
}
@@ -3296,12 +3303,10 @@ ambw_end:
}
} else {
// Remember where the option was set.
- set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
- /*
- * Free string options that are in allocated memory.
- * Use "free_oldval", because recursiveness may change the flags under
- * our fingers (esp. init_highlight()).
- */
+ set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
+ // Free string options that are in allocated memory.
+ // Use "free_oldval", because recursiveness may change the flags under
+ // our fingers (esp. init_highlight()).
if (free_oldval) {
free_string_option(oldval);
}
@@ -3786,15 +3791,14 @@ static bool parse_winhl_opt(win_T *wp)
return true;
}
-/*
- * Set the scriptID for an option, taking care of setting the buffer- or
- * window-local value.
- */
-static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
+// Set the script_ctx for an option, taking care of setting the buffer- or
+// window-local value.
+static void set_option_sctx_idx(int opt_idx, int opt_flags, sctx_T script_ctx)
{
int both = (opt_flags & (OPT_LOCAL | OPT_GLOBAL)) == 0;
int indir = (int)options[opt_idx].indir;
- const LastSet last_set = { id, current_channel_id };
+ const LastSet last_set = { .script_ctx =
+ { script_ctx.sc_sid, sourcing_lnum }, current_channel_id };
// Remember where the option was set. For local options need to do that
// in the buffer or window structure.
@@ -3803,9 +3807,9 @@ static void set_option_scriptID_idx(int opt_idx, int opt_flags, int id)
}
if (both || (opt_flags & OPT_LOCAL)) {
if (indir & PV_BUF) {
- curbuf->b_p_scriptID[indir & PV_MASK] = last_set;
+ curbuf->b_p_script_ctx[indir & PV_MASK] = last_set;
} else if (indir & PV_WIN) {
- curwin->w_p_scriptID[indir & PV_MASK] = last_set;
+ curwin->w_p_script_ctx[indir & PV_MASK] = last_set;
}
}
}
@@ -3832,7 +3836,7 @@ static char *set_bool_option(const int opt_idx, char_u *const varp,
*(int *)varp = value; // set the new value
// Remember where the option was set.
- set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
+ set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
// May set global value for local option.
@@ -4310,7 +4314,7 @@ static char *set_num_option(int opt_idx, char_u *varp, long value,
*pp = value;
// Remember where the option was set.
- set_option_scriptID_idx(opt_idx, opt_flags, current_SID);
+ set_option_sctx_idx(opt_idx, opt_flags, current_sctx);
// For these options we want to fix some invalid values.
if (pp == &p_window) {