mirror of
https://github.com/neovim/neovim.git
synced 2024-12-29 14:41:06 -07:00
vim-patch:8.1.1899: sign_place() does not work as documented
Problem: sign_place() does not work as documented. Solution: Make accept line numbers like line(). (Yegappan Lakshmanan, closes #4848)
This commit is contained in:
parent
5257bce979
commit
d82b599ea5
@ -2033,8 +2033,9 @@ int sign_place_from_dict(
|
||||
// line number of the sign
|
||||
di = tv_dict_find(dict, "lnum", -1);
|
||||
if (di != NULL) {
|
||||
lnum = (int)tv_get_number_chk(&di->di_tv, ¬anum);
|
||||
if (notanum) {
|
||||
lnum = tv_get_lnum(&di->di_tv);
|
||||
if (lnum <= 0) {
|
||||
EMSG(_(e_invarg));
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
@ -460,11 +460,11 @@ func Test_sign_funcs()
|
||||
call assert_fails('call sign_place(5, "", "sign1", [], {"lnum" : 10})',
|
||||
\ 'E158:')
|
||||
call assert_fails('call sign_place(21, "", "sign1", "Xsign",
|
||||
\ {"lnum" : -1})', 'E885:')
|
||||
\ {"lnum" : -1})', 'E474:')
|
||||
call assert_fails('call sign_place(22, "", "sign1", "Xsign",
|
||||
\ {"lnum" : 0})', 'E885:')
|
||||
\ {"lnum" : 0})', 'E474:')
|
||||
call assert_fails('call sign_place(22, "", "sign1", "Xsign",
|
||||
\ {"lnum" : []})', 'E745:')
|
||||
\ {"lnum" : []})', 'E474:')
|
||||
call assert_equal(-1, sign_place(1, "*", "sign1", "Xsign", {"lnum" : 10}))
|
||||
|
||||
" Tests for sign_getplaced()
|
||||
@ -1946,6 +1946,14 @@ func Test_sign_funcs_multi()
|
||||
call assert_equal([{'id' : 5, 'name' : 'sign1', 'lnum' : 11,
|
||||
\ 'group' : '', 'priority' : 10}], s[0].signs)
|
||||
|
||||
" 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)
|
||||
|
||||
" Place sign without a sign name
|
||||
call assert_equal([-1], sign_placelist([{'id' : 10, 'buffer' : 'Xsign',
|
||||
\ 'lnum' : 12, 'group' : ''}]))
|
||||
|
Loading…
Reference in New Issue
Block a user