diff options
author | Matthieu Coudron <mcoudron@hotmail.com> | 2020-11-18 22:52:49 +0100 |
---|---|---|
committer | Matthieu Coudron <mcoudron@hotmail.com> | 2020-11-23 21:06:56 +0100 |
commit | 4f1fc0f6d514980700152b7c05e5c92ec379f0d7 (patch) | |
tree | 56488620cbef1d2d13e7c9866364ea1d7292da17 /src/nvim/option.c | |
parent | 7dfeadb0fcbcedeafc357e60f0b7b2b8916afeaf (diff) | |
download | rneovim-4f1fc0f6d514980700152b7c05e5c92ec379f0d7.tar.gz rneovim-4f1fc0f6d514980700152b7c05e5c92ec379f0d7.tar.bz2 rneovim-4f1fc0f6d514980700152b7c05e5c92ec379f0d7.zip |
refactor: pass window to was_set_insecurely
working on get_foldtext and wanted to get rid of the curwin backup/restore.
Turns out it's not possible else f_foldtext is run on the same window.
Kept the cleanup anyway.
Diffstat (limited to 'src/nvim/option.c')
-rw-r--r-- | src/nvim/option.c | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/nvim/option.c b/src/nvim/option.c index 0a91687352..0996638158 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -945,7 +945,7 @@ set_option_default( } // The default value is not insecure. - uint32_t *flagsp = insecure_flag(opt_idx, opt_flags); + uint32_t *flagsp = insecure_flag(curwin, opt_idx, opt_flags); *flagsp = *flagsp & ~P_INSECURE; } @@ -1880,7 +1880,7 @@ int do_set( saved_newval = (newval != NULL) ? xstrdup((char *)newval) : 0; { - uint32_t *p = insecure_flag(opt_idx, opt_flags); + uint32_t *p = insecure_flag(curwin, opt_idx, opt_flags); const int secure_saved = secure; // When an option is set in the sandbox, from a @@ -2007,7 +2007,7 @@ static void did_set_option( /* When an option is set in the sandbox, from a modeline or in secure mode * set the P_INSECURE flag. Otherwise, if a new value is stored reset the * flag. */ - uint32_t *p = insecure_flag(opt_idx, opt_flags); + uint32_t *p = insecure_flag(curwin, opt_idx, opt_flags); if (!value_checked && (secure || sandbox != 0 || (opt_flags & OPT_MODELINE))) { @@ -2346,12 +2346,12 @@ static void check_string_option(char_u **pp) /// Return true when option "opt" was set from a modeline or in secure mode. /// Return false when it wasn't. /// Return -1 for an unknown option. -int was_set_insecurely(char_u *opt, int opt_flags) +int was_set_insecurely(win_T *const wp, char_u *opt, int opt_flags) { int idx = findoption((const char *)opt); if (idx >= 0) { - uint32_t *flagp = insecure_flag(idx, opt_flags); + uint32_t *flagp = insecure_flag(wp, idx, opt_flags); return (*flagp & P_INSECURE) != 0; } internal_error("was_set_insecurely()"); @@ -2360,16 +2360,16 @@ int was_set_insecurely(char_u *opt, int opt_flags) /// Get a pointer to the flags used for the P_INSECURE flag of option /// "opt_idx". For some local options a local flags field is used. -static uint32_t *insecure_flag(int opt_idx, int opt_flags) +static uint32_t *insecure_flag(win_T *const wp, int opt_idx, int opt_flags) { if (opt_flags & OPT_LOCAL) switch ((int)options[opt_idx].indir) { - case PV_STL: return &curwin->w_p_stl_flags; - case PV_FDE: return &curwin->w_p_fde_flags; - case PV_FDT: return &curwin->w_p_fdt_flags; - case PV_INDE: return &curbuf->b_p_inde_flags; - case PV_FEX: return &curbuf->b_p_fex_flags; - case PV_INEX: return &curbuf->b_p_inex_flags; + case PV_STL: return &wp->w_p_stl_flags; + case PV_FDE: return &wp->w_p_fde_flags; + case PV_FDT: return &wp->w_p_fdt_flags; + case PV_INDE: return &wp->w_buffer->b_p_inde_flags; + case PV_FEX: return &wp->w_buffer->b_p_fex_flags; + case PV_INEX: return &wp->w_buffer->b_p_inex_flags; } // Nothing special, return global flags field. |