neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit 6b63fe798b7481edd8e3b0ed75a33bf297ca2856
parent 5436d9b3c6c537b243ea6af4f1acc143bf94de1c
Author: zeertzjq <zeertzjq@outlook.com>
Date:   Thu, 24 Oct 2024 06:31:09 +0800

vim-patch:9.1.0806: tests: no error check when setting global 'briopt'

Problem:  tests: no error check when setting global 'briopt'
Solution: also parse and check global 'briopt' value (Milly)

closes: vim/vim#15911

https://github.com/vim/vim/commit/b38700ac81d90a652e5c8495056dd78df5babdde

Co-authored-by: Milly <milly.ca@gmail.com>

Diffstat:
Msrc/nvim/indent.c | 20++++++++++++++++++--
Msrc/nvim/option.c | 2+-
Msrc/nvim/optionstr.c | 7+++++--
Mtest/old/testdir/gen_opt_test.vim | 1-
4 files changed, 24 insertions(+), 6 deletions(-)

diff --git a/src/nvim/indent.c b/src/nvim/indent.c @@ -769,9 +769,15 @@ int get_number_indent(linenr_T lnum) return (int)col; } +/// Check "briopt" as 'breakindentopt' and update the members of "wp". /// This is called when 'breakindentopt' is changed and when a window is /// initialized -bool briopt_check(win_T *wp) +/// +/// @param briopt when NULL: use "wp->w_p_briopt" +/// @param wp when NULL: only check "briopt" +/// +/// @return FAIL for failure, OK otherwise. +bool briopt_check(char *briopt, win_T *wp) { int bri_shift = 0; int bri_min = 20; @@ -779,7 +785,13 @@ bool briopt_check(win_T *wp) int bri_list = 0; int bri_vcol = 0; - char *p = wp->w_p_briopt; + char *p = empty_string_option; + if (briopt != NULL) { + p = briopt; + } else if (wp != NULL) { + p = wp->w_p_briopt; + } + while (*p != NUL) { // Note: Keep this in sync with p_briopt_values if (strncmp(p, "shift:", 6) == 0 @@ -807,6 +819,10 @@ bool briopt_check(win_T *wp) } } + if (wp == NULL) { + return OK; + } + wp->w_briopt_shift = bri_shift; wp->w_briopt_min = bri_min; wp->w_briopt_sbr = bri_sbr; diff --git a/src/nvim/option.c b/src/nvim/option.c @@ -5112,7 +5112,7 @@ void didset_window_options(win_T *wp, bool valid_cursor) wp->w_skipcol = 0; } check_colorcolumn(NULL, wp); - briopt_check(wp); + briopt_check(NULL, wp); fill_culopt_flags(NULL, wp); set_chars_option(wp, wp->w_p_fcs, kFillchars, true, NULL, 0); set_chars_option(wp, wp->w_p_lcs, kListchars, true, NULL, 0); diff --git a/src/nvim/optionstr.c b/src/nvim/optionstr.c @@ -717,11 +717,14 @@ const char *did_set_breakat(optset_T *args FUNC_ATTR_UNUSED) const char *did_set_breakindentopt(optset_T *args) { win_T *win = (win_T *)args->os_win; - if (briopt_check(win) == FAIL) { + char **varp = (char **)args->os_varp; + + if (briopt_check(*varp, varp == &win->w_p_briopt ? win : NULL) == FAIL) { return e_invarg; } + // list setting requires a redraw - if (win == curwin && win->w_briopt_list) { + if (varp == &win->w_p_briopt && win->w_briopt_list) { redraw_all_later(UPD_NOT_VALID); } diff --git a/test/old/testdir/gen_opt_test.vim b/test/old/testdir/gen_opt_test.vim @@ -45,7 +45,6 @@ endwhile let skip_setglobal_reasons = #{ \ iminsert: 'The global value is always overwritten by the local value', \ imsearch: 'The global value is always overwritten by the local value', - \ breakindentopt: 'TODO: fix missing error handling for setglobal', \ conceallevel: 'TODO: fix missing error handling for setglobal', \ foldcolumn: 'TODO: fix missing error handling for setglobal', \ numberwidth: 'TODO: fix missing error handling for setglobal',