diff options
author | Thomas Vigouroux <tomvig38@gmail.com> | 2020-11-24 07:10:55 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-24 07:10:55 +0100 |
commit | dd876a15489beea14cd35417ca5147cb5316e9ce (patch) | |
tree | 091e9b1ddf9451609e513c7bdc2d20865a1e9086 | |
parent | 2d36b62eda16ae1cf370f4107530fa65d2b1bce4 (diff) | |
parent | 7eb0c16dc8433e27ce0c8573a80284ec044d5ef4 (diff) | |
download | rneovim-dd876a15489beea14cd35417ca5147cb5316e9ce.tar.gz rneovim-dd876a15489beea14cd35417ca5147cb5316e9ce.tar.bz2 rneovim-dd876a15489beea14cd35417ca5147cb5316e9ce.zip |
Merge pull request #13322 from teto/remove_curwin
refactor: pass window to was_set_insecurely
-rw-r--r-- | src/nvim/buffer.c | 4 | ||||
-rw-r--r-- | src/nvim/eval.c | 3 | ||||
-rw-r--r-- | src/nvim/fold.c | 9 | ||||
-rw-r--r-- | src/nvim/hardcopy.c | 2 | ||||
-rw-r--r-- | src/nvim/indent.c | 3 | ||||
-rw-r--r-- | src/nvim/ops.c | 4 | ||||
-rw-r--r-- | src/nvim/option.c | 24 | ||||
-rw-r--r-- | src/nvim/path.c | 8 | ||||
-rw-r--r-- | src/nvim/screen.c | 9 | ||||
-rw-r--r-- | test/functional/ui/fold_spec.lua | 27 |
10 files changed, 61 insertions, 32 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 99cdde300d..ffa44c33cd 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -3198,7 +3198,7 @@ void maketitle(void) int use_sandbox = false; int save_called_emsg = called_emsg; - use_sandbox = was_set_insecurely((char_u *)"titlestring", 0); + use_sandbox = was_set_insecurely(curwin, (char_u *)"titlestring", 0); called_emsg = false; build_stl_str_hl(curwin, (char_u *)buf, sizeof(buf), p_titlestring, use_sandbox, @@ -3309,7 +3309,7 @@ void maketitle(void) int use_sandbox = false; int save_called_emsg = called_emsg; - use_sandbox = was_set_insecurely((char_u *)"iconstring", 0); + use_sandbox = was_set_insecurely(curwin, (char_u *)"iconstring", 0); called_emsg = false; build_stl_str_hl(curwin, icon_str, sizeof(buf), p_iconstring, use_sandbox, diff --git a/src/nvim/eval.c b/src/nvim/eval.c index 402211080b..054b788940 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -1178,8 +1178,7 @@ int eval_foldexpr(char_u *arg, int *cp) { typval_T tv; varnumber_T retval; - int use_sandbox = was_set_insecurely((char_u *)"foldexpr", - OPT_LOCAL); + int use_sandbox = was_set_insecurely(curwin, (char_u *)"foldexpr", OPT_LOCAL); ++emsg_off; if (use_sandbox) diff --git a/src/nvim/fold.c b/src/nvim/fold.c index 5e28ca6538..654aa6d5ba 100644 --- a/src/nvim/fold.c +++ b/src/nvim/fold.c @@ -1835,10 +1835,11 @@ char_u *get_foldtext(win_T *wp, linenr_T lnum, linenr_T lnume, curwin = wp; curbuf = wp->w_buffer; - ++emsg_silent; /* handle exceptions, but don't display errors */ - text = eval_to_string_safe(wp->w_p_fdt, NULL, - was_set_insecurely((char_u *)"foldtext", OPT_LOCAL)); - --emsg_silent; + emsg_silent++; // handle exceptions, but don't display errors + text = eval_to_string_safe( + wp->w_p_fdt, NULL, + was_set_insecurely(wp, (char_u *)"foldtext", OPT_LOCAL)); + emsg_silent--; if (text == NULL || did_emsg) got_fdt_error = TRUE; diff --git a/src/nvim/hardcopy.c b/src/nvim/hardcopy.c index 4a64cc31b1..2c954008b3 100644 --- a/src/nvim/hardcopy.c +++ b/src/nvim/hardcopy.c @@ -546,7 +546,7 @@ static void prt_header(prt_settings_T *const psettings, const int pagenum, curwin->w_botline = lnum + 63; printer_page_num = pagenum; - use_sandbox = was_set_insecurely((char_u *)"printheader", 0); + use_sandbox = was_set_insecurely(curwin, (char_u *)"printheader", 0); build_stl_str_hl(curwin, tbuf, (size_t)width + IOSIZE, p_header, use_sandbox, ' ', width, NULL, NULL); diff --git a/src/nvim/indent.c b/src/nvim/indent.c index 9e6693afdf..fae971b3b3 100644 --- a/src/nvim/indent.c +++ b/src/nvim/indent.c @@ -453,7 +453,8 @@ int get_expr_indent(void) colnr_T save_curswant; int save_set_curswant; int save_State; - int use_sandbox = was_set_insecurely((char_u *)"indentexpr", OPT_LOCAL); + int use_sandbox = was_set_insecurely( + curwin, (char_u *)"indentexpr", OPT_LOCAL); // Save and restore cursor position and curswant, in case it was changed // * via :normal commands. diff --git a/src/nvim/ops.c b/src/nvim/ops.c index 9e7d81fc82..40dd5f0b5c 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -4117,8 +4117,8 @@ fex_format( int c /* character to be inserted */ ) { - int use_sandbox = was_set_insecurely((char_u *)"formatexpr", - OPT_LOCAL); + int use_sandbox = was_set_insecurely( + curwin, (char_u *)"formatexpr", OPT_LOCAL); int r; char_u *fex; diff --git a/src/nvim/option.c b/src/nvim/option.c index 6149331763..c1b071b04e 100644 --- a/src/nvim/option.c +++ b/src/nvim/option.c @@ -952,7 +952,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; } @@ -1886,7 +1886,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 @@ -2013,7 +2013,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))) { @@ -2352,12 +2352,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()"); @@ -2366,16 +2366,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. diff --git a/src/nvim/path.c b/src/nvim/path.c index 793f917f06..f52fbbd5c8 100644 --- a/src/nvim/path.c +++ b/src/nvim/path.c @@ -1610,10 +1610,10 @@ void simplify_filename(char_u *filename) static char *eval_includeexpr(const char *const ptr, const size_t len) { - set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t) len); - char *res = (char *) eval_to_string_safe( - curbuf->b_p_inex, NULL, was_set_insecurely((char_u *)"includeexpr", - OPT_LOCAL)); + set_vim_var_string(VV_FNAME, ptr, (ptrdiff_t)len); + char *res = (char *)eval_to_string_safe( + curbuf->b_p_inex, NULL, + was_set_insecurely(curwin, (char_u *)"includeexpr", OPT_LOCAL)); set_vim_var_string(VV_FNAME, NULL, 0); return res; } diff --git a/src/nvim/screen.c b/src/nvim/screen.c index 5f09912116..425458f210 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -2196,6 +2196,7 @@ static int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, } if (wp->w_p_spell + && foldinfo.fi_lines == 0 && *wp->w_s->b_p_spl != NUL && !GA_EMPTY(&wp->w_s->b_langp) && *(char **)(wp->w_s->b_langp.ga_data) != NULL) { @@ -5205,7 +5206,7 @@ win_redr_custom ( fillchar = ' '; attr = HL_ATTR(HLF_TPF); maxwidth = Columns; - use_sandbox = was_set_insecurely((char_u *)"tabline", 0); + use_sandbox = was_set_insecurely(wp, (char_u *)"tabline", 0); } else { row = W_ENDROW(wp); fillchar = fillchar_status(&attr, wp); @@ -5236,14 +5237,14 @@ win_redr_custom ( attr = HL_ATTR(HLF_MSG); } - use_sandbox = was_set_insecurely((char_u *)"rulerformat", 0); + use_sandbox = was_set_insecurely(wp, (char_u *)"rulerformat", 0); } else { if (*wp->w_p_stl != NUL) stl = wp->w_p_stl; else stl = p_stl; - use_sandbox = was_set_insecurely((char_u *)"statusline", - *wp->w_p_stl == NUL ? 0 : OPT_LOCAL); + use_sandbox = was_set_insecurely( + wp, (char_u *)"statusline", *wp->w_p_stl == NUL ? 0 : OPT_LOCAL); } col += wp->w_wincol; diff --git a/test/functional/ui/fold_spec.lua b/test/functional/ui/fold_spec.lua index 669ec5d3ed..018049d2f4 100644 --- a/test/functional/ui/fold_spec.lua +++ b/test/functional/ui/fold_spec.lua @@ -117,6 +117,33 @@ describe("folded lines", function() end end) + it("work with spell", function() + command("set spell") + insert([[ + This is a + valid English + sentence composed by + an exhausted developer + in his cave. + ]]) + + feed("gg") + feed("zf3j") + if not multigrid then + -- screen:snapshot_util() + screen:expect{grid=[[ + {5:^+-- 4 lines: This is a······················}| + in his cave. | + | + {1:~ }| + {1:~ }| + {1:~ }| + {1:~ }| + | + ]]} + end + end) + it("works with multibyte fillchars", function() insert([[ aa |