Skip to content

Commit 6bfc475

Browse files
committed
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)
1 parent b4893b8 commit 6bfc475

3 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/popupwin.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -873,18 +873,13 @@ apply_general_options(win_T *wp, dict_T *dict)
873873
handle_moved_argument(wp, di, TRUE);
874874
}
875875

876-
di = dict_find(dict, (char_u *)"cursorline", -1);
877-
if (di != NULL)
876+
nr = dict_get_bool(dict, (char_u *)"cursorline", -1);
877+
if (nr != -1)
878878
{
879-
if (di->di_tv.v_type == VAR_NUMBER)
880-
{
881-
if (di->di_tv.vval.v_number != 0)
882-
wp->w_popup_flags |= POPF_CURSORLINE;
883-
else
884-
wp->w_popup_flags &= ~POPF_CURSORLINE;
885-
}
879+
if (nr != 0)
880+
wp->w_popup_flags |= POPF_CURSORLINE;
886881
else
887-
semsg(_(e_invargval), "cursorline");
882+
wp->w_popup_flags &= ~POPF_CURSORLINE;
888883
}
889884

890885
di = dict_find(dict, (char_u *)"filter", -1);

src/testdir/test_popupwin.vim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,6 +2978,10 @@ func Test_popup_cursorline()
29782978
call assert_equal(1, popup_getoptions(winid).cursorline)
29792979
call popup_close(winid)
29802980

2981+
let winid = popup_create('some text', #{ cursorline: v:true, })
2982+
call assert_equal(1, popup_getoptions(winid).cursorline)
2983+
call popup_close(winid)
2984+
29812985
let winid = popup_create('some text', #{ cursorline: 0, })
29822986
call assert_equal(0, popup_getoptions(winid).cursorline)
29832987
call popup_close(winid)
@@ -3112,6 +3116,15 @@ func Test_popup_cursorline()
31123116
call delete('XtestPopupCursorLine')
31133117
endfunc
31143118

3119+
def Test_popup_cursorline_vim9()
3120+
var winid = popup_create('some text', { cursorline: true, })
3121+
assert_equal(1, popup_getoptions(winid).cursorline)
3122+
popup_close(winid)
3123+
3124+
assert_fails("popup_create('some text', { cursorline: 2, })", 'E1023:')
3125+
popup_clear()
3126+
enddef
3127+
31153128
func Test_previewpopup()
31163129
CheckScreendump
31173130
CheckFeature quickfix

src/version.c

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

751751
static int included_patches[] =
752752
{ /* Add new patch number below this line */
753+
/**/
754+
2541,
753755
/**/
754756
2540,
755757
/**/

0 commit comments

Comments
 (0)