diff options
author | Bram Moolenaar <Bram@vim.org> | 2019-11-12 22:33:45 +0100 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2019-11-12 22:33:45 +0100 |
commit | 4eb7dae255abc271cf313d4c75839577f1424183 (patch) | |
tree | 55738e6838d3de39c91541c21687990c8af5b113 | |
parent | cbee635eee3007db97646ddb9f211a1d4966eb2a (diff) |
patch 8.1.2295: if buffer of popup is in another window cursorline sign showsv8.1.2295
Problem: If buffer of popup is in another window cursorline sign shows.
Solution: Check the group of the sign.
-rw-r--r-- | src/drawline.c | 2 | ||||
-rw-r--r-- | src/option.c | 25 | ||||
-rw-r--r-- | src/proto/option.pro | 1 | ||||
-rw-r--r-- | src/proto/sign.pro | 4 | ||||
-rw-r--r-- | src/screen.c | 2 | ||||
-rw-r--r-- | src/sign.c | 46 | ||||
-rw-r--r-- | src/testdir/dumps/Test_popupwin_cursorline_8.dump | 10 | ||||
-rw-r--r-- | src/testdir/test_popupwin.vim | 17 | ||||
-rw-r--r-- | src/version.c | 2 |
9 files changed, 78 insertions, 31 deletions
diff --git a/src/drawline.c b/src/drawline.c index 2802859747..54163c7c94 100644 --- 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 index 313882148f..c54fc82681 100644 --- 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 index b3c66ee118..b3250dca72 100644 --- a/src/proto/option.pro +++ b/src/proto/option.pro @@ -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 : */ diff --git a/src/proto/sign.pro b/src/proto/sign.pro index 7362cc06d5..bda8372a24 100644 --- 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, 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 : */ diff --git a/src/screen.c b/src/screen.c index 0120d11eb3..8453c8d8ee 100644 --- 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 index ddf2ac6a2a..134edf09f0 100644 --- 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 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 index 0000000000..51a009aa8f --- /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 index 7e9404162f..4992837a89 100644 --- 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 index e147ac3012..ae85a956a3 100644 --- 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, |