Patch 8.1.2295
Problem: If buffer of popup is in another window cursorline sign shows.
Solution: Check the group of the sign.
Files: src/option.c, src/proto/
option.pro, src/sign.c,
src/proto/
sign.pro, src/screen.c, src/drawline.c,
src/testdir/test_popupwin.vim,
src/testdir/dumps/Test_popupwin_cursorline_8.dump
*** ../vim-8.1.2294/src/option.c 2019-11-09 23:26:36.901570979 +0100
--- src/option.c 2019-11-12 21:56:32.902611778 +0100
***************
*** 7293,7323 ****
}
#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.
--- 7293,7298 ----
*** ../vim-8.1.2294/src/proto/
option.pro 2019-11-09 23:26:36.901570979 +0100
--- src/proto/
option.pro 2019-11-12 22:02:54.112902256 +0100
***************
*** 81,87 ****
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 : */
--- 81,86 ----
*** ../vim-8.1.2294/src/sign.c 2019-10-24 14:59:58.035079639 +0200
--- src/sign.c 2019-11-12 22:25:18.411002756 +0100
***************
*** 467,476 ****
* 'lnum', FALSE otherwise.
*/
int
! buf_get_signattrs(buf_T *buf, linenr_T lnum, sign_attrs_T *sattr)
{
sign_entry_T *sign;
sign_T *sp;
vim_memset(sattr, 0, sizeof(sign_attrs_T));
--- 467,477 ----
* 'lnum', FALSE otherwise.
*/
int
! 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,487 ****
// for signs after the specified line number 'lnum'.
break;
! if (sign->se_lnum == lnum)
{
sattr->sat_typenr = sign->se_typenr;
sp = find_sign_by_typenr(sign->se_typenr);
--- 482,493 ----
// for signs after the specified line number 'lnum'.
break;
! 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,2638 ****
--- 2639,2680 ----
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
*/
*** ../vim-8.1.2294/src/proto/
sign.pro 2019-07-20 16:51:14.343605469 +0200
--- src/proto/
sign.pro 2019-11-12 22:15:05.153549290 +0100
***************
*** 1,6 ****
/* sign.c */
void init_signs(void);
! int buf_get_signattrs(buf_T *buf, 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);
--- 1,6 ----
/* sign.c */
void init_signs(void);
! 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,31 ****
--- 26,33 ----
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 : */
*** ../vim-8.1.2294/src/screen.c 2019-09-19 23:05:56.475034930 +0200
--- src/screen.c 2019-11-12 22:10:30.126745271 +0100
***************
*** 4615,4621 ****
# 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)
&& (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'))
n = 2;
# endif
--- 4615,4621 ----
# 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 && get_first_valid_sign(wp) != NULL
&& (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'))
n = 2;
# endif
*** ../vim-8.1.2294/src/drawline.c 2019-11-09 23:26:36.901570979 +0100
--- src/drawline.c 2019-11-12 22:12:57.866096414 +0100
***************
*** 671,677 ****
#endif
#ifdef FEAT_SIGNS
! sign_present = buf_get_signattrs(wp->w_buffer, lnum, &sattr);
#endif
#ifdef LINE_ATTR
--- 671,677 ----
#endif
#ifdef FEAT_SIGNS
! sign_present = buf_get_signattrs(wp, lnum, &sattr);
#endif
#ifdef LINE_ATTR
*** ../vim-8.1.2294/src/testdir/test_popupwin.vim 2019-11-11 21:45:01.929407112 +0100
--- src/testdir/test_popupwin.vim 2019-11-12 22:23:56.179338686 +0100
***************
*** 2615,2620 ****
--- 2615,2637 ----
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()
*** ../vim-8.1.2294/src/testdir/dumps/Test_popupwin_cursorline_8.dump 2019-11-12 22:32:50.565171414 +0100
--- src/testdir/dumps/Test_popupwin_cursorline_8.dump 2019-11-12 22:24:02.935311022 +0100
***************
*** 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|
*** ../vim-8.1.2294/src/version.c 2019-11-12 20:49:12.173234318 +0100
--- src/version.c 2019-11-12 22:32:37.137225550 +0100
***************
*** 743,744 ****
--- 743,746 ----
{ /* Add new patch number below this line */
+ /**/
+ 2295,
/**/
--
hundred-and-one symptoms of being an internet addict:
81. At social functions you introduce your husband as "my domain server."
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language --
http://www.Zimbu.org ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///