# HG changeset patch # User Bram Moolenaar # Date 1573595105 -3600 # Node ID f249b44039e0292cd25df8405ea0d3c4b8d28cf7 # Parent 9d6fa65148d208cee1b3429a08cfb5691c77557c patch 8.1.2295: if buffer of popup is in another window cursorline sign shows Commit: https://github.com/vim/vim/commit/4eb7dae255abc271cf313d4c75839577f1424183 Author: Bram Moolenaar Date: Tue Nov 12 22:33:45 2019 +0100 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. diff --git a/src/drawline.c b/src/drawline.c --- a/src/drawline.c +++ b/src/drawline.c @@ -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 diff --git a/src/option.c b/src/option.c --- a/src/option.c +++ b/src/option.c @@ -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. diff --git a/src/proto/option.pro b/src/proto/option.pro --- a/src/proto/option.pro +++ b/src/proto/option.pro @@ -81,7 +81,6 @@ void find_mps_values(int *initc, int *fi 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 : */ diff --git a/src/proto/sign.pro b/src/proto/sign.pro --- a/src/proto/sign.pro +++ b/src/proto/sign.pro @@ -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, typv 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 : */ diff --git a/src/screen.c b/src/screen.c --- a/src/screen.c +++ b/src/screen.c @@ -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 diff --git a/src/sign.c b/src/sign.c --- a/src/sign.c +++ b/src/sign.c @@ -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 l // 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 --- /dev/null +++ b/src/testdir/dumps/Test_popupwin_cursorline_8.dump @@ -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| diff --git a/src/testdir/test_popupwin.vim b/src/testdir/test_popupwin.vim --- a/src/testdir/test_popupwin.vim +++ b/src/testdir/test_popupwin.vim @@ -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() diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -742,6 +742,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 2295, +/**/ 2294, /**/ 2293,