From d6bcff457799e491c3d27880858ec08e758e1849 Mon Sep 17 00:00:00 2001 From: Bram Moolenaar Date: Thu, 18 Jul 2019 12:48:16 +0200 Subject: 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 #4694) --- src/screen.c | 9 +++++++-- src/testdir/test_signs.vim | 7 +++++++ src/version.c | 2 ++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/screen.c b/src/screen.c index 825b7ab0e..fdb1e0af5 100644 --- a/src/screen.c +++ b/src/screen.c @@ -3120,8 +3120,13 @@ get_sign_display_info( { if (nrcol) { - sprintf((char *)extra, "%*s ", number_width(wp), - *pp_extra); + int n, width = number_width(wp) - 2; + + for (n = 0; n < width; n++) + extra[n] = ' '; + extra[n] = 0; + STRCAT(extra, *pp_extra); + STRCAT(extra, " "); *pp_extra = extra; } *c_extrap = NUL; diff --git a/src/testdir/test_signs.vim b/src/testdir/test_signs.vim index 1b9a29d9f..3d885d642 100644 --- a/src/testdir/test_signs.vim +++ b/src/testdir/test_signs.vim @@ -1766,6 +1766,7 @@ func Test_sign_numcol() set number set signcolumn=number sign define sign1 text==> + sign define sign2 text=V sign place 10 line=1 name=sign1 redraw! call assert_equal("=> 01234", s:ScreenLine(1, 1, 8)) @@ -1846,6 +1847,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(" V abcde", s:ScreenLine(2, 1, 9)) sign unplace * group=* sign undefine sign1 diff --git a/src/version.c b/src/version.c index 6c6550b09..a6d1492e2 100644 --- a/src/version.c +++ b/src/version.c @@ -777,6 +777,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ +/**/ + 1712, /**/ 1711, /**/ -- cgit v1.2.1