summaryrefslogtreecommitdiff
path: root/src/sign.c
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2019-07-04 11:59:28 +0200
committerBram Moolenaar <Bram@vim.org>2019-07-04 11:59:28 +0200
commite4b407f536ba8bd007152649a347a95320d80fce (patch)
tree306f3fa571a153b3fa0e7d6c66d2ec1f668e8d04 /src/sign.c
parente296e3177b67bdcaa8b1f144d2495b9413e7055c (diff)
downloadvim-git-e4b407f536ba8bd007152649a347a95320d80fce.tar.gz
patch 8.1.1623: display wrong with signs in narrow number columnv8.1.1623
Problem: Display wrong with signs in narrow number column. Solution: Increase the numbercolumn width if needed. (Yegappan Lakshmanan, closes #4606)
Diffstat (limited to 'src/sign.c')
-rw-r--r--src/sign.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/sign.c b/src/sign.c
index 7ea40abf1..a67f3ec8c 100644
--- a/src/sign.c
+++ b/src/sign.c
@@ -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;
}