aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/testdir/test_signs.vim
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/testdir/test_signs.vim')
-rw-r--r--src/nvim/testdir/test_signs.vim114
1 files changed, 114 insertions, 0 deletions
diff --git a/src/nvim/testdir/test_signs.vim b/src/nvim/testdir/test_signs.vim
index 8b1927e4f0..2b7672f1af 100644
--- a/src/nvim/testdir/test_signs.vim
+++ b/src/nvim/testdir/test_signs.vim
@@ -1742,3 +1742,117 @@ 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
+ sign define sign2 text=V
+ 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))
+
+ " Test displaying signs in the number column with width 1
+ call sign_unplace('*')
+ call append(1, "abcde")
+ call append(2, "01234")
+ " Enable number column with width 1
+ set number numberwidth=1 signcolumn=auto
+ redraw!
+ call assert_equal("3 01234", s:ScreenLine(3, 1, 7))
+ " Place a sign and make sure number column width remains the same
+ sign place 20 line=2 name=sign1
+ redraw!
+ call assert_equal("=>2 abcde", s:ScreenLine(2, 1, 9))
+ call assert_equal(" 3 01234", s:ScreenLine(3, 1, 9))
+ " Set 'signcolumn' to 'number', make sure the number column width increases
+ set signcolumn=number
+ redraw!
+ call assert_equal("=> abcde", s:ScreenLine(2, 1, 8))
+ call assert_equal(" 3 01234", s:ScreenLine(3, 1, 8))
+ " Set 'signcolumn' to 'auto', make sure the number column width is 1.
+ set signcolumn=auto
+ redraw!
+ call assert_equal("=>2 abcde", s:ScreenLine(2, 1, 9))
+ call assert_equal(" 3 01234", s:ScreenLine(3, 1, 9))
+ " Set 'signcolumn' to 'number', make sure the number column width is 2.
+ set signcolumn=number
+ redraw!
+ call assert_equal("=> abcde", s:ScreenLine(2, 1, 8))
+ call assert_equal(" 3 01234", s:ScreenLine(3, 1, 8))
+ " Disable 'number' column
+ set nonumber
+ redraw!
+ call assert_equal("=>abcde", s:ScreenLine(2, 1, 7))
+ call assert_equal(" 01234", s:ScreenLine(3, 1, 7))
+ " Enable 'number' column
+ set number
+ redraw!
+ call assert_equal("=> abcde", s:ScreenLine(2, 1, 8))
+ call assert_equal(" 3 01234", s:ScreenLine(3, 1, 8))
+ " Remove the sign and make sure the width of the number column is 1.
+ call sign_unplace('', {'id' : 20})
+ redraw!
+ call assert_equal("3 01234", s:ScreenLine(3, 1, 7))
+ " When the first sign is placed with 'signcolumn' set to number, verify that
+ " the number column width increases
+ sign place 30 line=1 name=sign1
+ 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
+ set signcolumn&
+ set number&
+ enew! | close
+endfunc