changeset 17427:45c1dc353321 v8.1.1712

patch 8.1.1712: signs in number column cause text to be misaligned commit https://github.com/vim/vim/commit/d6bcff457799e491c3d27880858ec08e758e1849 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Jul 18 12:48:16 2019 +0200 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 https://github.com/vim/vim/issues/4694)
author Bram Moolenaar <Bram@vim.org>
date Thu, 18 Jul 2019 13:00:06 +0200
parents 4240f8ba788f
children 30036b80e5ca
files src/screen.c src/testdir/test_signs.vim src/version.c
diffstat 3 files changed, 16 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;
--- 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
--- a/src/version.c
+++ b/src/version.c
@@ -778,6 +778,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1712,
+/**/
     1711,
 /**/
     1710,