]> granicus.if.org Git - vim/commitdiff
patch 8.1.2295: if buffer of popup is in another window cursorline sign shows v8.1.2295
authorBram Moolenaar <Bram@vim.org>
Tue, 12 Nov 2019 21:33:45 +0000 (22:33 +0100)
committerBram Moolenaar <Bram@vim.org>
Tue, 12 Nov 2019 21:33:45 +0000 (22:33 +0100)
Problem:    If buffer of popup is in another window cursorline sign shows.
Solution:   Check the group of the sign.

src/drawline.c
src/option.c
src/proto/option.pro
src/proto/sign.pro
src/screen.c
src/sign.c
src/testdir/dumps/Test_popupwin_cursorline_8.dump [new file with mode: 0644]
src/testdir/test_popupwin.vim
src/version.c

index 280285974770c45f747c259ad705831b18035b57..54163c7c9402d228e4932d2fa9345e4f4261b4e3 100644 (file)
@@ -671,7 +671,7 @@ win_line(
 #endif
 
 #ifdef FEAT_SIGNS
-    sign_present = buf_get_signattrs(wp->w_buffer, lnum, &sattr);
+    sign_present = buf_get_signattrs(wp, lnum, &sattr);
 #endif
 
 #ifdef LINE_ATTR
index 313882148f922098dfc640b1cb286f6034612b7d..c54fc82681c12ff1f8f86cb8e2d60d3fe171f9c4 100644 (file)
@@ -7293,31 +7293,6 @@ get_showbreak_value(win_T *win)
 }
 #endif
 
-#if defined(FEAT_SIGNS) || defined(PROTO)
-/*
- * Return TRUE when window "wp" has a column to draw signs in.
- */
-     int
-signcolumn_on(win_T *wp)
-{
-    // If 'signcolumn' is set to 'number', signs are displayed in the 'number'
-    // column (if present). Otherwise signs are to be displayed in the sign
-    // column.
-    if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u')
-       return wp->w_buffer->b_signlist != NULL && !wp->w_p_nu && !wp->w_p_rnu;
-
-    if (*wp->w_p_scl == 'n')
-       return FALSE;
-    if (*wp->w_p_scl == 'y')
-       return TRUE;
-    return (wp->w_buffer->b_signlist != NULL
-# ifdef FEAT_NETBEANS_INTG
-                       || wp->w_buffer->b_has_sign_column
-# endif
-                   );
-}
-#endif
-
 #if defined(FEAT_EVAL) || defined(PROTO)
 /*
  * Get window or buffer local options.
index b3c66ee118dec6681d13b1ec78cdb2e86176087e..b3250dca72ec17888e51ad918de1e677a45d21cc 100644 (file)
@@ -81,7 +81,6 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit);
 int briopt_check(win_T *wp);
 unsigned int get_bkc_value(buf_T *buf);
 char_u *get_showbreak_value(win_T *win);
-int signcolumn_on(win_T *wp);
 dict_T *get_winbuf_options(int bufopt);
 int fill_culopt_flags(char_u *val, win_T *wp);
 /* vim: set ft=c : */
index 7362cc06d5d3c037fa7e103276a7413be813f5e0..bda8372a24169ae2e945da9e06966175bc78d344 100644 (file)
@@ -1,6 +1,6 @@
 /* sign.c */
 void init_signs(void);
-int buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T *sattr);
+int buf_get_signattrs(win_T *wp, linenr_T lnum, sign_attrs_T *sattr);
 linenr_T buf_delsign(buf_T *buf, linenr_T atlnum, int id, char_u *group);
 int buf_findsign(buf_T *buf, int id, char_u *group);
 int buf_findsign_id(buf_T *buf, linenr_T lnum, char_u *groupname);
@@ -26,6 +26,8 @@ void f_sign_jump(typval_T *argvars, typval_T *rettv);
 void f_sign_place(typval_T *argvars, typval_T *rettv);
 void f_sign_placelist(typval_T *argvars, typval_T *rettv);
 void f_sign_undefine(typval_T *argvars, typval_T *rettv);
+sign_entry_T *get_first_valid_sign(win_T *wp);
+int signcolumn_on(win_T *wp);
 void f_sign_unplace(typval_T *argvars, typval_T *rettv);
 void f_sign_unplacelist(typval_T *argvars, typval_T *rettv);
 /* vim: set ft=c : */
index 0120d11eb358f201cb4d93a4f99e373e477b0d66..8453c8d8ee061ddef2c2808d792e25e2ee94b477 100644 (file)
@@ -4615,7 +4615,7 @@ number_width(win_T *wp)
 # ifdef FEAT_SIGNS
     // If 'signcolumn' is set to 'number' and there is a sign to display, then
     // the minimal width for the number column is 2.
