0
0
mirror of https://github.com/vim/vim.git synced 2025-09-30 04:44:14 -04:00

patch 8.1.2295: if buffer of popup is in another window cursorline sign shows

Problem:    If buffer of popup is in another window cursorline sign shows.
Solution:   Check the group of the sign.
This commit is contained in:
Bram Moolenaar
2019-11-12 22:33:45 +01:00
parent cbee635eee
commit 4eb7dae255
9 changed files with 78 additions and 31 deletions

View File

@@ -671,7 +671,7 @@ win_line(
#endif #endif
#ifdef FEAT_SIGNS #ifdef FEAT_SIGNS
sign_present = buf_get_signattrs(wp->w_buffer, lnum, &sattr); sign_present = buf_get_signattrs(wp, lnum, &sattr);
#endif #endif
#ifdef LINE_ATTR #ifdef LINE_ATTR

View File

@@ -7293,31 +7293,6 @@ get_showbreak_value(win_T *win)
} }
#endif #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) #if defined(FEAT_EVAL) || defined(PROTO)
/* /*
* Get window or buffer local options. * Get window or buffer local options.

View File

@@ -81,7 +81,6 @@ void find_mps_values(int *initc, int *findc, int *backwards, int switchit);
int briopt_check(win_T *wp); int briopt_check(win_T *wp);
unsigned int get_bkc_value(buf_T *buf); unsigned int get_bkc_value(buf_T *buf);
char_u *get_showbreak_value(win_T *win); char_u *get_showbreak_value(win_T *win);
int signcolumn_on(win_T *wp);
dict_T *get_winbuf_options(int bufopt); dict_T *get_winbuf_options(int bufopt);
int fill_culopt_flags(char_u *val, win_T *wp); int fill_culopt_flags(char_u *val, win_T *wp);
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -1,6 +1,6 @@
/* sign.c */ /* sign.c */
void init_signs(void); 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); 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(buf_T *buf, int id, char_u *group);
int buf_findsign_id(buf_T *buf, linenr_T lnum, char_u *groupname); 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_place(typval_T *argvars, typval_T *rettv);
void f_sign_placelist(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); 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_unplace(typval_T *argvars, typval_T *rettv);
void f_sign_unplacelist(typval_T *argvars, typval_T *rettv); void f_sign_unplacelist(typval_T *argvars, typval_T *rettv);
/* vim: set ft=c : */ /* vim: set ft=c : */

View File

@@ -4615,7 +4615,7 @@ number_width(win_T *wp)
# ifdef FEAT_SIGNS # ifdef FEAT_SIGNS
// If 'signcolumn' is set to 'number' and there is a sign to display, then // If 'signcolumn' is set to 'number' and there is a sign to display, then
// the minimal width for the number column is 2. // 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')) && (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'))
n = 2; n = 2;
# endif # endif

View File

@@ -467,10 +467,11 @@ buf_change_sign_type(
* 'lnum', FALSE otherwise. * 'lnum', FALSE otherwise.
*/ */
int 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_entry_T *sign;
sign_T *sp; sign_T *sp;
buf_T *buf = wp->w_buffer;
vim_memset(sattr, 0, sizeof(sign_attrs_T)); 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'. // for signs after the specified line number 'lnum'.
break; 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; sattr->sat_typenr = sign->se_typenr;
sp = find_sign_by_typenr(sign->se_typenr); sp = find_sign_by_typenr(sign->se_typenr);
@@ -2633,6 +2639,42 @@ cleanup:
return retval; 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 * "sign_unplace()" function
*/ */

View File

@@ -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|

View File

@@ -2615,6 +2615,23 @@ func Test_popup_cursorline()
call StopVimInTerminal(buf) call StopVimInTerminal(buf)
call delete('XtestPopupCursorLine') 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 endfunc
func Test_previewpopup() func Test_previewpopup()

View File

@@ -741,6 +741,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 */
/**/
2295,
/**/ /**/
2294, 2294,
/**/ /**/