diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-10-24 06:31:09 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-10-24 06:56:12 +0800 |
commit | 6b63fe798b7481edd8e3b0ed75a33bf297ca2856 (patch) | |
tree | 7227b779a906055a65123a3bbb650db3b2d5c72e | |
parent | 5436d9b3c6c537b243ea6af4f1acc143bf94de1c (diff) | |
download | rneovim-6b63fe798b7481edd8e3b0ed75a33bf297ca2856.tar.gz rneovim-6b63fe798b7481edd8e3b0ed75a33bf297ca2856.tar.bz2 rneovim-6b63fe798b7481edd8e3b0ed75a33bf297ca2856.zip |
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>
-rw-r--r-- | src/nvim/indent.c | 20 | ||||
-rw-r--r-- | src/nvim/option.c | 2 | ||||
-rw-r--r-- | src/nvim/optionstr.c | 7 | ||||
-rw-r--r-- | test/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 index b7e3842aad..58215f738c 100644 --- 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 index 8e6e068e96..933ee4ba75 100644 --- 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 index 0e63a8089d..23b70ab5ad 100644 --- 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 index c28284afdf..89ddf283d2 100644 --- 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', |