mirror of
https://github.com/neovim/neovim.git
synced 2025-09-22 11:18:19 +00:00
screen: Adjust buffer sizes for multiple sign columns #10314
* screen: Fix to draw signs with combining characters. The buffer size for signs can be too small, because the upper length limit of a sign can be 56 bytes. If combining characters are only two bytes in size, this reduces to 32 bytes. * screen: Adjust buffer size to maximal sign column count
This commit is contained in:

committed by
Justin M. Keyes

parent
9ce34050e5
commit
0bdeec8ef0
@@ -1775,7 +1775,9 @@ static void fold_line(win_T *wp, long fold_count, foldinfo_T *foldinfo, linenr_T
|
||||
if (len > len_max) {
|
||||
len = len_max;
|
||||
}
|
||||
copy_text_attr(off + col, (char_u *)" ", len,
|
||||
char_u space_buf[18] = " ";
|
||||
assert((size_t)len_max <= sizeof(space_buf));
|
||||
copy_text_attr(off + col, space_buf, len,
|
||||
win_hl_attr(wp, HLF_FL));
|
||||
col += len;
|
||||
}
|
||||
@@ -2061,7 +2063,8 @@ win_line (
|
||||
int row; // row in the window, excl w_winrow
|
||||
ScreenGrid *grid = &wp->w_grid; // grid specfic to the window
|
||||
|
||||
char_u extra[18]; // line number and 'fdc' must fit in here
|
||||
char_u extra[57]; // sign, line number and 'fdc' must
|
||||
// fit in here
|
||||
int n_extra = 0; // number of extra chars
|
||||
char_u *p_extra = NULL; // string of extra chars, plus NUL
|
||||
char_u *p_extra_free = NULL; // p_extra needs to be freed
|
||||
@@ -2712,15 +2715,24 @@ win_line (
|
||||
sign_idx, count);
|
||||
if (text_sign != 0) {
|
||||
p_extra = sign_get_text(text_sign);
|
||||
int symbol_blen = (int)STRLEN(p_extra);
|
||||
if (p_extra != NULL) {
|
||||
int symbol_blen = (int)STRLEN(p_extra);
|
||||
|
||||
c_extra = NUL;
|
||||
c_final = NUL;
|
||||
|
||||
// TODO(oni-link): Is sign text already extended to
|
||||
// full cell width?
|
||||
assert((size_t)win_signcol_width(wp)
|
||||
>= mb_string2cells(p_extra));
|
||||
// symbol(s) bytes + (filling spaces) (one byte each)
|
||||
n_extra = symbol_blen +
|
||||
(win_signcol_width(wp) - mb_string2cells(p_extra));
|
||||
|
||||
assert(sizeof(extra) > (size_t)symbol_blen);
|
||||
memset(extra, ' ', sizeof(extra));
|
||||
STRNCPY(extra, p_extra, STRLEN(p_extra));
|
||||
memcpy(extra, p_extra, symbol_blen);
|
||||
|
||||
p_extra = extra;
|
||||
p_extra[n_extra] = NUL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user