mirror of
https://github.com/neovim/neovim.git
synced 2025-09-08 12:28:18 +00:00
test(old): make test_signs.vim closer to upstream
(cherry picked from commit 5391e8b002
)
This commit is contained in:

committed by
github-actions[bot]
![github-actions[bot]](/assets/img/avatar_default.png)
parent
bd3634d7a4
commit
d2582350b2
@@ -334,8 +334,10 @@ See |sign_getplaced()| for the equivalent Vim script function.
|
|||||||
:sign place group=* buffer={nr}
|
:sign place group=* buffer={nr}
|
||||||
List signs in all the groups placed in buffer {nr}.
|
List signs in all the groups placed in buffer {nr}.
|
||||||
|
|
||||||
|
:sign place List placed signs in the global group in all files.
|
||||||
|
|
||||||
:sign place group={group}
|
:sign place group={group}
|
||||||
List placed signs in all sign groups in all the files.
|
List placed signs with sign group {group} in all files.
|
||||||
|
|
||||||
:sign place group=*
|
:sign place group=*
|
||||||
List placed signs in all sign groups in all files.
|
List placed signs in all sign groups in all files.
|
||||||
@@ -381,15 +383,14 @@ sign_define({list})
|
|||||||
icon full path to the bitmap file for the sign.
|
icon full path to the bitmap file for the sign.
|
||||||
linehl highlight group used for the whole line the
|
linehl highlight group used for the whole line the
|
||||||
sign is placed in.
|
sign is placed in.
|
||||||
|
numhl highlight group used for the line number where
|
||||||
|
the sign is placed.
|
||||||
text text that is displayed when there is no icon
|
text text that is displayed when there is no icon
|
||||||
or the GUI is not being used.
|
or the GUI is not being used.
|
||||||
texthl highlight group used for the text item
|
texthl highlight group used for the text item
|
||||||
culhl highlight group used for the text item when
|
culhl highlight group used for the text item when
|
||||||
the cursor is on the same line as the sign and
|
the cursor is on the same line as the sign and
|
||||||
'cursorline' is enabled.
|
'cursorline' is enabled.
|
||||||
numhl highlight group used for 'number' column at the
|
|
||||||
associated line. Overrides |hl-LineNr|,
|
|
||||||
|hl-CursorLineNr|.
|
|
||||||
|
|
||||||
If the sign named {name} already exists, then the attributes
|
If the sign named {name} already exists, then the attributes
|
||||||
of the sign are updated.
|
of the sign are updated.
|
||||||
@@ -431,6 +432,8 @@ sign_getdefined([{name}]) *sign_getdefined()*
|
|||||||
linehl highlight group used for the whole line the
|
linehl highlight group used for the whole line the
|
||||||
sign is placed in; not present if not set.
|
sign is placed in; not present if not set.
|
||||||
name name of the sign
|
name name of the sign
|
||||||
|
numhl highlight group used for the line number where
|
||||||
|
the sign is placed; not present if not set.
|
||||||
text text that is displayed when there is no icon
|
text text that is displayed when there is no icon
|
||||||
or the GUI is not being used.
|
or the GUI is not being used.
|
||||||
texthl highlight group used for the text item; not
|
texthl highlight group used for the text item; not
|
||||||
@@ -439,9 +442,6 @@ sign_getdefined([{name}]) *sign_getdefined()*
|
|||||||
the cursor is on the same line as the sign and
|
the cursor is on the same line as the sign and
|
||||||
'cursorline' is enabled; not present if not
|
'cursorline' is enabled; not present if not
|
||||||
set.
|
set.
|
||||||
numhl highlight group used for 'number' column at the
|
|
||||||
associated line. Overrides |hl-LineNr|,
|
|
||||||
|hl-CursorLineNr|; not present if not set.
|
|
||||||
|
|
||||||
Returns an empty List if there are no signs and when {name} is
|
Returns an empty List if there are no signs and when {name} is
|
||||||
not found.
|
not found.
|
||||||
|
@@ -15,13 +15,13 @@ func Test_sign()
|
|||||||
" the icon name when listing signs.
|
" the icon name when listing signs.
|
||||||
sign define Sign1 text=x
|
sign define Sign1 text=x
|
||||||
|
|
||||||
call Sign_command_ignore_error('sign define Sign2 text=xy texthl=Title linehl=Error culhl=Search icon=../../pixmaps/stock_vim_find_help.png')
|
call Sign_command_ignore_error('sign define Sign2 text=xy texthl=Title linehl=Error culhl=Search numhl=Number icon=../../pixmaps/stock_vim_find_help.png')
|
||||||
|
|
||||||
" Test listing signs.
|
" Test listing signs.
|
||||||
let a=execute('sign list')
|
let a=execute('sign list')
|
||||||
call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' .
|
call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' .
|
||||||
\ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' .
|
\ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' .
|
||||||
\ 'linehl=Error texthl=Title culhl=Search$', a)
|
\ 'linehl=Error texthl=Title culhl=Search numhl=Number$', a)
|
||||||
|
|
||||||
let a=execute('sign list Sign1')
|
let a=execute('sign list Sign1')
|
||||||
call assert_equal("\nsign Sign1 text=x ", a)
|
call assert_equal("\nsign Sign1 text=x ", a)
|
||||||
@@ -127,26 +127,34 @@ func Test_sign()
|
|||||||
call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:')
|
call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:')
|
||||||
|
|
||||||
" an empty highlight argument for an existing sign clears it
|
" an empty highlight argument for an existing sign clears it
|
||||||
sign define SignY texthl=TextHl culhl=CulHl linehl=LineHl
|
sign define SignY texthl=TextHl culhl=CulHl linehl=LineHl numhl=NumHl
|
||||||
let sl = sign_getdefined('SignY')[0]
|
let sl = sign_getdefined('SignY')[0]
|
||||||
call assert_equal('TextHl', sl.texthl)
|
call assert_equal('TextHl', sl.texthl)
|
||||||
call assert_equal('CulHl', sl.culhl)
|
call assert_equal('CulHl', sl.culhl)
|
||||||
call assert_equal('LineHl', sl.linehl)
|
call assert_equal('LineHl', sl.linehl)
|
||||||
|
call assert_equal('NumHl', sl.numhl)
|
||||||
|
|
||||||
sign define SignY texthl= culhl=CulHl linehl=LineHl
|
sign define SignY texthl= culhl=CulHl linehl=LineHl numhl=NumHl
|
||||||
let sl = sign_getdefined('SignY')[0]
|
let sl = sign_getdefined('SignY')[0]
|
||||||
call assert_false(has_key(sl, 'texthl'))
|
call assert_false(has_key(sl, 'texthl'))
|
||||||
call assert_equal('CulHl', sl.culhl)
|
call assert_equal('CulHl', sl.culhl)
|
||||||
call assert_equal('LineHl', sl.linehl)
|
call assert_equal('LineHl', sl.linehl)
|
||||||
|
call assert_equal('NumHl', sl.numhl)
|
||||||
|
|
||||||
sign define SignY linehl=
|
sign define SignY linehl=
|
||||||
let sl = sign_getdefined('SignY')[0]
|
let sl = sign_getdefined('SignY')[0]
|
||||||
call assert_false(has_key(sl, 'linehl'))
|
call assert_false(has_key(sl, 'linehl'))
|
||||||
call assert_equal('CulHl', sl.culhl)
|
call assert_equal('CulHl', sl.culhl)
|
||||||
|
call assert_equal('NumHl', sl.numhl)
|
||||||
|
|
||||||
sign define SignY culhl=
|
sign define SignY culhl=
|
||||||
let sl = sign_getdefined('SignY')[0]
|
let sl = sign_getdefined('SignY')[0]
|
||||||
call assert_false(has_key(sl, 'culhl'))
|
call assert_false(has_key(sl, 'culhl'))
|
||||||
|
call assert_equal('NumHl', sl.numhl)
|
||||||
|
|
||||||
|
sign define SignY numhl=
|
||||||
|
let sl = sign_getdefined('SignY')[0]
|
||||||
|
call assert_false(has_key(sl, 'numhl'))
|
||||||
|
|
||||||
sign undefine SignY
|
sign undefine SignY
|
||||||
|
|
||||||
@@ -158,7 +166,7 @@ func Test_sign()
|
|||||||
|
|
||||||
sign define Sign5 text=X\ linehl=Comment
|
sign define Sign5 text=X\ linehl=Comment
|
||||||
sign undefine Sign5
|
sign undefine Sign5
|
||||||
sign define Sign5 linehl=Comment text=X\
|
sign define Sign5 linehl=Comment text=X\
|
||||||
sign undefine Sign5
|
sign undefine Sign5
|
||||||
|
|
||||||
" define sign with backslash
|
" define sign with backslash
|
||||||
@@ -417,8 +425,8 @@ func Test_sign_funcs()
|
|||||||
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error',
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error',
|
||||||
\ 'culhl': 'Visual', 'numhl': 'Number'}
|
\ 'culhl': 'Visual', 'numhl': 'Number'}
|
||||||
call assert_equal(0, "sign1"->sign_define(attr))
|
call assert_equal(0, "sign1"->sign_define(attr))
|
||||||
call assert_equal([{'name' : 'sign1', 'texthl' : 'Error', 'linehl': 'Search',
|
call assert_equal([{'name' : 'sign1', 'texthl' : 'Error', 'linehl' : 'Search',
|
||||||
\ 'culhl': 'Visual', 'numhl': 'Number', 'text' : '=>'}],
|
\ 'culhl' : 'Visual', 'numhl': 'Number', 'text' : '=>'}],
|
||||||
\ sign_getdefined())
|
\ sign_getdefined())
|
||||||
|
|
||||||
" Define a new sign without attributes and then update it
|
" Define a new sign without attributes and then update it
|
||||||
@@ -535,9 +543,9 @@ func Test_sign_funcs()
|
|||||||
call assert_equal(15, sign_place(15, '', 'sign1', 'Xsign', {'lnum' : 20}))
|
call assert_equal(15, sign_place(15, '', 'sign1', 'Xsign', {'lnum' : 20}))
|
||||||
call assert_equal(15, sign_place(15, '', 'sign2', 'Xsign'))
|
call assert_equal(15, sign_place(15, '', 'sign2', 'Xsign'))
|
||||||
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
||||||
\ [{'id' : 15, 'group' : '', 'lnum' : 20, 'name' : 'sign2',
|
\ [{'id' : 15, 'group' : '', 'lnum' : 20, 'name' : 'sign2',
|
||||||
\ 'priority' : 10}]}],
|
\ 'priority' : 10}]}],
|
||||||
\ sign_getplaced())
|
\ sign_getplaced())
|
||||||
|
|
||||||
" Tests for sign_undefine()
|
" Tests for sign_undefine()
|
||||||
call assert_equal(0, sign_undefine("sign1"))
|
call assert_equal(0, sign_undefine("sign1"))
|
||||||
@@ -1165,7 +1173,7 @@ func Test_sign_unplace()
|
|||||||
call delete("Xsign2")
|
call delete("Xsign2")
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
" Tests for auto-generating the sign identifier
|
" Tests for auto-generating the sign identifier.
|
||||||
func Test_aaa_sign_id_autogen()
|
func Test_aaa_sign_id_autogen()
|
||||||
enew | only
|
enew | only
|
||||||
call sign_unplace('*')
|
call sign_unplace('*')
|
||||||
@@ -1650,10 +1658,34 @@ func Test_sign_lnum_adjust()
|
|||||||
" changes made by this function.
|
" changes made by this function.
|
||||||
let &undolevels=&undolevels
|
let &undolevels=&undolevels
|
||||||
|
|
||||||
|
" Nvim: make sign adjustment when deleting lines match Vim
|
||||||
|
set signcolumn=yes:1
|
||||||
|
|
||||||
" Delete the line with the sign
|
" Delete the line with the sign
|
||||||
call deletebufline('', 4)
|
call deletebufline('', 4)
|
||||||
let l = sign_getplaced(bufnr(''))
|
let l = sign_getplaced(bufnr(''))
|
||||||
call assert_equal(0, len(l[0].signs))
|
call assert_equal(4, l[0].signs[0].lnum)
|
||||||
|
|
||||||
|
" Undo the delete operation
|
||||||
|
undo
|
||||||
|
let l = sign_getplaced(bufnr(''))
|
||||||
|
call assert_equal(5, l[0].signs[0].lnum)
|
||||||
|
|
||||||
|
" Break the undo
|
||||||
|
let &undolevels=&undolevels
|
||||||
|
|
||||||
|
" Delete few lines at the end of the buffer including the line with the sign
|
||||||
|
" Sign line number should not change (as it is placed outside of the buffer)
|
||||||
|
call deletebufline('', 3, 6)
|
||||||
|
let l = sign_getplaced(bufnr(''))
|
||||||
|
call assert_equal(5, l[0].signs[0].lnum)
|
||||||
|
|
||||||
|
" Undo the delete operation. Sign should be restored to the previous line
|
||||||
|
undo
|
||||||
|
let l = sign_getplaced(bufnr(''))
|
||||||
|
call assert_equal(5, l[0].signs[0].lnum)
|
||||||
|
|
||||||
|
set signcolumn&
|
||||||
|
|
||||||
sign unplace * group=*
|
sign unplace * group=*
|
||||||
sign undefine sign1
|
sign undefine sign1
|
||||||
@@ -1790,8 +1822,8 @@ func Test_sign_numcol()
|
|||||||
set number
|
set number
|
||||||
set signcolumn=number
|
set signcolumn=number
|
||||||
sign define sign1 text==>
|
sign define sign1 text==>
|
||||||
sign place 10 line=1 name=sign1
|
|
||||||
sign define sign2 text=V
|
sign define sign2 text=V
|
||||||
|
sign place 10 line=1 name=sign1
|
||||||
redraw!
|
redraw!
|
||||||
call assert_equal("=> 01234", s:ScreenLine(1, 1, 8))
|
call assert_equal("=> 01234", s:ScreenLine(1, 1, 8))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user