diff src/testdir/test_signs.vim @ 17129:4fb68abc770f v8.1.1564

patch 8.1.1564: sign column takes up space commit https://github.com/vim/vim/commit/394c5d8870b15150fc91a4c058dc571fd5eaa97e Author: Bram Moolenaar <Bram@vim.org> Date: Mon Jun 17 21:48:05 2019 +0200 patch 8.1.1564: sign column takes up space Problem: Sign column takes up space. (Adam Stankiewicz) Solution: Optionally put signs in the number column. (Yegappan Lakshmanan, closes #4555, closes #4515)
author Bram Moolenaar <Bram@vim.org>
date Mon, 17 Jun 2019 22:00:09 +0200
parents 811c5c2f5236
children 3c0efdd95f8d
line wrap: on
line diff
--- a/src/testdir/test_signs.vim
+++ b/src/testdir/test_signs.vim
@@ -1736,3 +1736,60 @@ func Test_sign_cursor_position()
   call StopVimInTerminal(buf)
   call delete('XtestSigncolumn')
 endfunc
+
+" Return the 'len' characters in screen starting from (row,col)
+func s:ScreenLine(row, col, len)
+  let s = ''
+  for i in range(a:len)
+    let s .= nr2char(screenchar(a:row, a:col + i))
+  endfor
+  return s
+endfunc
+
+" Test for 'signcolumn' set to 'number'.
+func Test_sign_numcol()
+  new
+  call append(0, "01234")
+  " With 'signcolumn' set to 'number', make sure sign is displayed in the
+  " number column and line number is not displayed.
+  set numberwidth=2
+  set number
+  set signcolumn=number
+  sign define sign1 text==>
+  sign place 10 line=1 name=sign1
+  redraw!
+  call assert_equal("=> 01234", s:ScreenLine(1, 1, 8))
+
+  " With 'signcolumn' set to 'number', when there is no sign, make sure line
+  " number is displayed in the number column
+  sign unplace 10
+  redraw!
+  call assert_equal("1 01234", s:ScreenLine(1, 1, 7))
+
+  " Disable number column. Check whether sign is displayed in the sign column
+  set numberwidth=4
+  set nonumber
+  sign place 10 line=1 name=sign1
+  redraw!
+  call assert_equal("=>01234", s:ScreenLine(1, 1, 7))
+
+  " Enable number column. Check whether sign is displayed in the number column
+  set number
+  redraw!
+  call assert_equal("=>  01234", s:ScreenLine(1, 1, 9))
+
+  " Disable sign column. Make sure line number is displayed
+  set signcolumn=no
+  redraw!
+  call assert_equal("  1 01234", s:ScreenLine(1, 1, 9))
+
+  " Enable auto sign column. Make sure both sign and line number are displayed
+  set signcolumn=auto
+  redraw!
+  call assert_equal("=>  1 01234", s:ScreenLine(1, 1, 11))
+
+  sign undefine sign1
+  set signcolumn&
+  set number&
+  enew!  | close
+endfunc