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

patch 8.1.1623: display wrong with signs in narrow number column

Problem:    Display wrong with signs in narrow number column.
Solution:   Increase the numbercolumn width if needed. (Yegappan Lakshmanan,
            closes #4606)
This commit is contained in:
Bram Moolenaar
2019-07-04 11:59:28 +02:00
parent e296e3177b
commit e4b407f536
5 changed files with 93 additions and 1 deletions

View File

@@ -1008,6 +1008,20 @@ sign_list_by_name(char_u *name)
semsg(_("E155: Unknown sign: %s"), name);
}
static void
may_force_numberwidth_recompute(buf_T *buf, int unplace)
{
tabpage_T *tp;
win_T *wp;
FOR_ALL_TAB_WINDOWS(tp, wp)
if (wp->w_buffer == buf
&& (wp->w_p_nu || wp->w_p_rnu)
&& (unplace || wp->w_nrwidth_width < 2)
&& (*wp->w_p_scl == 'n' && *(wp->w_p_scl + 1) == 'u'))
wp->w_nrwidth_line_count = 0;
}
/*
* Place a sign at the specified file location or update a sign.
*/
@@ -1045,7 +1059,13 @@ sign_place(
// ":sign place {id} file={fname}": change sign type
lnum = buf_change_sign_type(buf, *sign_id, sign_group, sp->sn_typenr);
if (lnum > 0)
{
redraw_buf_line_later(buf, lnum);
// When displaying signs in the 'number' column, if the width of the
// number column is less than 2, then force recomputing the width.
may_force_numberwidth_recompute(buf, FALSE);
}
else
{
semsg(_("E885: Not possible to change sign %s"), sign_name);
@@ -1080,6 +1100,12 @@ sign_unplace(int sign_id, char_u *sign_group, buf_T *buf, linenr_T atlnum)
return FAIL;
}
// When all the signs in a buffer are removed, force recomputing the
// number column width (if enabled) in all the windows displaying the
// buffer if 'signcolumn' is set to 'number' in that window.
if (buf->b_signlist == NULL)
may_force_numberwidth_recompute(buf, TRUE);
return OK;
}