-    if (n < 2 && (wp->w_buffer->b_signlist != NULL)
+    if (n < 2 && get_first_valid_sign(wp) != NULL
            && (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'))
        n = 2;
 # endif
index ddf2ac6a2a7fd068055acdf55904e4f6e379f4aa..134edf09f0b7a76cc32cc0f24db226cb455abce7 100644 (file)
@@ -467,10 +467,11 @@ buf_change_sign_type(
  * 'lnum', FALSE otherwise.
  */
     int
-buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T *sattr)
+buf_get_signattrs(win_T *wp, linenr_T lnum, sign_attrs_T *sattr)
 {
     sign_entry_T       *sign;
     sign_T             *sp;
+    buf_T              *buf = wp->w_buffer;
 
     vim_memset(sattr, 0, sizeof(sign_attrs_T));
 
@@ -481,7 +482,12 @@ buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T *sattr)
            // for signs after the specified line number 'lnum'.
            break;
 
-       if (sign->se_lnum == lnum)
+       if (sign->se_lnum == lnum
+# ifdef FEAT_TEXT_PROP
+               && sign_in_group(sign, (char_u *)"popupmenu")
+                                         == (WIN_IS_POPUP(wp) ? TRUE : FALSE)
+# endif
+               )
        {
            sattr->sat_typenr = sign->se_typenr;
            sp = find_sign_by_typenr(sign->se_typenr);
@@ -2633,6 +2639,42 @@ cleanup:
     return retval;
 }
 
+    sign_entry_T *
+get_first_valid_sign(win_T *wp)
+{
+    sign_entry_T *sign = wp->w_buffer->b_signlist;
+
+# ifdef FEAT_TEXT_PROP
+    while (sign != NULL && sign_in_group(sign, (char_u *)"popupmenu")
+                                         == (WIN_IS_POPUP(wp) ? FALSE : TRUE))
+       sign = sign->se_next;
+# endif
+    return sign;
+}
+
+/*
+ * Return TRUE when window "wp" has a column to draw signs in.
+ */
+     int
+signcolumn_on(win_T *wp)
+{
+    // If 'signcolumn' is set to 'number', signs are displayed in the 'number'
+    // column (if present). Otherwise signs are to be displayed in the sign
+    // column.
+    if (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u')
+       return get_first_valid_sign(wp) != NULL && !wp->w_p_nu && !wp->w_p_rnu;
+
+    if (*wp->w_p_scl == 'n')
+       return FALSE;
+    if (*wp->w_p_scl == 'y')
+       return TRUE;
+    return (get_first_valid_sign(wp) != NULL
+# ifdef FEAT_NETBEANS_INTG
+                       || wp->w_buffer->b_has_sign_column
+# endif
+                   );
+}
+
 /*
  * "sign_unplace()" function
  */
diff --git a/src/testdir/dumps/Test_popupwin_cursorline_8.dump b/src/testdir/dumps/Test_popupwin_cursorline_8.dump
new file mode 100644 (file)
index 0000000..51a009a
--- /dev/null
@@ -0,0 +1,10 @@
+>o+0&#ffffff0|n|e| @71
+|t|w|o| @71
+|t|h|r|e@1| @69
+|~+0#4040ff13&| @33|o+0#0000001#ffd7ff255|n|e| @1| +0#4040ff13#ffffff0@34
+|~| @33|t+0#0000001#e0e0e08|w|o| @1| +0#4040ff13#ffffff0@34
+|~| @33|t+0#0000001#ffd7ff255|h|r|e@1| +0#4040ff13#ffffff0@34
+|~| @73
+|~| @73
+|~| @73
+| +0#0000000&@56|1|,|1| @10|A|l@1| 
index 7e9404162fa8d84fd4076078657e1bd3980012fe..4992837a89bb79b87092d9c7b93a732b713b05e9 100644 (file)
@@ -2615,6 +2615,23 @@ func Test_popup_cursorline()
   call StopVimInTerminal(buf)
 
   call delete('XtestPopupCursorLine')
+
+  " ---------
+  " Use current buffer for popupmenu
+  " ---------
+  let lines =<< trim END
+    call setline(1, ['one', 'two', 'three'])
+    let winid = popup_create(bufnr('%'), #{
+         \ cursorline : 1,
+         \ })
+    call win_execute(winid, "2")
+  END
+  call writefile(lines, 'XtestPopupCursorLine')
+  let buf = RunVimInTerminal('-S XtestPopupCursorLine', #{rows: 10})
+  call VerifyScreenDump(buf, 'Test_popupwin_cursorline_8', {})
+  call StopVimInTerminal(buf)
+
+  call delete('XtestPopupCursorLine')
 endfunc
 
 func Test_previewpopup()
index e147ac30122c469aaecb9839b5088a13c2fcd57c..ae85a956a3e11214a33d1ed00dfdc871a33384eb 100644 (file)
@@ -741,6 +741,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    2295,
 /**/
     2294,
 /**/