To: vim_dev@googlegroups.com Subject: Patch 8.1.1899 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.1.1899 Problem: sign_place() does not work as documented. Solution: Make it accept line numbers like line(). (Yegappan Lakshmanan, closes #4848) Files: src/sign.c, src/testdir/test_signs.vim *** ../vim-8.1.1898/src/sign.c 2019-08-18 22:25:54.665447991 +0200 --- src/sign.c 2019-08-21 13:16:27.044013913 +0200 *************** *** 2430,2438 **** di = dict_find(dict, (char_u *)"lnum", -1); if (di != NULL) { ! lnum = (int)tv_get_number_chk(&di->di_tv, ¬anum); ! if (notanum) goto cleanup; } // sign priority --- 2430,2441 ---- di = dict_find(dict, (char_u *)"lnum", -1); if (di != NULL) { ! lnum = tv_get_lnum(&di->di_tv); ! if (lnum <= 0) ! { ! emsg(_(e_invarg)); goto cleanup; + } } // sign priority *** ../vim-8.1.1898/src/testdir/test_signs.vim 2019-07-18 12:48:11.951123888 +0200 --- src/testdir/test_signs.vim 2019-08-21 13:16:27.044013913 +0200 *************** *** 457,467 **** call assert_fails('call sign_place(5, "", "sign1", [], {"lnum" : 10})', \ 'E158:') call assert_fails('call sign_place(21, "", "sign1", "Xsign", ! \ {"lnum" : -1})', 'E885:') call assert_fails('call sign_place(22, "", "sign1", "Xsign", ! \ {"lnum" : 0})', 'E885:') call assert_fails('call sign_place(22, "", "sign1", "Xsign", ! \ {"lnum" : []})', 'E745:') call assert_equal(-1, sign_place(1, "*", "sign1", "Xsign", {"lnum" : 10})) " Tests for sign_getplaced() --- 457,467 ---- call assert_fails('call sign_place(5, "", "sign1", [], {"lnum" : 10})', \ 'E158:') call assert_fails('call sign_place(21, "", "sign1", "Xsign", ! \ {"lnum" : -1})', 'E474:') call assert_fails('call sign_place(22, "", "sign1", "Xsign", ! \ {"lnum" : 0})', 'E474:') call assert_fails('call sign_place(22, "", "sign1", "Xsign", ! \ {"lnum" : []})', 'E474:') call assert_equal(-1, sign_place(1, "*", "sign1", "Xsign", {"lnum" : 10})) " Tests for sign_getplaced() *************** *** 517,522 **** --- 517,532 ---- call assert_fails('call sign_undefine("none")', 'E155:') call assert_fails('call sign_undefine({})', 'E731:') + " Test for using '.' as the line number for sign_place() + call sign_define("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})) + call delete("Xsign") call sign_unplace('*') call sign_undefine() *************** *** 1928,1933 **** --- 1938,1951 ---- 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' : ''}])) *** ../vim-8.1.1898/src/version.c 2019-08-21 13:06:50.915041078 +0200 --- src/version.c 2019-08-21 13:17:33.019685379 +0200 *************** *** 767,768 **** --- 767,770 ---- { /* Add new patch number below this line */ + /**/ + 1899, /**/ -- From "know your smileys": :-F Bucktoothed vampire with one tooth missing /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///