vim-patch:8.1.1712: signs in number column cause text to be misaligned

Problem:    Signs in number column cause text to be misaligned.
Solution:   Improve alignment. (Yasuhiro Matsumoto, closes vim/vim#4694)
d6bcff4577
This commit is contained in:
erw7
2020-07-14 05:13:26 +09:00
committed by Shougo Matsushita
parent bfe94d0a08
commit 6b521ceeaf
2 changed files with 14 additions and 2 deletions

View File

@@ -4518,8 +4518,13 @@ static void get_sign_display_info(
*c_finalp = NUL;
if (nrcol) {
snprintf((char *)extra, extra_size, "%-*s ",
number_width(wp), *pp_extra);
int n, width = number_width(wp) - 2;
for (n = 0; n < width; n++) {
extra[n] = ' ';
}
extra[n] = NUL;
STRCAT(extra, *pp_extra);
STRCAT(extra, " ");
*pp_extra = extra;
*n_extrap = (int)STRLEN(*pp_extra);
} else {

View File

@@ -1765,6 +1765,7 @@ func Test_sign_numcol()
set signcolumn=number
sign define sign1 text==>
sign place 10 line=1 name=sign1
sign define sign2 text=
redraw!
call assert_equal("=> 01234", s:ScreenLine(1, 1, 8))
@@ -1844,6 +1845,12 @@ func Test_sign_numcol()
redraw!
call assert_equal("=> 01234", s:ScreenLine(1, 1, 8))
call assert_equal(" 2 abcde", s:ScreenLine(2, 1, 8))
" Add sign with multi-byte text
set numberwidth=4
sign place 40 line=2 name=sign2
redraw!
call assert_equal(" => 01234", s:ScreenLine(1, 1, 9))
call assert_equal(" abcde", s:ScreenLine(2, 1, 9))
sign unplace * group=*
sign undefine sign1