mirror of
https://github.com/neovim/neovim.git
synced 2025-11-03 09:14:24 +00:00
vim-patch:9.1.0538: not possible to assign priority when defining a sign (#29592)
Problem: not possible to assign priority when defining a sign
(Mathias Fußenegger)
Solution: Add the priority argument for the :sign-define ex command and
the sign_define() function (LemonBoy)
Use the specified value instead of the default one (SIGN_DEF_PRIO) when
no priority is explicitly specified in sign_place or :sign place.
fixes: vim/vim#8334
closes: vim/vim#15124
b975ddfdf9
Co-authored-by: LemonBoy <thatlemon@gmail.com>
This commit is contained in:
@@ -2920,11 +2920,12 @@ describe('builtin popupmenu', function()
|
||||
feed('<C-U>sign define <Tab>')
|
||||
screen:expect([[
|
||||
|
|
||||
{1:~ }|*2
|
||||
{1:~ }|
|
||||
{1:~ }{s: culhl= }{1: }|
|
||||
{1:~ }{n: icon= }{1: }|
|
||||
{1:~ }{n: linehl= }{1: }|
|
||||
{1:~ }{n: numhl= }{1: }|
|
||||
{1:~ }{n: priority= }{1: }|
|
||||
{1:~ }{n: text= }{1: }|
|
||||
{1:~ }{n: texthl= }{1: }|
|
||||
:sign define culhl=^ |
|
||||
@@ -2933,11 +2934,12 @@ describe('builtin popupmenu', function()
|
||||
feed('<Space><Tab>')
|
||||
screen:expect([[
|
||||
|
|
||||
{1:~ }|*2
|
||||
{1:~ }|
|
||||
{1:~ }{s: culhl= }{1: }|
|
||||
{1:~ }{n: icon= }{1: }|
|
||||
{1:~ }{n: linehl= }{1: }|
|
||||
{1:~ }{n: numhl= }{1: }|
|
||||
{1:~ }{n: priority= }{1: }|
|
||||
{1:~ }{n: text= }{1: }|
|
||||
{1:~ }{n: texthl= }{1: }|
|
||||
:sign define culhl= culhl=^ |
|
||||
|
||||
@@ -246,7 +246,7 @@ func Test_sign_completion()
|
||||
call assert_equal('"sign define jump list place undefine unplace', @:)
|
||||
|
||||
call feedkeys(":sign define Sign \<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
call assert_equal('"sign define Sign culhl= icon= linehl= numhl= text= texthl=', @:)
|
||||
call assert_equal('"sign define Sign culhl= icon= linehl= numhl= priority= text= texthl=', @:)
|
||||
|
||||
for hl in ['culhl', 'linehl', 'numhl', 'texthl']
|
||||
call feedkeys(":sign define Sign "..hl.."=Spell\<C-A>\<C-B>\"\<CR>", 'tx')
|
||||
@@ -1240,9 +1240,28 @@ func Test_sign_priority()
|
||||
call sign_define("sign1", attr)
|
||||
call sign_define("sign2", attr)
|
||||
call sign_define("sign3", attr)
|
||||
let attr = {'text' : '=>', 'linehl' : 'Search', 'texthl' : 'Search', 'priority': 60}
|
||||
call sign_define("sign4", attr)
|
||||
|
||||
" Test for :sign list
|
||||
let a = execute('sign list')
|
||||
call assert_equal("\nsign sign1 text==> linehl=Search texthl=Search\n" .
|
||||
\ "sign sign2 text==> linehl=Search texthl=Search\n" .
|
||||
\ "sign sign3 text==> linehl=Search texthl=Search\n" .
|
||||
\ "sign sign4 text==> priority=60 linehl=Search texthl=Search", a)
|
||||
|
||||
" Test for sign_getdefined()
|
||||
let s = sign_getdefined()
|
||||
call assert_equal([
|
||||
\ {'name': 'sign1', 'texthl': 'Search', 'linehl': 'Search', 'text': '=>'},
|
||||
\ {'name': 'sign2', 'texthl': 'Search', 'linehl': 'Search', 'text': '=>'},
|
||||
\ {'name': 'sign3', 'texthl': 'Search', 'linehl': 'Search', 'text': '=>'},
|
||||
\ {'name': 'sign4', 'priority': 60, 'texthl': 'Search', 'linehl': 'Search',
|
||||
\ 'text': '=>'}],
|
||||
\ s)
|
||||
|
||||
" Place three signs with different priority in the same line
|
||||
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
||||
call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
|
||||
edit Xsign
|
||||
|
||||
call sign_place(1, 'g1', 'sign1', 'Xsign',
|
||||
@@ -1577,16 +1596,34 @@ func Test_sign_priority()
|
||||
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
||||
\ " line=10 id=5 group=g1 name=sign1 priority=20\n", a)
|
||||
|
||||
call sign_unplace('*')
|
||||
|
||||
" Test for sign with default priority.
|
||||
call sign_place(1, 'g1', 'sign4', 'Xsign', {'lnum' : 3})
|
||||
sign place 2 line=5 name=sign4 group=g1 file=Xsign
|
||||
|
||||
let s = sign_getplaced('Xsign', {'group' : '*'})
|
||||
call assert_equal([
|
||||
\ {'id' : 1, 'name' : 'sign4', 'lnum' : 3, 'group' : 'g1',
|
||||
\ 'priority' : 60},
|
||||
\ {'id' : 2, 'name' : 'sign4', 'lnum' : 5, 'group' : 'g1',
|
||||
\ 'priority' : 60}],
|
||||
\ s[0].signs)
|
||||
|
||||
let a = execute('sign place group=g1')
|
||||
call assert_equal("\n--- Signs ---\nSigns for Xsign:\n" .
|
||||
\ " line=3 id=1 group=g1 name=sign4 priority=60\n" .
|
||||
\ " line=5 id=2 group=g1 name=sign4 priority=60\n", a)
|
||||
|
||||
call sign_unplace('*')
|
||||
call sign_undefine()
|
||||
enew | only
|
||||
call delete("Xsign")
|
||||
endfunc
|
||||
|
||||
" Tests for memory allocation failures in sign functions
|
||||
func Test_sign_memfailures()
|
||||
CheckFunction test_alloc_fail
|
||||
call writefile(repeat(["Sun is shining"], 30), "Xsign")
|
||||
call writefile(repeat(["Sun is shining"], 30), "Xsign", 'D')
|
||||
edit Xsign
|
||||
|
||||
call test_alloc_fail(GetAllocId('sign_getdefined'), 0, 0)
|
||||
@@ -1623,7 +1660,6 @@ func Test_sign_memfailures()
|
||||
call sign_unplace('*')
|
||||
call sign_undefine()
|
||||
enew | only
|
||||
call delete("Xsign")
|
||||
endfunc
|
||||
|
||||
" Test for auto-adjusting the line number of a placed sign.
|
||||
|
||||
Reference in New Issue
Block a user