changeset 23998:0967c54ff3b2 v8.2.2541

patch 8.2.2541: popup_create() does not allow boolean for "cursorline" Commit: https://github.com/vim/vim/commit/6bfc475f717aa0412d13163d47ff6210fa611fb5 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Feb 21 23:12:18 2021 +0100 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 https://github.com/vim/vim/issues/7869)
author Bram Moolenaar <Bram@vim.org>
date Sun, 21 Feb 2021 23:15:03 +0100
parents 74ed52d0f507
children ff467cccc34c
files src/popupwin.c src/testdir/test_popupwin.vim src/version.c
diffstat 3 files changed, 20 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/src/popupwin.c
+++ b/src/popupwin.c
@@ -873,18 +873,13 @@ apply_general_options(win_T *wp, dict_T 
 	handle_moved_argument(wp, di, TRUE);
     }
 
-    di = dict_find(dict, (char_u *)"cursorline", -1);
-    if (di != NULL)
+    nr = dict_get_bool(dict, (char_u *)"cursorline", -1);
+    if (nr != -1)
     {
-	if (di->di_tv.v_type == VAR_NUMBER)
-	{
-	    if (di->di_tv.vval.v_number != 0)
-		wp->w_popup_flags |= POPF_CURSORLINE;
-	    else
-		wp->w_popup_flags &= ~POPF_CURSORLINE;
-	}
+	if (nr != 0)
+	    wp->w_popup_flags |= POPF_CURSORLINE;
 	else
-	    semsg(_(e_invargval), "cursorline");
+	    wp->w_popup_flags &= ~POPF_CURSORLINE;
     }
 
     di = dict_find(dict, (char_u *)"filter", -1);
--- a/src/testdir/test_popupwin.vim
+++ b/src/testdir/test_popupwin.vim
@@ -2978,6 +2978,10 @@ func Test_popup_cursorline()
   call assert_equal(1, popup_getoptions(winid).cursorline)
   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, })
   call assert_equal(0, popup_getoptions(winid).cursorline)
   call popup_close(winid)
@@ -3112,6 +3116,15 @@ func Test_popup_cursorline()
   call delete('XtestPopupCursorLine')
 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()
   CheckScreendump
   CheckFeature quickfix
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2541,
+/**/
     2540,
 /**/
     2539,