1
0
forked from aniani/vim

patch 8.2.2541: popup_create() does not allow boolean for "cursorline"

Problem:    Popup_create() does not allow boolean for "cursorline".
Solution:   Use dict_get_bool(). (issue #7869)
This commit is contained in:
Bram Moolenaar
2021-02-21 23:12:18 +01:00
parent b4893b8450
commit 6bfc475f71
3 changed files with 20 additions and 10 deletions

View File

@@ -873,18 +873,13 @@ apply_general_options(win_T *wp, dict_T *dict)
handle_moved_argument(wp, di, TRUE); handle_moved_argument(wp, di, TRUE);
} }
di = dict_find(dict, (char_u *)"cursorline", -1); nr = dict_get_bool(dict, (char_u *)"cursorline", -1);
if (di != NULL) if (nr != -1)
{ {
if (di->di_tv.v_type == VAR_NUMBER) if (nr != 0)
{ wp->w_popup_flags |= POPF_CURSORLINE;
if (di->di_tv.vval.v_number != 0)
wp->w_popup_flags |= POPF_CURSORLINE;
else
wp->w_popup_flags &= ~POPF_CURSORLINE;
}
else else
semsg(_(e_invargval), "cursorline"); wp->w_popup_flags &= ~POPF_CURSORLINE;
} }
di = dict_find(dict, (char_u *)"filter", -1); di = dict_find(dict, (char_u *)"filter", -1);

View File

@@ -2978,6 +2978,10 @@ func Test_popup_cursorline()
call assert_equal(1, popup_getoptions(winid).cursorline) call assert_equal(1, popup_getoptions(winid).cursorline)
call popup_close(winid) call popup_close(winid)
let winid = popup_create('some text', #{ cursorline: v:true, })
call assert_equal(1, popup_getoptions(winid).cursorline)
call popup_close(winid)
let winid = popup_create('some text', #{ cursorline: 0, }) let winid = popup_create('some text', #{ cursorline: 0, })
call assert_equal(0, popup_getoptions(winid).cursorline) call assert_equal(0, popup_getoptions(winid).cursorline)
call popup_close(winid) call popup_close(winid)
@@ -3112,6 +3116,15 @@ func Test_popup_cursorline()
call delete('XtestPopupCursorLine') call delete('XtestPopupCursorLine')
endfunc endfunc
def Test_popup_cursorline_vim9()
var winid = popup_create('some text', { cursorline: true, })
assert_equal(1, popup_getoptions(winid).cursorline)
popup_close(winid)
assert_fails("popup_create('some text', { cursorline: 2, })", 'E1023:')
popup_clear()
enddef
func Test_previewpopup() func Test_previewpopup()
CheckScreendump CheckScreendump
CheckFeature quickfix CheckFeature quickfix

View File

@@ -750,6 +750,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
2541,
/**/ /**/
2540, 2540,
/**/ /**/