Skip to content

Commit b38700a

Browse files
Millychrisbra
authored andcommitted
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: #15911 Signed-off-by: Milly <milly.ca@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
1 parent 231480f commit b38700a

6 files changed

Lines changed: 25 additions & 11 deletions

File tree

src/indent.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,11 +869,15 @@ get_number_indent(linenr_T lnum)
869869

870870
#if defined(FEAT_LINEBREAK) || defined(PROTO)
871871
/*
872+
* Check "briopt" as 'breakindentopt' and update the members of "wp".
872873
* This is called when 'breakindentopt' is changed and when a window is
873874
* initialized.
875+
* Returns FAIL for failure, OK otherwise.
874876
*/
875877
int
876-
briopt_check(win_T *wp)
878+
briopt_check(
879+
char_u *briopt, // when NULL: use "wp->w_p_briopt"
880+
win_T *wp) // when NULL: only check "briopt"
877881
{
878882
char_u *p;
879883
int bri_shift = 0;
@@ -882,7 +886,11 @@ briopt_check(win_T *wp)
882886
int bri_list = 0;
883887
int bri_vcol = 0;
884888

885-
p = wp->w_p_briopt;
889+
if (briopt != NULL)
890+
p = briopt;
891+
else
892+
p = wp->w_p_briopt;
893+
886894
while (*p != NUL)
887895
{
888896
// Note: Keep this in sync with p_briopt_values
@@ -918,6 +926,9 @@ briopt_check(win_T *wp)
918926
++p;
919927
}
920928

929+
if (wp == NULL)
930+
return OK;
931+
921932
wp->w_briopt_shift = bri_shift;
922933
wp->w_briopt_min = bri_min;
923934
wp->w_briopt_sbr = bri_sbr;

src/option.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6751,7 +6751,7 @@ after_copy_winopt(win_T *wp)
67516751
else
67526752
wp->w_skipcol = 0;
67536753
#ifdef FEAT_LINEBREAK
6754-
briopt_check(wp);
6754+
briopt_check(NULL, wp);
67556755
#endif
67566756
#ifdef FEAT_SYN_HL
67576757
fill_culopt_flags(NULL, wp);

src/optionstr.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1235,17 +1235,19 @@ did_set_breakat(optset_T *args UNUSED)
12351235
* The 'breakindentopt' option is changed.
12361236
*/
12371237
char *
1238-
did_set_breakindentopt(optset_T *args UNUSED)
1238+
did_set_breakindentopt(optset_T *args)
12391239
{
1240-
char *errmsg = NULL;
1240+
char_u **varp = (char_u **)args->os_varp;
1241+
1242+
if (briopt_check(*varp, varp == &curwin->w_p_briopt ? curwin : NULL)
1243+
== FAIL)
1244+
return e_invalid_argument;
12411245

1242-
if (briopt_check(curwin) == FAIL)
1243-
errmsg = e_invalid_argument;
12441246
// list setting requires a redraw
1245-
if (curwin->w_briopt_list)
1247+
if (varp == &curwin->w_p_briopt && curwin->w_briopt_list)
12461248
redraw_all_later(UPD_NOT_VALID);
12471249

1248-
return errmsg;
1250+
return NULL;
12491251
}
12501252

12511253
int

src/proto/indent.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ int get_indent_str(char_u *ptr, int ts, int no_ts);
1818
int get_indent_str_vtab(char_u *ptr, int ts, int *vts, int no_ts);
1919
int set_indent(int size, int flags);
2020
int get_number_indent(linenr_T lnum);
21-
int briopt_check(win_T *wp);
21+
int briopt_check(char_u *briopt, win_T *wp);
2222
int get_breakindent_win(win_T *wp, char_u *line);
2323
int inindent(int extra);
2424
void op_reindent(oparg_T *oap, int (*how)(void));

src/testdir/gen_opt_test.vim

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ endwhile
4545
let skip_setglobal_reasons = #{
4646
\ iminsert: 'The global value is always overwritten by the local value',
4747
\ imsearch: 'The global value is always overwritten by the local value',
48-
\ breakindentopt: 'TODO: fix missing error handling for setglobal',
4948
\ conceallevel: 'TODO: fix missing error handling for setglobal',
5049
\ foldcolumn: 'TODO: fix missing error handling for setglobal',
5150
\ numberwidth: 'TODO: fix missing error handling for setglobal',

src/version.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,8 @@ static char *(features[]) =
704704

705705
static int included_patches[] =
706706
{ /* Add new patch number below this line */
707+
/**/
708+
806,
707709
/**/
708710
805,
709711
/**/

0 commit comments

Comments
 (0)