2016-11-15 14:28:23 -07:00
|
|
|
|
" Test for signs
|
|
|
|
|
|
2021-03-26 20:06:39 -07:00
|
|
|
|
source check.vim
|
|
|
|
|
CheckFeature signs
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
2020-02-24 22:43:06 -07:00
|
|
|
|
source screendump.vim
|
|
|
|
|
|
2016-11-15 14:28:23 -07:00
|
|
|
|
func Test_sign()
|
|
|
|
|
new
|
|
|
|
|
call setline(1, ['a', 'b', 'c', 'd'])
|
|
|
|
|
|
2016-11-15 14:30:14 -07:00
|
|
|
|
" Define some signs.
|
|
|
|
|
" We can specify icons even if not all versions of vim support icons as
|
|
|
|
|
" icon is ignored when not supported. "(not supported)" is shown after
|
|
|
|
|
" the icon name when listing signs.
|
2016-11-15 14:28:23 -07:00
|
|
|
|
sign define Sign1 text=x
|
2020-12-11 08:10:33 -07:00
|
|
|
|
|
2022-12-19 20:03:38 -07:00
|
|
|
|
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')
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
|
|
|
|
" Test listing signs.
|
|
|
|
|
let a=execute('sign list')
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_match('^\nsign Sign1 text=x \nsign Sign2 ' .
|
|
|
|
|
\ 'icon=../../pixmaps/stock_vim_find_help.png .*text=xy ' .
|
2022-12-19 20:03:38 -07:00
|
|
|
|
\ 'linehl=Error texthl=Title culhl=Search numhl=Number$', a)
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
|
|
|
|
let a=execute('sign list Sign1')
|
|
|
|
|
call assert_equal("\nsign Sign1 text=x ", a)
|
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Split the window to the bottom to verify sign jump will stay in the
|
|
|
|
|
" current window if the buffer is displayed there.
|
2016-11-15 14:30:14 -07:00
|
|
|
|
let bn = bufnr('%')
|
|
|
|
|
let wn = winnr()
|
2019-05-19 09:38:25 -07:00
|
|
|
|
exe 'sign place 41 line=3 name=Sign1 buffer=' . bn
|
2016-11-15 14:30:14 -07:00
|
|
|
|
1
|
|
|
|
|
bot split
|
|
|
|
|
exe 'sign jump 41 buffer=' . bufnr('%')
|
|
|
|
|
call assert_equal('c', getline('.'))
|
|
|
|
|
call assert_equal(3, winnr())
|
|
|
|
|
call assert_equal(bn, bufnr('%'))
|
|
|
|
|
call assert_notequal(wn, winnr())
|
|
|
|
|
|
|
|
|
|
" Create a new buffer and check that ":sign jump" switches to the old buffer.
|
2016-11-15 14:28:23 -07:00
|
|
|
|
1
|
2016-11-15 14:30:14 -07:00
|
|
|
|
new foo
|
|
|
|
|
call assert_notequal(bn, bufnr('%'))
|
|
|
|
|
exe 'sign jump 41 buffer=' . bn
|
|
|
|
|
call assert_equal(bn, bufnr('%'))
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call assert_equal('c', getline('.'))
|
|
|
|
|
|
2016-11-15 14:30:14 -07:00
|
|
|
|
" Redraw to make sure that screen redraw with sign gets exercised,
|
|
|
|
|
" with and without 'rightleft'.
|
|
|
|
|
if has('rightleft')
|
|
|
|
|
set rightleft
|
|
|
|
|
redraw
|
|
|
|
|
set norightleft
|
|
|
|
|
endif
|
|
|
|
|
redraw
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
2016-11-15 14:30:14 -07:00
|
|
|
|
" Check that we can't change sign.
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign place 40 name=Sign1 buffer=" . bufnr('%'), 'E885:')
|
2016-11-15 14:30:14 -07:00
|
|
|
|
|
|
|
|
|
" Check placed signs
|
2016-11-15 14:28:23 -07:00
|
|
|
|
let a=execute('sign place')
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=3 id=41 name=Sign1 priority=10\n", a)
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
2016-11-15 14:30:14 -07:00
|
|
|
|
" Unplace the sign and try jumping to it again should fail.
|
|
|
|
|
sign unplace 41
|
2016-11-15 14:28:23 -07:00
|
|
|
|
1
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign jump 41 buffer=" . bufnr('%'), 'E157:')
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call assert_equal('a', getline('.'))
|
|
|
|
|
|
|
|
|
|
" Unplace sign on current line.
|
2016-11-15 14:30:14 -07:00
|
|
|
|
exe 'sign place 42 line=4 name=Sign2 buffer=' . bufnr('%')
|
2016-11-15 14:28:23 -07:00
|
|
|
|
4
|
|
|
|
|
sign unplace
|
|
|
|
|
let a=execute('sign place')
|
|
|
|
|
call assert_equal("\n--- Signs ---\n", a)
|
2019-05-19 09:38:25 -07:00
|
|
|
|
|
2016-11-15 14:28:23 -07:00
|
|
|
|
" Try again to unplace sign on current line, it should fail this time.
|
|
|
|
|
call assert_fails('sign unplace', 'E159:')
|
|
|
|
|
|
|
|
|
|
" Unplace all signs.
|
2016-11-15 14:30:14 -07:00
|
|
|
|
exe 'sign place 41 line=3 name=Sign1 buffer=' . bufnr('%')
|
2016-11-15 14:28:23 -07:00
|
|
|
|
sign unplace *
|
|
|
|
|
let a=execute('sign place')
|
|
|
|
|
call assert_equal("\n--- Signs ---\n", a)
|
|
|
|
|
|
2019-05-19 12:14:30 -07:00
|
|
|
|
" Place a sign without specifying the filename or buffer
|
|
|
|
|
sign place 77 line=9 name=Sign2
|
|
|
|
|
let a=execute('sign place')
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for [NULL]:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=9 id=77 name=Sign2 priority=10\n", a)
|
2019-05-19 12:14:30 -07:00
|
|
|
|
sign unplace *
|
|
|
|
|
|
2016-11-15 14:30:14 -07:00
|
|
|
|
" Check :jump with file=...
|
|
|
|
|
edit foo
|
|
|
|
|
call setline(1, ['A', 'B', 'C', 'D'])
|
|
|
|
|
|
2020-12-11 08:10:33 -07:00
|
|
|
|
call Sign_command_ignore_error('sign define Sign3 text=y texthl=DoesNotExist linehl=DoesNotExist icon=doesnotexist.xpm')
|
2016-11-15 14:30:14 -07:00
|
|
|
|
|
|
|
|
|
let fn = expand('%:p')
|
|
|
|
|
exe 'sign place 43 line=2 name=Sign3 file=' . fn
|
|
|
|
|
edit bar
|
|
|
|
|
call assert_notequal(fn, expand('%:p'))
|
|
|
|
|
exe 'sign jump 43 file=' . fn
|
|
|
|
|
call assert_equal('B', getline('.'))
|
|
|
|
|
|
2019-05-17 03:34:50 -07:00
|
|
|
|
" Check for jumping to a sign in a hidden buffer
|
|
|
|
|
enew! | only!
|
|
|
|
|
edit foo
|
|
|
|
|
call setline(1, ['A', 'B', 'C', 'D'])
|
|
|
|
|
let fn = expand('%:p')
|
|
|
|
|
exe 'sign place 21 line=3 name=Sign3 file=' . fn
|
|
|
|
|
hide edit bar
|
|
|
|
|
exe 'sign jump 21 file=' . fn
|
|
|
|
|
call assert_equal('C', getline('.'))
|
|
|
|
|
|
2018-12-14 20:46:22 -07:00
|
|
|
|
" can't define a sign with a non-printable character as text
|
|
|
|
|
call assert_fails("sign define Sign4 text=\e linehl=Comment", 'E239:')
|
|
|
|
|
call assert_fails("sign define Sign4 text=a\e linehl=Comment", 'E239:')
|
|
|
|
|
call assert_fails("sign define Sign4 text=\ea linehl=Comment", 'E239:')
|
|
|
|
|
|
2020-12-24 09:33:52 -07:00
|
|
|
|
" Only 0, 1 or 2 character text is allowed
|
2018-12-14 20:46:22 -07:00
|
|
|
|
call assert_fails("sign define Sign4 text=abc linehl=Comment", 'E239:')
|
2020-12-24 09:33:52 -07:00
|
|
|
|
" call assert_fails("sign define Sign4 text= linehl=Comment", 'E239:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_fails("sign define Sign4 text=\\ ab linehl=Comment", 'E239:')
|
2018-12-14 20:46:22 -07:00
|
|
|
|
|
2021-12-05 19:57:22 -07:00
|
|
|
|
" an empty highlight argument for an existing sign clears it
|
2022-12-19 20:03:38 -07:00
|
|
|
|
sign define SignY texthl=TextHl culhl=CulHl linehl=LineHl numhl=NumHl
|
2021-12-05 19:57:22 -07:00
|
|
|
|
let sl = sign_getdefined('SignY')[0]
|
|
|
|
|
call assert_equal('TextHl', sl.texthl)
|
|
|
|
|
call assert_equal('CulHl', sl.culhl)
|
|
|
|
|
call assert_equal('LineHl', sl.linehl)
|
2022-12-19 20:03:38 -07:00
|
|
|
|
call assert_equal('NumHl', sl.numhl)
|
2021-12-05 19:57:22 -07:00
|
|
|
|
|
2022-12-19 20:03:38 -07:00
|
|
|
|
sign define SignY texthl= culhl=CulHl linehl=LineHl numhl=NumHl
|
2021-12-05 19:57:22 -07:00
|
|
|
|
let sl = sign_getdefined('SignY')[0]
|
|
|
|
|
call assert_false(has_key(sl, 'texthl'))
|
|
|
|
|
call assert_equal('CulHl', sl.culhl)
|
|
|
|
|
call assert_equal('LineHl', sl.linehl)
|
2022-12-19 20:03:38 -07:00
|
|
|
|
call assert_equal('NumHl', sl.numhl)
|
2021-12-05 19:57:22 -07:00
|
|
|
|
|
|
|
|
|
sign define SignY linehl=
|
|
|
|
|
let sl = sign_getdefined('SignY')[0]
|
|
|
|
|
call assert_false(has_key(sl, 'linehl'))
|
|
|
|
|
call assert_equal('CulHl', sl.culhl)
|
2022-12-19 20:03:38 -07:00
|
|
|
|
call assert_equal('NumHl', sl.numhl)
|
2021-12-05 19:57:22 -07:00
|
|
|
|
|
|
|
|
|
sign define SignY culhl=
|
|
|
|
|
let sl = sign_getdefined('SignY')[0]
|
|
|
|
|
call assert_false(has_key(sl, 'culhl'))
|
2022-12-19 20:03:38 -07:00
|
|
|
|
call assert_equal('NumHl', sl.numhl)
|
|
|
|
|
|
|
|
|
|
sign define SignY numhl=
|
|
|
|
|
let sl = sign_getdefined('SignY')[0]
|
|
|
|
|
call assert_false(has_key(sl, 'numhl'))
|
2021-12-05 19:57:22 -07:00
|
|
|
|
|
|
|
|
|
sign undefine SignY
|
2021-12-05 19:39:37 -07:00
|
|
|
|
|
2018-12-14 20:46:22 -07:00
|
|
|
|
" define sign with whitespace
|
|
|
|
|
sign define Sign4 text=\ X linehl=Comment
|
|
|
|
|
sign undefine Sign4
|
|
|
|
|
sign define Sign4 linehl=Comment text=\ X
|
|
|
|
|
sign undefine Sign4
|
|
|
|
|
|
|
|
|
|
sign define Sign5 text=X\ linehl=Comment
|
|
|
|
|
sign undefine Sign5
|
2022-12-19 20:03:38 -07:00
|
|
|
|
sign define Sign5 linehl=Comment text=X\
|
2018-12-14 20:46:22 -07:00
|
|
|
|
sign undefine Sign5
|
|
|
|
|
|
|
|
|
|
" define sign with backslash
|
|
|
|
|
sign define Sign4 text=\\\\ linehl=Comment
|
|
|
|
|
sign undefine Sign4
|
|
|
|
|
sign define Sign4 text=\\ linehl=Comment
|
|
|
|
|
sign undefine Sign4
|
|
|
|
|
|
2019-05-17 03:34:50 -07:00
|
|
|
|
" define a sign with a leading 0 in the name
|
|
|
|
|
sign unplace *
|
|
|
|
|
sign define 004 text=#> linehl=Comment
|
|
|
|
|
let a = execute('sign list 4')
|
|
|
|
|
call assert_equal("\nsign 4 text=#> linehl=Comment", a)
|
|
|
|
|
exe 'sign place 20 line=3 name=004 buffer=' . bufnr('')
|
|
|
|
|
let a = execute('sign place')
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for foo:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=3 id=20 name=4 priority=10\n", a)
|
2019-05-17 03:34:50 -07:00
|
|
|
|
exe 'sign unplace 20 buffer=' . bufnr('')
|
|
|
|
|
sign undefine 004
|
|
|
|
|
call assert_fails('sign list 4', 'E155:')
|
|
|
|
|
|
2016-11-15 14:28:23 -07:00
|
|
|
|
" After undefining the sign, we should no longer be able to place it.
|
|
|
|
|
sign undefine Sign1
|
|
|
|
|
sign undefine Sign2
|
2016-11-15 14:30:14 -07:00
|
|
|
|
sign undefine Sign3
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign place 41 line=3 name=Sign1 buffer=" .
|
|
|
|
|
\ bufnr('%'), 'E155:')
|
2016-11-15 14:30:14 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2023-03-03 07:24:12 -07:00
|
|
|
|
func Test_sign_many_bytes()
|
|
|
|
|
new
|
|
|
|
|
set signcolumn=number
|
|
|
|
|
set number
|
|
|
|
|
call setline(1, 'some text')
|
|
|
|
|
" composing characters can use many bytes, check for overflow
|
|
|
|
|
sign define manyBytes text=▶᷄᷅᷆◀᷄᷅᷆᷇
|
|
|
|
|
sign place 17 line=1 name=manyBytes
|
|
|
|
|
redraw
|
|
|
|
|
|
|
|
|
|
bwipe!
|
|
|
|
|
sign undefine manyBytes
|
|
|
|
|
endfunc
|
|
|
|
|
|
2016-11-15 14:30:14 -07:00
|
|
|
|
" Undefining placed sign is not recommended.
|
|
|
|
|
" Quoting :help sign
|
|
|
|
|
"
|
|
|
|
|
" :sign undefine {name}
|
|
|
|
|
" Deletes a previously defined sign. If signs with this {name}
|
|
|
|
|
" are still placed this will cause trouble.
|
|
|
|
|
func Test_sign_undefine_still_placed()
|
|
|
|
|
new foobar
|
|
|
|
|
sign define Sign text=x
|
|
|
|
|
exe 'sign place 41 line=1 name=Sign buffer=' . bufnr('%')
|
|
|
|
|
sign undefine Sign
|
|
|
|
|
|
|
|
|
|
" Listing placed sign should show that sign is deleted.
|
|
|
|
|
let a=execute('sign place')
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for foobar:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=1 id=41 name=[Deleted] priority=10\n", a)
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
2016-11-15 14:30:14 -07:00
|
|
|
|
sign unplace 41
|
|
|
|
|
let a=execute('sign place')
|
|
|
|
|
call assert_equal("\n--- Signs ---\n", a)
|
2016-11-15 14:28:23 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_sign_completion()
|
|
|
|
|
sign define Sign1 text=x
|
|
|
|
|
sign define Sign2 text=y
|
|
|
|
|
|
|
|
|
|
call feedkeys(":sign \<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign define jump list place undefine unplace', @:)
|
|
|
|
|
|
|
|
|
|
call feedkeys(":sign define Sign \<C-A>\<C-B>\"\<CR>", 'tx')
|
2021-12-22 12:53:37 -07:00
|
|
|
|
call assert_equal('"sign define Sign culhl= icon= linehl= numhl= text= texthl=', @:)
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
2021-12-22 12:53:37 -07:00
|
|
|
|
for hl in ['culhl', 'linehl', 'numhl', 'texthl']
|
|
|
|
|
call feedkeys(":sign define Sign "..hl.."=Spell\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign define Sign '..hl..'=SpellBad SpellCap ' .
|
|
|
|
|
\ 'SpellLocal SpellRare', @:)
|
|
|
|
|
endfor
|
2020-02-25 21:03:14 -07:00
|
|
|
|
|
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "XsignOne")
|
|
|
|
|
call writefile(repeat(["Sky is blue"], 30), "XsignTwo")
|
2016-12-12 21:26:51 -07:00
|
|
|
|
call feedkeys(":sign define Sign icon=Xsig\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign define Sign icon=XsignOne XsignTwo', @:)
|
2016-11-15 14:30:14 -07:00
|
|
|
|
|
2020-02-25 21:03:14 -07:00
|
|
|
|
" Test for completion of arguments to ':sign undefine'
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call feedkeys(":sign undefine \<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign undefine Sign1 Sign2', @:)
|
|
|
|
|
|
|
|
|
|
call feedkeys(":sign place 1 \<C-A>\<C-B>\"\<CR>", 'tx')
|
2019-05-16 12:27:41 -07:00
|
|
|
|
call assert_equal('"sign place 1 buffer= file= group= line= name= priority=',
|
|
|
|
|
\ @:)
|
2016-11-15 14:28:23 -07:00
|
|
|
|
|
|
|
|
|
call feedkeys(":sign place 1 name=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign place 1 name=Sign1 Sign2', @:)
|
|
|
|
|
|
2020-02-25 21:03:14 -07:00
|
|
|
|
edit XsignOne
|
|
|
|
|
sign place 1 name=Sign1 line=5
|
|
|
|
|
sign place 1 name=Sign1 group=g1 line=10
|
|
|
|
|
edit XsignTwo
|
|
|
|
|
sign place 1 name=Sign2 group=g2 line=15
|
|
|
|
|
|
|
|
|
|
" Test for completion of group= and file= arguments to ':sign place'
|
|
|
|
|
call feedkeys(":sign place 1 name=Sign1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign place 1 name=Sign1 file=XsignOne XsignTwo', @:)
|
|
|
|
|
call feedkeys(":sign place 1 name=Sign1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign place 1 name=Sign1 group=g1 g2', @:)
|
|
|
|
|
|
|
|
|
|
" Test for completion of arguments to 'sign place' without sign identifier
|
|
|
|
|
call feedkeys(":sign place \<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign place buffer= file= group=', @:)
|
|
|
|
|
call feedkeys(":sign place file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign place file=XsignOne XsignTwo', @:)
|
|
|
|
|
call feedkeys(":sign place group=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign place group=g1 g2', @:)
|
|
|
|
|
call feedkeys(":sign place group=g1 file=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign place group=g1 file=XsignOne XsignTwo', @:)
|
|
|
|
|
|
|
|
|
|
" Test for completion of arguments to ':sign unplace'
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call feedkeys(":sign unplace 1 \<C-A>\<C-B>\"\<CR>", 'tx')
|
2019-05-16 12:27:41 -07:00
|
|
|
|
call assert_equal('"sign unplace 1 buffer= file= group=', @:)
|
2020-02-25 21:03:14 -07:00
|
|
|
|
call feedkeys(":sign unplace 1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign unplace 1 file=XsignOne XsignTwo', @:)
|
|
|
|
|
call feedkeys(":sign unplace 1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign unplace 1 group=g1 g2', @:)
|
|
|
|
|
call feedkeys(":sign unplace 1 group=g2 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign unplace 1 group=g2 file=XsignOne XsignTwo', @:)
|
|
|
|
|
|
|
|
|
|
" Test for completion of arguments to ':sign list'
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call feedkeys(":sign list \<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign list Sign1 Sign2', @:)
|
|
|
|
|
|
2020-02-25 21:03:14 -07:00
|
|
|
|
" Test for completion of arguments to ':sign jump'
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call feedkeys(":sign jump 1 \<C-A>\<C-B>\"\<CR>", 'tx')
|
2019-05-16 12:27:41 -07:00
|
|
|
|
call assert_equal('"sign jump 1 buffer= file= group=', @:)
|
2020-02-25 21:03:14 -07:00
|
|
|
|
call feedkeys(":sign jump 1 file=Xsign\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign jump 1 file=XsignOne XsignTwo', @:)
|
|
|
|
|
call feedkeys(":sign jump 1 group=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign jump 1 group=g1 g2', @:)
|
|
|
|
|
|
|
|
|
|
" Error cases
|
|
|
|
|
call feedkeys(":sign here\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal('"sign here', @:)
|
|
|
|
|
call feedkeys(":sign define Sign here=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal("\"sign define Sign here=\<C-A>", @:)
|
|
|
|
|
call feedkeys(":sign place 1 here=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal("\"sign place 1 here=\<C-A>", @:)
|
|
|
|
|
call feedkeys(":sign jump 1 here=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal("\"sign jump 1 here=\<C-A>", @:)
|
|
|
|
|
call feedkeys(":sign here there\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal("\"sign here there\<C-A>", @:)
|
|
|
|
|
call feedkeys(":sign here there=\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
|
call assert_equal("\"sign here there=\<C-A>", @:)
|
|
|
|
|
|
|
|
|
|
sign unplace * group=*
|
2016-11-15 14:28:23 -07:00
|
|
|
|
sign undefine Sign1
|
|
|
|
|
sign undefine Sign2
|
2020-02-25 21:03:14 -07:00
|
|
|
|
enew
|
|
|
|
|
call delete('XsignOne')
|
|
|
|
|
call delete('XsignTwo')
|
2016-11-15 14:28:23 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
func Test_sign_invalid_commands()
|
2019-05-06 23:26:09 -07:00
|
|
|
|
sign define Sign1 text=x
|
|
|
|
|
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call assert_fails('sign', 'E471:')
|
2016-11-15 14:30:14 -07:00
|
|
|
|
call assert_fails('sign jump', 'E471:')
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call assert_fails('sign xxx', 'E160:')
|
|
|
|
|
call assert_fails('sign define', 'E156:')
|
2016-11-15 14:30:14 -07:00
|
|
|
|
call assert_fails('sign define Sign1 xxx', 'E475:')
|
2016-11-15 14:28:23 -07:00
|
|
|
|
call assert_fails('sign undefine', 'E156:')
|
|
|
|
|
call assert_fails('sign list xxx', 'E155:')
|
2018-02-03 04:11:07 -07:00
|
|
|
|
call assert_fails('sign place 1 buffer=999', 'E158:')
|
2019-05-17 03:34:50 -07:00
|
|
|
|
call assert_fails('sign place 1 name=Sign1 buffer=999', 'E158:')
|
|
|
|
|
call assert_fails('sign place buffer=999', 'E158:')
|
|
|
|
|
call assert_fails('sign jump buffer=999', 'E158:')
|
|
|
|
|
call assert_fails('sign jump 1 file=', 'E158:')
|
|
|
|
|
call assert_fails('sign jump 1 group=', 'E474:')
|
|
|
|
|
call assert_fails('sign jump 1 name=', 'E474:')
|
|
|
|
|
call assert_fails('sign jump 1 name=Sign1', 'E474:')
|
|
|
|
|
call assert_fails('sign jump 1 line=100', '474:')
|
2020-12-24 09:33:52 -07:00
|
|
|
|
" call assert_fails('sign define Sign2 text=', 'E239:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Non-numeric identifier for :sign place
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_fails("sign place abc line=3 name=Sign1 buffer=" . bufnr(''),
|
|
|
|
|
\ 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Non-numeric identifier for :sign unplace
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_fails("sign unplace abc name=Sign1 buffer=" . bufnr(''),
|
|
|
|
|
\ 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Number followed by an alphabet as sign identifier for :sign place
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_fails("sign place 1abc line=3 name=Sign1 buffer=" . bufnr(''),
|
|
|
|
|
\ 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Number followed by an alphabet as sign identifier for :sign unplace
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_fails("sign unplace 2abc name=Sign1 buffer=" . bufnr(''),
|
|
|
|
|
\ 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Sign identifier and '*' for :sign unplace
|
|
|
|
|
call assert_fails("sign unplace 2 *", 'E474:')
|
|
|
|
|
" Trailing characters after buffer number for :sign place
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_fails("sign place 1 line=3 name=Sign1 buffer=" .
|
|
|
|
|
\ bufnr('%') . 'xxx', 'E488:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Trailing characters after buffer number for :sign unplace
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign unplace 1 buffer=" . bufnr('%') . 'xxx', 'E488:')
|
|
|
|
|
call assert_fails("sign unplace * buffer=" . bufnr('%') . 'xxx', 'E488:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_fails("sign unplace 1 xxx", 'E474:')
|
|
|
|
|
call assert_fails("sign unplace * xxx", 'E474:')
|
|
|
|
|
call assert_fails("sign unplace xxx", 'E474:')
|
|
|
|
|
" Placing a sign without line number
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign place name=Sign1 buffer=" . bufnr('%'), 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Placing a sign without sign name
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign place line=10 buffer=" . bufnr('%'), 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Unplacing a sign with line number
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign unplace 2 line=10 buffer=" . bufnr('%'), 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Unplacing a sign with sign name
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign unplace 2 name=Sign1 buffer=" . bufnr('%'), 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Placing a sign without sign name
|
2019-05-09 08:30:23 -07:00
|
|
|
|
call assert_fails("sign place 2 line=3 buffer=" . bufnr('%'), 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Placing a sign with only sign identifier
|
|
|
|
|
call assert_fails("sign place 2", 'E474:')
|
|
|
|
|
" Placing a sign with only a name
|
|
|
|
|
call assert_fails("sign place abc", 'E474:')
|
|
|
|
|
" Placing a sign with only line number
|
|
|
|
|
call assert_fails("sign place 5 line=3", 'E474:')
|
|
|
|
|
" Placing a sign with only sign group
|
|
|
|
|
call assert_fails("sign place 5 group=g1", 'E474:')
|
|
|
|
|
call assert_fails("sign place 5 group=*", 'E474:')
|
|
|
|
|
" Placing a sign with only sign priority
|
|
|
|
|
call assert_fails("sign place 5 priority=10", 'E474:')
|
|
|
|
|
|
|
|
|
|
sign undefine Sign1
|
2016-11-15 14:28:23 -07:00
|
|
|
|
endfunc
|
2016-11-15 14:38:33 -07:00
|
|
|
|
|
|
|
|
|
func Test_sign_delete_buffer()
|
|
|
|
|
new
|
|
|
|
|
sign define Sign text=x
|
|
|
|
|
let bufnr = bufnr('%')
|
|
|
|
|
new
|
|
|
|
|
exe 'bd ' . bufnr
|
|
|
|
|
exe 'sign place 61 line=3 name=Sign buffer=' . bufnr
|
|
|
|
|
call assert_fails('sign jump 61 buffer=' . bufnr, 'E934:')
|
|
|
|
|
sign unplace 61
|
|
|
|
|
sign undefine Sign
|
|
|
|
|
endfunc
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2020-12-11 08:10:33 -07:00
|
|
|
|
" Ignore error: E255: Couldn't read in sign data!
|
|
|
|
|
" This error can happen when running in the GUI.
|
|
|
|
|
" Some gui like Motif do not support the png icon format.
|
|
|
|
|
func Sign_command_ignore_error(cmd)
|
|
|
|
|
try
|
|
|
|
|
exe a:cmd
|
|
|
|
|
catch /E255:/
|
|
|
|
|
endtry
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" ignore error: E255: Couldn't read in sign data!
|
|
|
|
|
" This error can happen when running in gui.
|
|
|
|
|
func Sign_define_ignore_error(name, attr)
|
|
|
|
|
try
|
|
|
|
|
call sign_define(a:name, a:attr)
|
|
|
|
|
catch /E255:/
|
|
|
|
|
endtry
|
|
|
|
|
endfunc
|
|
|
|
|
|
2019-05-15 13:02:10 -07:00
|
|
|
|
" Test for Vim script functions for managing signs
|
2019-05-06 23:26:09 -07:00
|
|
|
|
func Test_sign_funcs()
|
|
|
|
|
" Remove all the signs
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
|
|
|
|
|
|
|
|
|
" Tests for sign_define()
|
2021-12-05 13:36:54 -07:00
|
|
|
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error',
|
2021-12-22 12:53:37 -07:00
|
|
|
|
\ 'culhl': 'Visual', 'numhl': 'Number'}
|
2021-10-31 10:31:35 -07:00
|
|
|
|
call assert_equal(0, "sign1"->sign_define(attr))
|
2022-12-19 20:03:38 -07:00
|
|
|
|
call assert_equal([{'name' : 'sign1', 'texthl' : 'Error', 'linehl' : 'Search',
|
|
|
|
|
\ 'culhl' : 'Visual', 'numhl': 'Number', 'text' : '=>'}],
|
2021-12-05 13:36:54 -07:00
|
|
|
|
\ sign_getdefined())
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
" Define a new sign without attributes and then update it
|
|
|
|
|
call sign_define("sign2")
|
|
|
|
|
let attr = {'text' : '!!', 'linehl' : 'DiffAdd', 'texthl' : 'DiffChange',
|
2021-12-22 12:53:37 -07:00
|
|
|
|
\ 'culhl': 'DiffDelete', 'numhl': 'Number', 'icon' : 'sign2.ico'}
|
2020-12-11 08:10:33 -07:00
|
|
|
|
call Sign_define_ignore_error("sign2", attr)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal([{'name' : 'sign2', 'texthl' : 'DiffChange',
|
2021-12-05 13:36:54 -07:00
|
|
|
|
\ 'linehl' : 'DiffAdd', 'culhl' : 'DiffDelete', 'text' : '!!',
|
2021-12-22 12:53:37 -07:00
|
|
|
|
\ 'numhl': 'Number', 'icon' : 'sign2.ico'}],
|
|
|
|
|
\ "sign2"->sign_getdefined())
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
" Test for a sign name with digits
|
|
|
|
|
call assert_equal(0, sign_define(0002, {'linehl' : 'StatusLine'}))
|
|
|
|
|
call assert_equal([{'name' : '2', 'linehl' : 'StatusLine'}],
|
|
|
|
|
\ sign_getdefined(0002))
|
2021-10-31 10:31:35 -07:00
|
|
|
|
eval 0002->sign_undefine()
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
" Tests for invalid arguments to sign_define()
|
|
|
|
|
call assert_fails('call sign_define("sign4", {"text" : "===>"})', 'E239:')
|
2020-12-24 09:33:52 -07:00
|
|
|
|
" call assert_fails('call sign_define("sign5", {"text" : ""})', 'E239:')
|
2021-03-05 17:50:07 -07:00
|
|
|
|
call assert_fails('call sign_define({})', 'E731:')
|
2023-04-25 06:32:12 -07:00
|
|
|
|
call assert_fails('call sign_define("sign6", [])', 'E1206:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
" Tests for sign_getdefined()
|
|
|
|
|
call assert_equal([], sign_getdefined("none"))
|
|
|
|
|
call assert_fails('call sign_getdefined({})', 'E731:')
|
|
|
|
|
|
|
|
|
|
" Tests for sign_place()
|
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
|
|
|
|
edit Xsign
|
|
|
|
|
|
|
|
|
|
call assert_equal(10, sign_place(10, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 20}))
|
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
|
|
|
|
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
|
|
|
|
\ 'priority' : 10}]}], sign_getplaced('Xsign'))
|
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
|
|
|
|
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
|
|
|
|
\ 'priority' : 10}]}],
|
2021-10-31 10:31:35 -07:00
|
|
|
|
\ '%'->sign_getplaced({'lnum' : 20}))
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
|
|
|
|
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
|
|
|
|
\ 'priority' : 10}]}],
|
2019-05-19 09:38:25 -07:00
|
|
|
|
\ sign_getplaced('', {'id' : 10}))
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
" Tests for invalid arguments to sign_place()
|
|
|
|
|
call assert_fails('call sign_place([], "", "mySign", 1)', 'E745:')
|
|
|
|
|
call assert_fails('call sign_place(5, "", "mySign", -1)', 'E158:')
|
2023-04-25 06:32:12 -07:00
|
|
|
|
call assert_fails('call sign_place(-1, "", "sign1", "Xsign", [])', 'E1206:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_fails('call sign_place(-1, "", "sign1", "Xsign",
|
|
|
|
|
\ {"lnum" : 30})', 'E474:')
|
|
|
|
|
call assert_fails('call sign_place(10, "", "xsign1x", "Xsign",
|
|
|
|
|
\ {"lnum" : 30})', 'E155:')
|
|
|
|
|
call assert_fails('call sign_place(10, "", "", "Xsign",
|
|
|
|
|
\ {"lnum" : 30})', 'E155:')
|
|
|
|
|
call assert_fails('call sign_place(10, "", [], "Xsign",
|
|
|
|
|
\ {"lnum" : 30})', 'E730:')
|
|
|
|
|
call assert_fails('call sign_place(5, "", "sign1", "abcxyz.xxx",
|
|
|
|
|
\ {"lnum" : 10})', 'E158:')
|
2019-05-19 09:38:25 -07:00
|
|
|
|
call assert_fails('call sign_place(5, "", "sign1", "@", {"lnum" : 10})',
|
2019-05-06 23:26:09 -07:00
|
|
|
|
\ 'E158:')
|
|
|
|
|
call assert_fails('call sign_place(5, "", "sign1", [], {"lnum" : 10})',
|
2022-11-04 16:24:06 -07:00
|
|
|
|
\ 'E730:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_fails('call sign_place(21, "", "sign1", "Xsign",
|
2021-03-11 17:07:49 -07:00
|
|
|
|
\ {"lnum" : -1})', 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_fails('call sign_place(22, "", "sign1", "Xsign",
|
2021-03-11 17:07:49 -07:00
|
|
|
|
\ {"lnum" : 0})', 'E474:')
|
2019-05-17 03:20:22 -07:00
|
|
|
|
call assert_fails('call sign_place(22, "", "sign1", "Xsign",
|
2022-11-04 16:24:06 -07:00
|
|
|
|
\ {"lnum" : []})', 'E745:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal(-1, sign_place(1, "*", "sign1", "Xsign", {"lnum" : 10}))
|
|
|
|
|
|
|
|
|
|
" Tests for sign_getplaced()
|
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
|
|
|
|
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
|
|
|
|
\ 'priority' : 10}]}],
|
|
|
|
|
\ sign_getplaced(bufnr('Xsign')))
|
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
|
|
|
|
\ [{'id' : 10, 'group' : '', 'lnum' : 20, 'name' : 'sign1',
|
|
|
|
|
\ 'priority' : 10}]}],
|
|
|
|
|
\ sign_getplaced())
|
|
|
|
|
call assert_fails("call sign_getplaced('dummy.sign')", 'E158:')
|
2019-05-19 09:38:25 -07:00
|
|
|
|
call assert_fails('call sign_getplaced("&")', 'E158:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_fails('call sign_getplaced(-1)', 'E158:')
|
2023-04-25 06:32:12 -07:00
|
|
|
|
call assert_fails('call sign_getplaced("Xsign", [])', 'E1206:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' : []}],
|
|
|
|
|
\ sign_getplaced('Xsign', {'lnum' : 1000000}))
|
|
|
|
|
call assert_fails("call sign_getplaced('Xsign', {'lnum' : []})",
|
|
|
|
|
\ 'E745:')
|
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' : []}],
|
|
|
|
|
\ sign_getplaced('Xsign', {'id' : 44}))
|
|
|
|
|
call assert_fails("call sign_getplaced('Xsign', {'id' : []})",
|
|
|
|
|
\ 'E745:')
|
|
|
|
|
|
|
|
|
|
" Tests for sign_unplace()
|
2021-10-31 10:31:35 -07:00
|
|
|
|
eval 20->sign_place('', 'sign2', 'Xsign', {"lnum" : 30})
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal(0, sign_unplace('',
|
|
|
|
|
\ {'id' : 20, 'buffer' : 'Xsign'}))
|
2021-10-31 10:31:35 -07:00
|
|
|
|
call assert_equal(-1, ''->sign_unplace(
|
2019-05-06 23:26:09 -07:00
|
|
|
|
\ {'id' : 30, 'buffer' : 'Xsign'}))
|
|
|
|
|
call sign_place(20, '', 'sign2', 'Xsign', {"lnum" : 30})
|
|
|
|
|
call assert_fails("call sign_unplace('',
|
|
|
|
|
\ {'id' : 20, 'buffer' : 'buffer.c'})", 'E158:')
|
|
|
|
|
call assert_fails("call sign_unplace('',
|
2019-05-19 09:38:25 -07:00
|
|
|
|
\ {'id' : 20, 'buffer' : '&'})", 'E158:')
|
2019-05-17 03:20:22 -07:00
|
|
|
|
call assert_fails("call sign_unplace('g1',
|
2019-05-06 23:26:09 -07:00
|
|
|
|
\ {'id' : 20, 'buffer' : 200})", 'E158:')
|
2023-04-25 06:32:12 -07:00
|
|
|
|
call assert_fails("call sign_unplace('g1', 'mySign')", 'E1206:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2021-03-05 17:50:07 -07:00
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Test for modifying a placed sign
|
|
|
|
|
call assert_equal(15, sign_place(15, '', 'sign1', 'Xsign', {'lnum' : 20}))
|
|
|
|
|
call assert_equal(15, sign_place(15, '', 'sign2', 'Xsign'))
|
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
2022-12-19 20:03:38 -07:00
|
|
|
|
\ [{'id' : 15, 'group' : '', 'lnum' : 20, 'name' : 'sign2',
|
|
|
|
|
\ 'priority' : 10}]}],
|
|
|
|
|
\ sign_getplaced())
|
2021-03-05 17:50:07 -07:00
|
|
|
|
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Tests for sign_undefine()
|
|
|
|
|
call assert_equal(0, sign_undefine("sign1"))
|
|
|
|
|
call assert_equal([], sign_getdefined("sign1"))
|
|
|
|
|
call assert_fails('call sign_undefine("none")', 'E155:')
|
2021-03-05 17:50:07 -07:00
|
|
|
|
call assert_fails('call sign_undefine({})', 'E731:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2020-12-11 08:10:33 -07:00
|
|
|
|
" Test for using '.' as the line number for sign_place()
|
|
|
|
|
call Sign_define_ignore_error("sign1", attr)
|
|
|
|
|
call cursor(22, 1)
|
|
|
|
|
call assert_equal(15, sign_place(15, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : '.'}))
|
|
|
|
|
call assert_equal([{'bufnr' : bufnr(''), 'signs' :
|
|
|
|
|
\ [{'id' : 15, 'group' : '', 'lnum' : 22, 'name' : 'sign1',
|
|
|
|
|
\ 'priority' : 10}]}],
|
|
|
|
|
\ sign_getplaced('%', {'lnum' : 22}))
|
|
|
|
|
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call delete("Xsign")
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
|
|
|
|
enew | only
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Tests for sign groups
|
|
|
|
|
func Test_sign_group()
|
|
|
|
|
enew | only
|
|
|
|
|
" Remove all the signs
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
|
|
|
|
|
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
|
|
|
|
|
|
|
|
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
|
|
|
|
|
call assert_equal(0, sign_define("sign1", attr))
|
|
|
|
|
|
|
|
|
|
edit Xsign
|
|
|
|
|
let bnum = bufnr('%')
|
|
|
|
|
|
|
|
|
|
" Error case
|
|
|
|
|
call assert_fails("call sign_place(5, [], 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 30})", 'E730:')
|
|
|
|
|
|
|
|
|
|
" place three signs with the same identifier. One in the global group and
|
|
|
|
|
" others in the named groups
|
|
|
|
|
call assert_equal(5, sign_place(5, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 10}))
|
|
|
|
|
call assert_equal(5, sign_place(5, 'g1', 'sign1', bnum, {'lnum' : 20}))
|
|
|
|
|
call assert_equal(5, sign_place(5, 'g2', 'sign1', bnum, {'lnum' : 30}))
|
|
|
|
|
|
|
|
|
|
" Test for sign_getplaced() with group
|
|
|
|
|
let s = sign_getplaced('Xsign')
|
|
|
|
|
call assert_equal(1, len(s[0].signs))
|
|
|
|
|
call assert_equal(s[0].signs[0].group, '')
|
2019-05-16 12:27:41 -07:00
|
|
|
|
let s = sign_getplaced(bnum, {'group' : ''})
|
|
|
|
|
call assert_equal([{'id' : 5, 'group' : '', 'name' : 'sign1', 'lnum' : 10,
|
|
|
|
|
\ 'priority' : 10}], s[0].signs)
|
|
|
|
|
call assert_equal(1, len(s[0].signs))
|
2019-05-06 23:26:09 -07:00
|
|
|
|
let s = sign_getplaced(bnum, {'group' : 'g2'})
|
|
|
|
|
call assert_equal('g2', s[0].signs[0].group)
|
|
|
|
|
let s = sign_getplaced(bnum, {'group' : 'g3'})
|
|
|
|
|
call assert_equal([], s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum, {'group' : '*'})
|
|
|
|
|
call assert_equal([{'id' : 5, 'group' : '', 'name' : 'sign1', 'lnum' : 10,
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 5, 'group' : 'g1', 'name' : 'sign1', 'lnum' : 20,
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 5, 'group' : 'g2', 'name' : 'sign1', 'lnum' : 30,
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for sign_getplaced() with id
|
|
|
|
|
let s = sign_getplaced(bnum, {'id' : 5})
|
|
|
|
|
call assert_equal([{'id' : 5, 'group' : '', 'name' : 'sign1', 'lnum' : 10,
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum, {'id' : 5, 'group' : 'g2'})
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ [{'id' : 5, 'name' : 'sign1', 'lnum' : 30, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum, {'id' : 5, 'group' : '*'})
|
|
|
|
|
call assert_equal([{'id' : 5, 'group' : '', 'name' : 'sign1', 'lnum' : 10,
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 5, 'group' : 'g1', 'name' : 'sign1', 'lnum' : 20,
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 5, 'group' : 'g2', 'name' : 'sign1', 'lnum' : 30,
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum, {'id' : 5, 'group' : 'g3'})
|
|
|
|
|
call assert_equal([], s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for sign_getplaced() with lnum
|
|
|
|
|
let s = sign_getplaced(bnum, {'lnum' : 20})
|
|
|
|
|
call assert_equal([], s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum, {'lnum' : 20, 'group' : 'g1'})
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ [{'id' : 5, 'name' : 'sign1', 'lnum' : 20, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum, {'lnum' : 30, 'group' : '*'})
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ [{'id' : 5, 'name' : 'sign1', 'lnum' : 30, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum, {'lnum' : 40, 'group' : '*'})
|
|
|
|
|
call assert_equal([], s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Error case
|
|
|
|
|
call assert_fails("call sign_getplaced(bnum, {'group' : []})",
|
|
|
|
|
\ 'E730:')
|
|
|
|
|
|
|
|
|
|
" Clear the sign in global group
|
|
|
|
|
call sign_unplace('', {'id' : 5, 'buffer' : bnum})
|
|
|
|
|
let s = sign_getplaced(bnum, {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign1', 'lnum' : 20, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign1', 'lnum' : 30, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Clear the sign in one of the groups
|
|
|
|
|
call sign_unplace('g1', {'buffer' : 'Xsign'})
|
|
|
|
|
let s = sign_getplaced(bnum, {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign1', 'lnum' : 30, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Clear all the signs from the buffer
|
|
|
|
|
call sign_unplace('*', {'buffer' : bnum})
|
|
|
|
|
call assert_equal([], sign_getplaced(bnum, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Clear sign across groups using an identifier
|
|
|
|
|
call sign_place(25, '', 'sign1', bnum, {'lnum' : 10})
|
|
|
|
|
call sign_place(25, 'g1', 'sign1', bnum, {'lnum' : 11})
|
|
|
|
|
call sign_place(25, 'g2', 'sign1', bnum, {'lnum' : 12})
|
|
|
|
|
call assert_equal(0, sign_unplace('*', {'id' : 25}))
|
|
|
|
|
call assert_equal([], sign_getplaced(bnum, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Error case
|
2023-04-25 08:39:15 -07:00
|
|
|
|
call assert_fails("call sign_unplace({})", 'E1174:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
" Place a sign in the global group and try to delete it using a group
|
|
|
|
|
call assert_equal(5, sign_place(5, '', 'sign1', bnum, {'lnum' : 10}))
|
|
|
|
|
call assert_equal(-1, sign_unplace('g1', {'id' : 5}))
|
|
|
|
|
|
|
|
|
|
" Place signs in multiple groups and delete all the signs in one of the
|
|
|
|
|
" group
|
|
|
|
|
call assert_equal(5, sign_place(5, '', 'sign1', bnum, {'lnum' : 10}))
|
|
|
|
|
call assert_equal(6, sign_place(6, '', 'sign1', bnum, {'lnum' : 11}))
|
|
|
|
|
call assert_equal(5, sign_place(5, 'g1', 'sign1', bnum, {'lnum' : 10}))
|
|
|
|
|
call assert_equal(5, sign_place(5, 'g2', 'sign1', bnum, {'lnum' : 10}))
|
|
|
|
|
call assert_equal(6, sign_place(6, 'g1', 'sign1', bnum, {'lnum' : 11}))
|
|
|
|
|
call assert_equal(6, sign_place(6, 'g2', 'sign1', bnum, {'lnum' : 11}))
|
|
|
|
|
call assert_equal(0, sign_unplace('g1'))
|
|
|
|
|
let s = sign_getplaced(bnum, {'group' : 'g1'})
|
|
|
|
|
call assert_equal([], s[0].signs)
|
|
|
|
|
let s = sign_getplaced(bnum)
|
|
|
|
|
call assert_equal(2, len(s[0].signs))
|
|
|
|
|
let s = sign_getplaced(bnum, {'group' : 'g2'})
|
|
|
|
|
call assert_equal('g2', s[0].signs[0].group)
|
|
|
|
|
call assert_equal(0, sign_unplace('', {'id' : 5}))
|
|
|
|
|
call assert_equal(0, sign_unplace('', {'id' : 6}))
|
|
|
|
|
let s = sign_getplaced(bnum, {'group' : 'g2'})
|
|
|
|
|
call assert_equal('g2', s[0].signs[0].group)
|
|
|
|
|
call assert_equal(0, sign_unplace('', {'buffer' : bnum}))
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Test for :sign command and groups
|
2019-05-09 08:30:23 -07:00
|
|
|
|
sign place 5 line=10 name=sign1 file=Xsign
|
|
|
|
|
sign place 5 group=g1 line=10 name=sign1 file=Xsign
|
|
|
|
|
sign place 5 group=g2 line=10 name=sign1 file=Xsign
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Tests for the ':sign place' command
|
|
|
|
|
|
|
|
|
|
" :sign place file={fname}
|
2019-05-09 08:30:23 -07:00
|
|
|
|
let a = execute('sign place file=Xsign')
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 name=sign1 priority=10\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" :sign place group={group} file={fname}
|
2019-05-09 08:30:23 -07:00
|
|
|
|
let a = execute('sign place group=g2 file=Xsign')
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 group=g2 name=sign1 priority=10\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" :sign place group=* file={fname}
|
2019-05-09 08:30:23 -07:00
|
|
|
|
let a = execute('sign place group=* file=Xsign')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 group=g2 name=sign1 priority=10\n" .
|
|
|
|
|
\ " line=10 id=5 group=g1 name=sign1 priority=10\n" .
|
|
|
|
|
\ " line=10 id=5 name=sign1 priority=10\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Error case: non-existing group
|
2019-05-09 08:30:23 -07:00
|
|
|
|
let a = execute('sign place group=xyz file=Xsign')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n", a)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
let bnum = bufnr('Xsign')
|
|
|
|
|
exe 'sign place 5 line=10 name=sign1 buffer=' . bnum
|
|
|
|
|
exe 'sign place 5 group=g1 line=11 name=sign1 buffer=' . bnum
|
|
|
|
|
exe 'sign place 5 group=g2 line=12 name=sign1 buffer=' . bnum
|
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" :sign place buffer={fname}
|
2019-05-06 23:26:09 -07:00
|
|
|
|
let a = execute('sign place buffer=' . bnum)
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 name=sign1 priority=10\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" :sign place group={group} buffer={fname}
|
2019-05-06 23:26:09 -07:00
|
|
|
|
let a = execute('sign place group=g2 buffer=' . bnum)
|
2019-05-19 12:14:30 -07:00
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=12 id=5 group=g2 name=sign1 priority=10\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" :sign place group=* buffer={fname}
|
2019-05-06 23:26:09 -07:00
|
|
|
|
let a = execute('sign place group=* buffer=' . bnum)
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 name=sign1 priority=10\n" .
|
|
|
|
|
\ " line=11 id=5 group=g1 name=sign1 priority=10\n" .
|
|
|
|
|
\ " line=12 id=5 group=g2 name=sign1 priority=10\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Error case: non-existing group
|
2019-05-06 23:26:09 -07:00
|
|
|
|
let a = execute('sign place group=xyz buffer=' . bnum)
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n", a)
|
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" :sign place
|
|
|
|
|
let a = execute('sign place')
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 name=sign1 priority=10\n", a)
|
2019-05-16 12:27:41 -07:00
|
|
|
|
|
2019-05-20 02:04:58 -07:00
|
|
|
|
" Place signs in more than one buffer and list the signs
|
|
|
|
|
split foo
|
|
|
|
|
set buftype=nofile
|
|
|
|
|
sign place 25 line=76 name=sign1 priority=99 file=foo
|
|
|
|
|
let a = execute('sign place')
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
|
|
|
|
\ " line=10 id=5 name=sign1 priority=10\n" .
|
|
|
|
|
\ "Signs for foo:\n" .
|
|
|
|
|
\ " line=76 id=25 name=sign1 priority=99\n", a)
|
|
|
|
|
close
|
|
|
|
|
bwipe foo
|
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" :sign place group={group}
|
|
|
|
|
let a = execute('sign place group=g1')
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=11 id=5 group=g1 name=sign1 priority=10\n", a)
|
2019-05-16 12:27:41 -07:00
|
|
|
|
|
|
|
|
|
" :sign place group=*
|
2019-05-06 23:26:09 -07:00
|
|
|
|
let a = execute('sign place group=*')
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 name=sign1 priority=10\n" .
|
|
|
|
|
\ " line=11 id=5 group=g1 name=sign1 priority=10\n" .
|
|
|
|
|
\ " line=12 id=5 group=g2 name=sign1 priority=10\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Test for ':sign jump' command with groups
|
|
|
|
|
sign jump 5 group=g1 file=Xsign
|
|
|
|
|
call assert_equal(11, line('.'))
|
|
|
|
|
call assert_equal('Xsign', bufname(''))
|
|
|
|
|
sign jump 5 group=g2 file=Xsign
|
|
|
|
|
call assert_equal(12, line('.'))
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-19 12:14:30 -07:00
|
|
|
|
" Test for :sign jump command without the filename or buffer
|
|
|
|
|
sign jump 5
|
|
|
|
|
call assert_equal(10, line('.'))
|
|
|
|
|
sign jump 5 group=g1
|
|
|
|
|
call assert_equal(11, line('.'))
|
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Error cases
|
|
|
|
|
call assert_fails("sign place 3 group= name=sign1 buffer=" . bnum, 'E474:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
call delete("Xsign")
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
2019-05-17 03:20:22 -07:00
|
|
|
|
enew | only
|
2019-05-16 12:27:41 -07:00
|
|
|
|
endfunc
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Place signs used for ":sign unplace" command test
|
|
|
|
|
func Place_signs_for_test()
|
|
|
|
|
call sign_unplace('*')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
sign place 3 line=10 name=sign1 file=Xsign1
|
|
|
|
|
sign place 3 group=g1 line=11 name=sign1 file=Xsign1
|
|
|
|
|
sign place 3 group=g2 line=12 name=sign1 file=Xsign1
|
|
|
|
|
sign place 4 line=15 name=sign1 file=Xsign1
|
|
|
|
|
sign place 4 group=g1 line=16 name=sign1 file=Xsign1
|
|
|
|
|
sign place 4 group=g2 line=17 name=sign1 file=Xsign1
|
|
|
|
|
sign place 5 line=20 name=sign1 file=Xsign2
|
|
|
|
|
sign place 5 group=g1 line=21 name=sign1 file=Xsign2
|
|
|
|
|
sign place 5 group=g2 line=22 name=sign1 file=Xsign2
|
|
|
|
|
sign place 6 line=25 name=sign1 file=Xsign2
|
|
|
|
|
sign place 6 group=g1 line=26 name=sign1 file=Xsign2
|
|
|
|
|
sign place 6 group=g2 line=27 name=sign1 file=Xsign2
|
|
|
|
|
endfunc
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Place multiple signs in a single line for test
|
|
|
|
|
func Place_signs_at_line_for_test()
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
sign place 3 line=13 name=sign1 file=Xsign1
|
|
|
|
|
sign place 3 group=g1 line=13 name=sign1 file=Xsign1
|
|
|
|
|
sign place 3 group=g2 line=13 name=sign1 file=Xsign1
|
|
|
|
|
sign place 4 line=13 name=sign1 file=Xsign1
|
|
|
|
|
sign place 4 group=g1 line=13 name=sign1 file=Xsign1
|
|
|
|
|
sign place 4 group=g2 line=13 name=sign1 file=Xsign1
|
|
|
|
|
endfunc
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Tests for the ':sign unplace' command
|
|
|
|
|
func Test_sign_unplace()
|
|
|
|
|
enew | only
|
|
|
|
|
" Remove all the signs
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Create two files and define signs
|
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "Xsign1")
|
|
|
|
|
call writefile(repeat(["It is beautiful"], 30), "Xsign2")
|
|
|
|
|
|
|
|
|
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
|
|
|
|
|
call sign_define("sign1", attr)
|
|
|
|
|
|
|
|
|
|
edit Xsign1
|
|
|
|
|
let bnum1 = bufnr('%')
|
|
|
|
|
split Xsign2
|
|
|
|
|
let bnum2 = bufnr('%')
|
|
|
|
|
|
|
|
|
|
let signs1 = [{'id' : 3, 'name' : 'sign1', 'lnum' : 10, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign1', 'lnum' : 11, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign1', 'lnum' : 12, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign1', 'lnum' : 15, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign1', 'lnum' : 16, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign1', 'lnum' : 17, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10},]
|
|
|
|
|
let signs2 = [{'id' : 5, 'name' : 'sign1', 'lnum' : 20, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign1', 'lnum' : 21, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign1', 'lnum' : 22, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 6, 'name' : 'sign1', 'lnum' : 25, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 6, 'name' : 'sign1', 'lnum' : 26, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 6, 'name' : 'sign1', 'lnum' : 27, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10},]
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} file={fname}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace 3 file=Xsign1
|
|
|
|
|
sign unplace 6 file=Xsign2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 3 || val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 6 || val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} group={group} file={fname}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace 4 group=g1 file=Xsign1
|
|
|
|
|
sign unplace 5 group=g2 file=Xsign2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4 || val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 5 || val.group != 'g2'}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} group=* file={fname}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace 3 group=* file=Xsign1
|
|
|
|
|
sign unplace 6 group=* file=Xsign2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 3}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 6}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * file={fname}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace * file=Xsign1
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(signs2, sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * group={group} file={fname}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace * group=g1 file=Xsign1
|
|
|
|
|
sign unplace * group=g2 file=Xsign2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.group != 'g2'}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * group=* file={fname}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace * group=* file=Xsign2
|
|
|
|
|
call assert_equal(signs1, sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal([], sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} buffer={nr}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
exe 'sign unplace 3 buffer=' . bnum1
|
|
|
|
|
exe 'sign unplace 6 buffer=' . bnum2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 3 || val.group != ''}),
|
|
|
|
|
\ sign_getplaced(bnum1, {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 6 || val.group != ''}),
|
|
|
|
|
\ sign_getplaced(bnum2, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} group={group} buffer={nr}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
exe 'sign unplace 4 group=g1 buffer=' . bnum1
|
|
|
|
|
exe 'sign unplace 5 group=g2 buffer=' . bnum2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4 || val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced(bnum1, {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 5 || val.group != 'g2'}),
|
|
|
|
|
\ sign_getplaced(bnum2, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} group=* buffer={nr}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
exe 'sign unplace 3 group=* buffer=' . bnum1
|
|
|
|
|
exe 'sign unplace 6 group=* buffer=' . bnum2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 3}),
|
|
|
|
|
\ sign_getplaced(bnum1, {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 6}),
|
|
|
|
|
\ sign_getplaced(bnum2, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * buffer={nr}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
exe 'sign unplace * buffer=' . bnum1
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.group != ''}),
|
|
|
|
|
\ sign_getplaced(bnum1, {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(signs2, sign_getplaced(bnum2, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * group={group} buffer={nr}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
exe 'sign unplace * group=g1 buffer=' . bnum1
|
|
|
|
|
exe 'sign unplace * group=g2 buffer=' . bnum2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced(bnum1, {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.group != 'g2'}),
|
|
|
|
|
\ sign_getplaced(bnum2, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * group=* buffer={nr}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
exe 'sign unplace * group=* buffer=' . bnum2
|
|
|
|
|
call assert_equal(signs1, sign_getplaced(bnum1, {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal([], sign_getplaced(bnum2, {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace 4
|
|
|
|
|
sign unplace 6
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4 || val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 6 || val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} group={group}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace 4 group=g1
|
|
|
|
|
sign unplace 6 group=g2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4 || val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 6 || val.group != 'g2'}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace {id} group=*
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace 3 group=*
|
2019-05-06 23:26:09 -07:00
|
|
|
|
sign unplace 5 group=*
|
2019-05-16 12:27:41 -07:00
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 3}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.id != 5}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Test for :sign unplace *
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace *
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * group={group}
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace * group=g1
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs2),
|
|
|
|
|
\ {idx, val -> val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for :sign unplace * group=*
|
|
|
|
|
call Place_signs_for_test()
|
2019-05-06 23:26:09 -07:00
|
|
|
|
sign unplace * group=*
|
2019-05-16 12:27:41 -07:00
|
|
|
|
call assert_equal([], sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal([], sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
2019-05-16 12:27:41 -07:00
|
|
|
|
" Negative test cases
|
|
|
|
|
call Place_signs_for_test()
|
|
|
|
|
sign unplace 3 group=xy file=Xsign1
|
|
|
|
|
sign unplace * group=xy file=Xsign1
|
|
|
|
|
silent! sign unplace * group=* file=FileNotPresent
|
|
|
|
|
call assert_equal(signs1, sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
call assert_equal(signs2, sign_getplaced('Xsign2', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Tests for removing sign at the current cursor position
|
|
|
|
|
|
|
|
|
|
" Test for ':sign unplace'
|
|
|
|
|
let signs1 = [{'id' : 4, 'name' : 'sign1', 'lnum' : 13, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign1', 'lnum' : 13, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign1', 'lnum' : 13, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign1', 'lnum' : 13, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign1', 'lnum' : 13, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign1', 'lnum' : 13, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},]
|
|
|
|
|
exe bufwinnr('Xsign1') . 'wincmd w'
|
|
|
|
|
call cursor(13, 1)
|
|
|
|
|
|
|
|
|
|
" Should remove only one sign in the global group
|
|
|
|
|
call Place_signs_at_line_for_test()
|
|
|
|
|
sign unplace
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4 || val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
" Should remove the second sign in the global group
|
|
|
|
|
sign unplace
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.group != ''}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for ':sign unplace group={group}'
|
|
|
|
|
call Place_signs_at_line_for_test()
|
|
|
|
|
" Should remove only one sign in group g1
|
|
|
|
|
sign unplace group=g1
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4 || val.group != 'g1'}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
sign unplace group=g2
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4 || val.group == ''}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
|
|
|
|
|
" Test for ':sign unplace group=*'
|
|
|
|
|
call Place_signs_at_line_for_test()
|
|
|
|
|
sign unplace group=*
|
|
|
|
|
sign unplace group=*
|
|
|
|
|
sign unplace group=*
|
|
|
|
|
call assert_equal(
|
|
|
|
|
\ filter(copy(signs1),
|
|
|
|
|
\ {idx, val -> val.id != 4}),
|
|
|
|
|
\ sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
|
|
|
|
sign unplace group=*
|
|
|
|
|
sign unplace group=*
|
|
|
|
|
sign unplace group=*
|
|
|
|
|
call assert_equal([], sign_getplaced('Xsign1', {'group' : '*'})[0].signs)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
2019-05-17 03:20:22 -07:00
|
|
|
|
enew | only
|
2019-05-16 12:27:41 -07:00
|
|
|
|
call delete("Xsign1")
|
|
|
|
|
call delete("Xsign2")
|
2019-05-06 23:26:09 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
2022-12-19 20:03:38 -07:00
|
|
|
|
" Tests for auto-generating the sign identifier.
|
2021-03-05 17:50:07 -07:00
|
|
|
|
func Test_aaa_sign_id_autogen()
|
2019-05-06 23:26:09 -07:00
|
|
|
|
enew | only
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
|
|
|
|
|
|
|
|
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
|
|
|
|
|
call assert_equal(0, sign_define("sign1", attr))
|
|
|
|
|
|
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
|
|
|
|
edit Xsign
|
|
|
|
|
|
|
|
|
|
call assert_equal(1, sign_place(0, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 10}))
|
|
|
|
|
call assert_equal(2, sign_place(2, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 12}))
|
|
|
|
|
call assert_equal(3, sign_place(0, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 14}))
|
|
|
|
|
call sign_unplace('', {'buffer' : 'Xsign', 'id' : 2})
|
2019-05-15 13:02:10 -07:00
|
|
|
|
call assert_equal(4, sign_place(0, '', 'sign1', 'Xsign',
|
2019-05-06 23:26:09 -07:00
|
|
|
|
\ {'lnum' : 12}))
|
|
|
|
|
|
|
|
|
|
call assert_equal(1, sign_place(0, 'g1', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 11}))
|
2019-05-17 03:20:22 -07:00
|
|
|
|
" Check for the next generated sign id in this group
|
|
|
|
|
call assert_equal(2, sign_place(0, 'g1', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 12}))
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call assert_equal(0, sign_unplace('g1', {'id' : 1}))
|
|
|
|
|
call assert_equal(10,
|
|
|
|
|
\ sign_getplaced('Xsign', {'id' : 1})[0].signs[0].lnum)
|
|
|
|
|
|
|
|
|
|
call delete("Xsign")
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
2019-05-17 03:20:22 -07:00
|
|
|
|
enew | only
|
2019-05-06 23:26:09 -07:00
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for sign priority
|
|
|
|
|
func Test_sign_priority()
|
|
|
|
|
enew | only
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
|
|
|
|
|
|
|
|
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Search'}
|
|
|
|
|
call sign_define("sign1", attr)
|
|
|
|
|
call sign_define("sign2", attr)
|
|
|
|
|
call sign_define("sign3", attr)
|
|
|
|
|
|
|
|
|
|
" Place three signs with different priority in the same line
|
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
|
|
|
|
edit Xsign
|
|
|
|
|
|
|
|
|
|
call sign_place(1, 'g1', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 11, 'priority' : 50})
|
|
|
|
|
call sign_place(2, 'g2', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 11, 'priority' : 100})
|
|
|
|
|
call sign_place(3, '', 'sign3', 'Xsign', {'lnum' : 11})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 11, 'group' : 'g2',
|
|
|
|
|
\ 'priority' : 100},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 11, 'group' : 'g1',
|
|
|
|
|
\ 'priority' : 50},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 11, 'group' : '',
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
2020-02-24 22:35:19 -07:00
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Three signs on different lines with changing priorities
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 11, 'priority' : 50})
|
|
|
|
|
call sign_place(2, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 12, 'priority' : 60})
|
|
|
|
|
call sign_place(3, '', 'sign3', 'Xsign',
|
|
|
|
|
\ {'lnum' : 13, 'priority' : 70})
|
|
|
|
|
call sign_place(2, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 12, 'priority' : 40})
|
|
|
|
|
call sign_place(3, '', 'sign3', 'Xsign',
|
|
|
|
|
\ {'lnum' : 13, 'priority' : 30})
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 11, 'priority' : 50})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 11, 'group' : '',
|
|
|
|
|
\ 'priority' : 50},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 12, 'group' : '',
|
|
|
|
|
\ 'priority' : 40},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 13, 'group' : '',
|
|
|
|
|
\ 'priority' : 30}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Two signs on the same line with changing priorities
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
call sign_place(2, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 30})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
" Change the priority of the last sign to highest
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 40})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 40},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
" Change the priority of the first sign to lowest
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 25})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 25}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 45})
|
|
|
|
|
call sign_place(2, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 55})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 55},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 45}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Three signs on the same line with changing priorities
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 40})
|
|
|
|
|
call sign_place(2, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 30})
|
|
|
|
|
call sign_place(3, '', 'sign3', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 40},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the middle sign to the highest
|
|
|
|
|
call sign_place(2, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 50})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 50},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 40},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the middle sign to the lowest
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 15})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 50},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 15}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the last sign to the highest
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 55})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 55},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 50},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the first sign to the lowest
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 15})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 50},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 15}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Three signs on the same line with changing priorities along with other
|
|
|
|
|
" signs
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 2, 'priority' : 10})
|
|
|
|
|
call sign_place(2, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 30})
|
|
|
|
|
call sign_place(3, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
call sign_place(4, '', 'sign3', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 25})
|
|
|
|
|
call sign_place(5, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 6, 'priority' : 80})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 25},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
|
|
|
|
|
\ 'priority' : 80}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the first sign to lowest
|
|
|
|
|
call sign_place(2, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 15})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 25},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 15},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
|
|
|
|
|
\ 'priority' : 80}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the last sign to highest
|
|
|
|
|
call sign_place(2, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 30})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 25},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
|
|
|
|
|
\ 'priority' : 80}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the middle sign to lowest
|
|
|
|
|
call sign_place(4, '', 'sign3', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 15})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 15},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
|
|
|
|
|
\ 'priority' : 80}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change the priority of the middle sign to highest
|
|
|
|
|
call sign_place(3, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 35})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 2, 'group' : '',
|
|
|
|
|
\ 'priority' : 10},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 35},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 30},
|
|
|
|
|
\ {'id' : 4, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 15},
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign2', 'lnum' : 6, 'group' : '',
|
|
|
|
|
\ 'priority' : 80}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Multiple signs with the same priority on the same line
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
call sign_place(2, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
call sign_place(3, '', 'sign3', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
" Place the last sign again with the same priority
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
" Place the first sign again with the same priority
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
" Place the middle sign again with the same priority
|
|
|
|
|
call sign_place(3, '', 'sign3', 'Xsign',
|
|
|
|
|
\ {'lnum' : 4, 'priority' : 20})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20},
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 4, 'group' : '',
|
|
|
|
|
\ 'priority' : 20}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
2020-02-24 22:30:42 -07:00
|
|
|
|
" Place multiple signs with same id on a line with different priority
|
|
|
|
|
call sign_place(1, '', 'sign1', 'Xsign',
|
|
|
|
|
\ {'lnum' : 5, 'priority' : 20})
|
|
|
|
|
call sign_place(1, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 5, 'priority' : 10})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'lnum' : 5})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign2', 'lnum' : 5, 'group' : '',
|
|
|
|
|
\ 'priority' : 10}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
call sign_place(1, '', 'sign2', 'Xsign',
|
|
|
|
|
\ {'lnum' : 5, 'priority' : 5})
|
|
|
|
|
let s = sign_getplaced('Xsign', {'lnum' : 5})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign2', 'lnum' : 5, 'group' : '',
|
|
|
|
|
\ 'priority' : 5}],
|
|
|
|
|
\ s[0].signs)
|
|
|
|
|
|
2019-05-06 23:26:09 -07:00
|
|
|
|
" Error case
|
2023-04-25 06:32:12 -07:00
|
|
|
|
call assert_fails("call sign_place(1, 'g1', 'sign1', 'Xsign', [])", 'E1206:')
|
2019-05-17 03:20:22 -07:00
|
|
|
|
call assert_fails("call sign_place(1, 'g1', 'sign1', 'Xsign',
|
|
|
|
|
\ {'priority' : []})", 'E745:')
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Tests for the :sign place command with priority
|
|
|
|
|
sign place 5 line=10 name=sign1 priority=30 file=Xsign
|
|
|
|
|
sign place 5 group=g1 line=10 name=sign1 priority=20 file=Xsign
|
|
|
|
|
sign place 5 group=g2 line=10 name=sign1 priority=25 file=Xsign
|
|
|
|
|
let a = execute('sign place group=*')
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 name=sign1 priority=30\n" .
|
|
|
|
|
\ " line=10 id=5 group=g2 name=sign1 priority=25\n" .
|
|
|
|
|
\ " line=10 id=5 group=g1 name=sign1 priority=20\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
" Test for :sign place group={group}
|
|
|
|
|
let a = execute('sign place group=g1')
|
|
|
|
|
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
2019-05-19 23:57:49 -07:00
|
|
|
|
\ " line=10 id=5 group=g1 name=sign1 priority=20\n", a)
|
2019-05-06 23:26:09 -07:00
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
2019-05-17 03:20:22 -07:00
|
|
|
|
enew | only
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call delete("Xsign")
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Tests for memory allocation failures in sign functions
|
|
|
|
|
func Test_sign_memfailures()
|
2021-03-26 20:06:39 -07:00
|
|
|
|
CheckFunction test_alloc_fail
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
|
|
|
|
edit Xsign
|
|
|
|
|
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_getdefined'), 0, 0)
|
|
|
|
|
call assert_fails('call sign_getdefined("sign1")', 'E342:')
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_getplaced'), 0, 0)
|
|
|
|
|
call assert_fails('call sign_getplaced("Xsign")', 'E342:')
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_define_by_name'), 0, 0)
|
|
|
|
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
|
|
|
|
|
call assert_fails('call sign_define("sign1", attr)', 'E342:')
|
|
|
|
|
|
|
|
|
|
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Error'}
|
|
|
|
|
call sign_define("sign1", attr)
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_getlist'), 0, 0)
|
|
|
|
|
call assert_fails('call sign_getdefined("sign1")', 'E342:')
|
|
|
|
|
|
|
|
|
|
call sign_place(3, 'g1', 'sign1', 'Xsign', {'lnum' : 10})
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_getplaced_dict'), 0, 0)
|
|
|
|
|
call assert_fails('call sign_getplaced("Xsign")', 'E342:')
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_getplaced_list'), 0, 0)
|
|
|
|
|
call assert_fails('call sign_getplaced("Xsign")', 'E342:')
|
|
|
|
|
|
|
|
|
|
call test_alloc_fail(GetAllocId('insert_sign'), 0, 0)
|
|
|
|
|
call assert_fails('call sign_place(4, "g1", "sign1", "Xsign", {"lnum" : 11})',
|
|
|
|
|
\ 'E342:')
|
|
|
|
|
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_getinfo'), 0, 0)
|
|
|
|
|
call assert_fails('call getbufinfo()', 'E342:')
|
|
|
|
|
call sign_place(4, 'g1', 'sign1', 'Xsign', {'lnum' : 11})
|
|
|
|
|
call test_alloc_fail(GetAllocId('sign_getinfo'), 0, 0)
|
|
|
|
|
call assert_fails('let binfo=getbufinfo("Xsign")', 'E342:')
|
|
|
|
|
call assert_equal([{'lnum': 11, 'id': 4, 'name': 'sign1',
|
|
|
|
|
\ 'priority': 10, 'group': 'g1'}], binfo[0].signs)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
2019-05-17 03:20:22 -07:00
|
|
|
|
enew | only
|
2019-05-06 23:26:09 -07:00
|
|
|
|
call delete("Xsign")
|
|
|
|
|
endfunc
|
2019-05-19 09:38:25 -07:00
|
|
|
|
|
|
|
|
|
" Test for auto-adjusting the line number of a placed sign.
|
|
|
|
|
func Test_sign_lnum_adjust()
|
|
|
|
|
enew! | only!
|
|
|
|
|
|
|
|
|
|
sign define sign1 text=#> linehl=Comment
|
2019-05-20 11:04:47 -07:00
|
|
|
|
call setline(1, ['A', 'B', 'C', 'D', 'E'])
|
2019-05-19 09:38:25 -07:00
|
|
|
|
exe 'sign place 5 line=3 name=sign1 buffer=' . bufnr('')
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal(3, l[0].signs[0].lnum)
|
|
|
|
|
|
|
|
|
|
" Add some lines before the sign and check the sign line number
|
2019-05-20 11:04:47 -07:00
|
|
|
|
call append(2, ['BA', 'BB', 'BC'])
|
2019-05-19 09:38:25 -07:00
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal(6, l[0].signs[0].lnum)
|
|
|
|
|
|
|
|
|
|
" Delete some lines before the sign and check the sign line number
|
|
|
|
|
call deletebufline('%', 1, 2)
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal(4, l[0].signs[0].lnum)
|
|
|
|
|
|
2019-05-20 11:04:47 -07:00
|
|
|
|
" Insert some lines after the sign and check the sign line number
|
|
|
|
|
call append(5, ['DA', 'DB'])
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal(4, l[0].signs[0].lnum)
|
|
|
|
|
|
|
|
|
|
" Delete some lines after the sign and check the sign line number
|
|
|
|
|
call deletebufline('', 6, 7)
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal(4, l[0].signs[0].lnum)
|
|
|
|
|
|
|
|
|
|
" Break the undo. Otherwise the undo operation below will undo all the
|
|
|
|
|
" changes made by this function.
|
vim-patch:9.0.1683: Updated runtime files (#24638)
This is a collection of various PRs from github that all require a minor
patch number:
1) https://github.com/vim/vim/pull/12612
Do not conflate dictionary key with end of block
2) https://github.com/vim/vim/pull/12729:
When saving and restoring 'undolevels', the constructs `&undolevels` and
`:set undolevels` are problematic.
The construct `&undolevels` reads an unpredictable value; it will be the
local option value (if one has been set), or the global option value
(otherwise), making it unsuitable for saving a value for later
restoration.
Similarly, if a local option value has been set for 'undolevels',
temporarily modifying the option via `:set undolevels` changes the local
value as well as the global value, requiring extra work to restore both
values.
Saving and restoring the option value in one step via the construct
`:let &undolevels = &undolevels` appears to make no changes to the
'undolevels' option, but if a local option has been set to a different
value than the global option, it has the unintended effect of changing
the global 'undolevels' value to the local value.
Update the documentation to explain these issues and recommend explicit
use of global and local option values when saving and restoring. Update
some unit tests to use `g:undolevels`.
3) https://github.com/vim/vim/pull/12702:
Problem: Pip requirements files are not recognized.
Solution: Add a pattern to match pip requirements files.
4) https://github.com/vim/vim/pull/12688:
Add indent file and tests for ABB Rapid
5) https://github.com/vim/vim/pull/12668:
Use Lua 5.1 numeric escapes in tests and add to CI
Only Lua 5.2+ and LuaJIT understand hexadecimal escapes in strings. Lua
5.1 only supports decimal escapes:
> A character in a string can also be specified by its numerical value
> using the escape sequence \ddd, where ddd is a sequence of up to three
> decimal digits. (Note that if a numerical escape is to be followed by a
> digit, it must be expressed using exactly three digits.) Strings in Lua
> can contain any 8-bit value, including embedded zeros, which can be
> specified as '\0'.
To make sure this works with Lua 5.4 and Lua 5.1 change the Vim CI to
run with Lua 5.1 as well as Lua 5.4
6) https://github.com/vim/vim/pull/12631:
Add hurl filetype detection
7) https://github.com/vim/vim/pull/12573:
Problem: Files for haskell persistent library are not recognized
Solution: Add pattern persistentmodels for haskell persistent library
closes: vim/vim#12612
closes: vim/vim#12729
closes: vim/vim#12702
closes: vim/vim#12688
closes: vim/vim#12668
closes: vim/vim#12631
closes: vim/vim#12573
Already ported but wasn't marked: vim-patch:ad34abee2583
https://github.com/vim/vim/commit/6efb1980336ff324e9c57a4e282530b952fca816
Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: lacygoill <lacygoill@lacygoill.me>
Co-authored-by: Michael Henry <drmikehenry@drmikehenry.com>
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
Co-authored-by: KnoP-01 <knosowski@graeffrobotics.de>
Co-authored-by: James McCoy <jamessan@jamessan.com>
Co-authored-by: Jacob Pfeifer <jacob@pfeifer.dev>
Co-authored-by: Borys Lykah <lykahb@fastmail.com>
2023-08-10 02:45:36 -07:00
|
|
|
|
let &g:undolevels=&g:undolevels
|
2019-05-20 11:04:47 -07:00
|
|
|
|
|
2022-12-19 20:03:38 -07:00
|
|
|
|
" Nvim: make sign adjustment when deleting lines match Vim
|
|
|
|
|
set signcolumn=yes:1
|
|
|
|
|
|
2019-05-20 11:04:47 -07:00
|
|
|
|
" Delete the line with the sign
|
|
|
|
|
call deletebufline('', 4)
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
2022-12-19 20:03:38 -07:00
|
|
|
|
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
|
vim-patch:9.0.1683: Updated runtime files (#24638)
This is a collection of various PRs from github that all require a minor
patch number:
1) https://github.com/vim/vim/pull/12612
Do not conflate dictionary key with end of block
2) https://github.com/vim/vim/pull/12729:
When saving and restoring 'undolevels', the constructs `&undolevels` and
`:set undolevels` are problematic.
The construct `&undolevels` reads an unpredictable value; it will be the
local option value (if one has been set), or the global option value
(otherwise), making it unsuitable for saving a value for later
restoration.
Similarly, if a local option value has been set for 'undolevels',
temporarily modifying the option via `:set undolevels` changes the local
value as well as the global value, requiring extra work to restore both
values.
Saving and restoring the option value in one step via the construct
`:let &undolevels = &undolevels` appears to make no changes to the
'undolevels' option, but if a local option has been set to a different
value than the global option, it has the unintended effect of changing
the global 'undolevels' value to the local value.
Update the documentation to explain these issues and recommend explicit
use of global and local option values when saving and restoring. Update
some unit tests to use `g:undolevels`.
3) https://github.com/vim/vim/pull/12702:
Problem: Pip requirements files are not recognized.
Solution: Add a pattern to match pip requirements files.
4) https://github.com/vim/vim/pull/12688:
Add indent file and tests for ABB Rapid
5) https://github.com/vim/vim/pull/12668:
Use Lua 5.1 numeric escapes in tests and add to CI
Only Lua 5.2+ and LuaJIT understand hexadecimal escapes in strings. Lua
5.1 only supports decimal escapes:
> A character in a string can also be specified by its numerical value
> using the escape sequence \ddd, where ddd is a sequence of up to three
> decimal digits. (Note that if a numerical escape is to be followed by a
> digit, it must be expressed using exactly three digits.) Strings in Lua
> can contain any 8-bit value, including embedded zeros, which can be
> specified as '\0'.
To make sure this works with Lua 5.4 and Lua 5.1 change the Vim CI to
run with Lua 5.1 as well as Lua 5.4
6) https://github.com/vim/vim/pull/12631:
Add hurl filetype detection
7) https://github.com/vim/vim/pull/12573:
Problem: Files for haskell persistent library are not recognized
Solution: Add pattern persistentmodels for haskell persistent library
closes: vim/vim#12612
closes: vim/vim#12729
closes: vim/vim#12702
closes: vim/vim#12688
closes: vim/vim#12668
closes: vim/vim#12631
closes: vim/vim#12573
Already ported but wasn't marked: vim-patch:ad34abee2583
https://github.com/vim/vim/commit/6efb1980336ff324e9c57a4e282530b952fca816
Co-authored-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: lacygoill <lacygoill@lacygoill.me>
Co-authored-by: Michael Henry <drmikehenry@drmikehenry.com>
Co-authored-by: ObserverOfTime <chronobserver@disroot.org>
Co-authored-by: KnoP-01 <knosowski@graeffrobotics.de>
Co-authored-by: James McCoy <jamessan@jamessan.com>
Co-authored-by: Jacob Pfeifer <jacob@pfeifer.dev>
Co-authored-by: Borys Lykah <lykahb@fastmail.com>
2023-08-10 02:45:36 -07:00
|
|
|
|
let &g:undolevels=&g:undolevels
|
2022-12-19 20:03:38 -07:00
|
|
|
|
|
|
|
|
|
" 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&
|
2019-05-20 11:04:47 -07:00
|
|
|
|
|
2019-05-19 09:38:25 -07:00
|
|
|
|
sign unplace * group=*
|
|
|
|
|
sign undefine sign1
|
|
|
|
|
enew!
|
|
|
|
|
endfunc
|
|
|
|
|
|
|
|
|
|
" Test for changing the type of a placed sign
|
|
|
|
|
func Test_sign_change_type()
|
|
|
|
|
enew! | only!
|
|
|
|
|
|
|
|
|
|
sign define sign1 text=#> linehl=Comment
|
|
|
|
|
sign define sign2 text=@@ linehl=Comment
|
|
|
|
|
|
|
|
|
|
call setline(1, ['A', 'B', 'C', 'D'])
|
|
|
|
|
exe 'sign place 4 line=3 name=sign1 buffer=' . bufnr('')
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal('sign1', l[0].signs[0].name)
|
|
|
|
|
exe 'sign place 4 name=sign2 buffer=' . bufnr('')
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal('sign2', l[0].signs[0].name)
|
|
|
|
|
call sign_place(4, '', 'sign1', '')
|
|
|
|
|
let l = sign_getplaced(bufnr(''))
|
|
|
|
|
call assert_equal('sign1', l[0].signs[0].name)
|
|
|
|
|
|
|
|
|
|
exe 'sign place 4 group=g1 line=4 name=sign1 buffer=' . bufnr('')
|
|
|
|
|
let l = sign_getplaced(bufnr(''), {'group' : 'g1'})
|
|
|
|
|
call assert_equal('sign1', l[0].signs[0].name)
|
|
|
|
|
exe 'sign place 4 group=g1 name=sign2 buffer=' . bufnr('')
|
|
|
|
|
let l = sign_getplaced(bufnr(''), {'group' : 'g1'})
|
|
|
|
|
call assert_equal('sign2', l[0].signs[0].name)
|
|
|
|
|
call sign_place(4, 'g1', 'sign1', '')
|
|
|
|
|
let l = sign_getplaced(bufnr(''), {'group' : 'g1'})
|
|
|
|
|
call assert_equal('sign1', l[0].signs[0].name)
|
|
|
|
|
|
|
|
|
|
sign unplace * group=*
|
|
|
|
|
sign undefine sign1
|
|
|
|
|
sign undefine sign2
|
|
|
|
|
enew!
|
|
|
|
|
endfunc
|
2019-05-20 04:12:30 -07:00
|
|
|
|
|
|
|
|
|
" Test for the sign_jump() function
|
|
|
|
|
func Test_sign_jump_func()
|
|
|
|
|
enew! | only!
|
|
|
|
|
|
|
|
|
|
sign define sign1 text=#> linehl=Comment
|
|
|
|
|
|
|
|
|
|
edit foo
|
|
|
|
|
set buftype=nofile
|
|
|
|
|
call setline(1, ['A', 'B', 'C', 'D', 'E'])
|
|
|
|
|
call sign_place(5, '', 'sign1', '', {'lnum' : 2})
|
|
|
|
|
call sign_place(5, 'g1', 'sign1', '', {'lnum' : 3})
|
|
|
|
|
call sign_place(6, '', 'sign1', '', {'lnum' : 4})
|
|
|
|
|
call sign_place(6, 'g1', 'sign1', '', {'lnum' : 5})
|
|
|
|
|
split bar
|
|
|
|
|
set buftype=nofile
|
|
|
|
|
call setline(1, ['P', 'Q', 'R', 'S', 'T'])
|
|
|
|
|
call sign_place(5, '', 'sign1', '', {'lnum' : 2})
|
|
|
|
|
call sign_place(5, 'g1', 'sign1', '', {'lnum' : 3})
|
|
|
|
|
call sign_place(6, '', 'sign1', '', {'lnum' : 4})
|
|
|
|
|
call sign_place(6, 'g1', 'sign1', '', {'lnum' : 5})
|
|
|
|
|
|
|
|
|
|
let r = sign_jump(5, '', 'foo')
|
|
|
|
|
call assert_equal(2, r)
|
|
|
|
|
call assert_equal(2, line('.'))
|
2021-10-31 10:31:35 -07:00
|
|
|
|
let r = 6->sign_jump('g1', 'foo')
|
2019-05-20 04:12:30 -07:00
|
|
|
|
call assert_equal(5, r)
|
|
|
|
|
call assert_equal(5, line('.'))
|
|
|
|
|
let r = sign_jump(5, '', 'bar')
|
|
|
|
|
call assert_equal(2, r)
|
|
|
|
|
call assert_equal(2, line('.'))
|
|
|
|
|
|
|
|
|
|
" Error cases
|
|
|
|
|
call assert_fails("call sign_jump(99, '', 'bar')", 'E157:')
|
|
|
|
|
call assert_fails("call sign_jump(0, '', 'foo')", 'E474:')
|
|
|
|
|
call assert_fails("call sign_jump(5, 'g5', 'foo')", 'E157:')
|
|
|
|
|
call assert_fails('call sign_jump([], "", "foo")', 'E745:')
|
|
|
|
|
call assert_fails('call sign_jump(2, [], "foo")', 'E730:')
|
2022-11-04 16:24:06 -07:00
|
|
|
|
call assert_fails('call sign_jump(2, "", {})', 'E731:')
|
2019-05-20 04:12:30 -07:00
|
|
|
|
call assert_fails('call sign_jump(2, "", "baz")', 'E158:')
|
|
|
|
|
|
|
|
|
|
sign unplace * group=*
|
|
|
|
|
sign undefine sign1
|
|
|
|
|
enew! | only!
|
|
|
|
|
endfunc
|
2020-02-24 22:43:06 -07:00
|
|
|
|
|
|
|
|
|
" Test for correct cursor position after the sign column appears or disappears.
|
|
|
|
|
func Test_sign_cursor_position()
|
2022-11-04 17:07:06 -07:00
|
|
|
|
CheckRunVimInTerminal
|
2020-02-24 22:43:06 -07:00
|
|
|
|
|
|
|
|
|
let lines =<< trim END
|
|
|
|
|
call setline(1, [repeat('x', 75), 'mmmm', 'yyyy'])
|
|
|
|
|
call cursor(2,1)
|
|
|
|
|
sign define s1 texthl=Search text==>
|
|
|
|
|
redraw
|
|
|
|
|
sign place 10 line=2 name=s1
|
|
|
|
|
END
|
|
|
|
|
call writefile(lines, 'XtestSigncolumn')
|
|
|
|
|
let buf = RunVimInTerminal('-S XtestSigncolumn', {'rows': 6})
|
2020-02-26 00:07:35 -07:00
|
|
|
|
call VerifyScreenDump(buf, 'Test_sign_cursor_1', {})
|
|
|
|
|
|
|
|
|
|
" Change the sign text
|
|
|
|
|
call term_sendkeys(buf, ":sign define s1 text=-)\<CR>")
|
|
|
|
|
call VerifyScreenDump(buf, 'Test_sign_cursor_2', {})
|
2020-02-24 22:43:06 -07:00
|
|
|
|
|
|
|
|
|
" update cursor position calculation
|
|
|
|
|
call term_sendkeys(buf, "lh")
|
|
|
|
|
call term_sendkeys(buf, ":sign unplace 10\<CR>")
|
2020-02-26 00:07:35 -07:00
|
|
|
|
call VerifyScreenDump(buf, 'Test_sign_cursor_3', {})
|
2020-02-24 22:43:06 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" clean up
|
|
|
|
|
call StopVimInTerminal(buf)
|
|
|
|
|
call delete('XtestSigncolumn')
|
|
|
|
|
endfunc
|
2020-07-10 21:13:49 -07:00
|
|
|
|
|
|
|
|
|
" 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==>
|
2020-07-13 13:13:26 -07:00
|
|
|
|
sign define sign2 text=V
|
2022-12-19 20:03:38 -07:00
|
|
|
|
sign place 10 line=1 name=sign1
|
2020-07-10 21:13:49 -07:00
|
|
|
|
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!
|
2020-07-14 07:12:27 -07:00
|
|
|
|
call assert_equal(" => 01234", s:ScreenLine(1, 1, 9))
|
2020-07-10 21:13:49 -07:00
|
|
|
|
|
|
|
|
|
" 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))
|
|
|
|
|
|
2020-07-13 13:15:04 -07:00
|
|
|
|
" 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))
|
2020-07-13 13:13:26 -07:00
|
|
|
|
" 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))
|
2020-07-13 13:15:04 -07:00
|
|
|
|
|
|
|
|
|
sign unplace * group=*
|
2020-07-10 21:13:49 -07:00
|
|
|
|
sign undefine sign1
|
|
|
|
|
set signcolumn&
|
|
|
|
|
set number&
|
|
|
|
|
enew! | close
|
|
|
|
|
endfunc
|
2021-03-05 17:50:07 -07:00
|
|
|
|
|
|
|
|
|
" Test for managing multiple signs using the sign functions
|
|
|
|
|
func Test_sign_funcs_multi()
|
|
|
|
|
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
|
|
|
|
edit Xsign
|
|
|
|
|
let bnum = bufnr('')
|
|
|
|
|
|
|
|
|
|
" Define multiple signs at once
|
|
|
|
|
call assert_equal([0, 0, 0, 0], sign_define([
|
|
|
|
|
\ {'name' : 'sign1', 'text' : '=>', 'linehl' : 'Search',
|
|
|
|
|
\ 'texthl' : 'Search'},
|
|
|
|
|
\ {'name' : 'sign2', 'text' : '=>', 'linehl' : 'Search',
|
|
|
|
|
\ 'texthl' : 'Search'},
|
|
|
|
|
\ {'name' : 'sign3', 'text' : '=>', 'linehl' : 'Search',
|
|
|
|
|
\ 'texthl' : 'Search'},
|
|
|
|
|
\ {'name' : 'sign4', 'text' : '=>', 'linehl' : 'Search',
|
|
|
|
|
\ 'texthl' : 'Search'}]))
|
|
|
|
|
|
|
|
|
|
" Negative cases for sign_define()
|
|
|
|
|
call assert_equal([], sign_define([]))
|
|
|
|
|
call assert_equal([-1], sign_define([{}]))
|
|
|
|
|
call assert_fails('call sign_define([6])', 'E715:')
|
|
|
|
|
call assert_fails('call sign_define(["abc"])', 'E715:')
|
|
|
|
|
call assert_fails('call sign_define([[]])', 'E715:')
|
|
|
|
|
|
|
|
|
|
" Place multiple signs at once with specific sign identifier
|
|
|
|
|
let l = sign_placelist([{'id' : 1, 'group' : 'g1', 'name' : 'sign1',
|
|
|
|
|
\ 'buffer' : 'Xsign', 'lnum' : 11, 'priority' : 50},
|
|
|
|
|
\ {'id' : 2, 'group' : 'g2', 'name' : 'sign2',
|
|
|
|
|
\ 'buffer' : 'Xsign', 'lnum' : 11, 'priority' : 100},
|
|
|
|
|
\ {'id' : 3, 'group' : '', 'name' : 'sign3',
|
|
|
|
|
\ 'buffer' : 'Xsign', 'lnum' : 11}])
|
|
|
|
|
call assert_equal([1, 2, 3], l)
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 2, 'name' : 'sign2', 'lnum' : 11,
|
|
|
|
|
\ 'group' : 'g2', 'priority' : 100},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 11,
|
|
|
|
|
\ 'group' : 'g1', 'priority' : 50},
|
|
|
|
|
\ {'id' : 3, 'name' : 'sign3', 'lnum' : 11,
|
|
|
|
|
\ 'group' : '', 'priority' : 10}], s[0].signs)
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
|
|
|
|
|
" Place multiple signs at once with auto-generated sign identifier
|
|
|
|
|
call assert_equal([1, 1, 5], sign_placelist([
|
|
|
|
|
\ {'group' : 'g1', 'name' : 'sign1',
|
|
|
|
|
\ 'buffer' : 'Xsign', 'lnum' : 11},
|
|
|
|
|
\ {'group' : 'g2', 'name' : 'sign2',
|
|
|
|
|
\ 'buffer' : 'Xsign', 'lnum' : 11},
|
|
|
|
|
\ {'group' : '', 'name' : 'sign3',
|
|
|
|
|
\ 'buffer' : 'Xsign', 'lnum' : 11}]))
|
|
|
|
|
let s = sign_getplaced('Xsign', {'group' : '*'})
|
|
|
|
|
call assert_equal([
|
|
|
|
|
\ {'id' : 5, 'name' : 'sign3', 'lnum' : 11,
|
|
|
|
|
\ 'group' : '', 'priority' : 10},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign2', 'lnum' : 11,
|
|
|
|
|
\ 'group' : 'g2', 'priority' : 10},
|
|
|
|
|
\ {'id' : 1, 'name' : 'sign1', 'lnum' : 11,
|
|
|
|
|
\ 'group' : 'g1', 'priority' : 10}], s[0].signs)
|
|
|
|
|
|
|
|
|
|
" Change an existing sign without specifying the group
|
2021-10-31 10:31:35 -07:00
|
|
|
|
call assert_equal([5], [{'id' : 5, 'name' : 'sign1', 'buffer' : 'Xsign'}]->sign_placelist())
|
2021-03-05 17:50:07 -07:00
|
|
|
|
let s = sign_getplaced('Xsign', {'id' : 5, 'group' : ''})
|
|
|
|
|
call assert_equal([{'id' : 5, 'name' : 'sign1', 'lnum' : 11,
|
|
|
|
|
\ 'group' : '', 'priority' : 10}], s[0].signs)
|
|
|
|
|
|
2021-03-11 17:07:49 -07:00
|
|
|
|
" Place a sign using '.' as the line number
|
|
|
|
|
call cursor(23, 1)
|
|
|
|
|
call assert_equal([7], sign_placelist([
|
|
|
|
|
\ {'id' : 7, 'name' : 'sign1', 'buffer' : '%', 'lnum' : '.'}]))
|
|
|
|
|
let s = sign_getplaced('%', {'lnum' : '.'})
|
|
|
|
|
call assert_equal([{'id' : 7, 'name' : 'sign1', 'lnum' : 23,
|
|
|
|
|
\ 'group' : '', 'priority' : 10}], s[0].signs)
|
|
|
|
|
|
2021-03-05 17:50:07 -07:00
|
|
|
|
" Place sign without a sign name
|
|
|
|
|
call assert_equal([-1], sign_placelist([{'id' : 10, 'buffer' : 'Xsign',
|
|
|
|
|
\ 'lnum' : 12, 'group' : ''}]))
|
|
|
|
|
|
|
|
|
|
" Place sign without a buffer
|
|
|
|
|
call assert_equal([-1], sign_placelist([{'id' : 10, 'name' : 'sign1',
|
|
|
|
|
\ 'lnum' : 12, 'group' : ''}]))
|
|
|
|
|
|
|
|
|
|
" Invalid arguments
|
|
|
|
|
call assert_equal([], sign_placelist([]))
|
|
|
|
|
call assert_fails('call sign_placelist({})', "E714:")
|
|
|
|
|
call assert_fails('call sign_placelist([[]])', "E715:")
|
|
|
|
|
call assert_fails('call sign_placelist(["abc"])', "E715:")
|
|
|
|
|
call assert_fails('call sign_placelist([100])', "E715:")
|
|
|
|
|
|
|
|
|
|
" Unplace multiple signs
|
|
|
|
|
call assert_equal([0, 0, 0], sign_unplacelist([{'id' : 5},
|
|
|
|
|
\ {'id' : 1, 'group' : 'g1'}, {'id' : 1, 'group' : 'g2'}]))
|
|
|
|
|
|
|
|
|
|
" Invalid arguments
|
2021-10-31 10:31:35 -07:00
|
|
|
|
call assert_equal([], []->sign_unplacelist())
|
2021-03-05 17:50:07 -07:00
|
|
|
|
call assert_fails('call sign_unplacelist({})', "E714:")
|
|
|
|
|
call assert_fails('call sign_unplacelist([[]])', "E715:")
|
|
|
|
|
call assert_fails('call sign_unplacelist(["abc"])', "E715:")
|
|
|
|
|
call assert_fails('call sign_unplacelist([100])', "E715:")
|
|
|
|
|
call assert_fails("call sign_unplacelist([{'id' : -1}])", 'E474')
|
|
|
|
|
|
|
|
|
|
call assert_equal([0, 0, 0, 0],
|
|
|
|
|
\ sign_undefine(['sign1', 'sign2', 'sign3', 'sign4']))
|
|
|
|
|
call assert_equal([], sign_getdefined())
|
|
|
|
|
|
|
|
|
|
" Invalid arguments
|
|
|
|
|
call assert_equal([], sign_undefine([]))
|
|
|
|
|
call assert_fails('call sign_undefine([[]])', 'E730:')
|
|
|
|
|
call assert_fails('call sign_undefine([{}])', 'E731:')
|
|
|
|
|
call assert_fails('call sign_undefine(["1abc2"])', 'E155:')
|
|
|
|
|
|
|
|
|
|
call sign_unplace('*')
|
|
|
|
|
call sign_undefine()
|
|
|
|
|
enew!
|
|
|
|
|
call delete("Xsign")
|
|
|
|
|
endfunc
|