To: vim_dev@googlegroups.com Subject: Patch 7.4.1093 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 7.4.1093 Problem: Typo in test goes unnoticed. Solution: Fix the typo. Give error for wrong arguments to cursor(). (partly by Hirohito Higashi) Add a test for cursor(). Files: src/testdir/test_searchpos.vim, src/testdir/test_cursor_func.vim, src/eval.c, src/testdir/test_alot.vim *** ../vim-7.4.1092/src/testdir/test_searchpos.vim 2015-12-28 19:19:41.546241839 +0100 --- src/testdir/test_searchpos.vim 2016-01-15 15:33:16.266106813 +0100 *************** *** 15,24 **** call assert_equal([1, 3, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')) " Now with \zs, first match is in column 0, "a" is matched. ! call cursor(1. 3) call assert_equal([2, 4, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW')) " With z flag start at cursor column, don't see the "a". ! call cursor(1. 3) call assert_equal([2, 4, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz')) set cpo+=c --- 15,24 ---- call assert_equal([1, 3, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}xyz', 'pcW')) " Now with \zs, first match is in column 0, "a" is matched. ! call cursor(1, 3) call assert_equal([2, 4, 2], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcW')) " With z flag start at cursor column, don't see the "a". ! call cursor(1, 3) call assert_equal([2, 4, 1], searchpos('\%(\([a-z]\)\|\_.\)\{-}\zsxyz', 'pcWz')) set cpo+=c *** ../vim-7.4.1092/src/testdir/test_cursor_func.vim 2016-01-15 15:36:45.183862785 +0100 --- src/testdir/test_cursor_func.vim 2016-01-15 15:13:30.170843712 +0100 *************** *** 0 **** --- 1,35 ---- + " Tests for cursor(). + + func Test_wrong_arguments() + try + call cursor(1. 3) + " not reached + call assert_false(1) + catch + call assert_exception('E474:') + endtry + endfunc + + func Test_move_cursor() + new + call setline(1, ['aaa', 'bbb', 'ccc', 'ddd']) + + call cursor([1, 1, 0, 1]) + call assert_equal([1, 1, 0, 1], getcurpos()[1:]) + call cursor([4, 3, 0, 3]) + call assert_equal([4, 3, 0, 3], getcurpos()[1:]) + + call cursor(2, 2) + call assert_equal([2, 2, 0, 3], getcurpos()[1:]) + " line number zero keeps the line number + call cursor(0, 1) + call assert_equal([2, 1, 0, 3], getcurpos()[1:]) + " col number zero keeps the column + call cursor(3, 0) + call assert_equal([3, 1, 0, 3], getcurpos()[1:]) + " below last line goes to last line + call cursor(9, 1) + call assert_equal([4, 1, 0, 3], getcurpos()[1:]) + + quit! + endfunc *** ../vim-7.4.1092/src/eval.c 2016-01-15 15:29:04.916806048 +0100 --- src/eval.c 2016-01-15 14:39:41.292690326 +0100 *************** *** 10243,10249 **** } /* ! * "cursor(lnum, col)" function * * Moves the cursor to the specified line and column. * Returns 0 when the position could be set, -1 otherwise. --- 10243,10250 ---- } /* ! * "cursor(lnum, col)" function, or ! * "cursor(list)" * * Moves the cursor to the specified line and column. * Returns 0 when the position could be set, -1 otherwise. *************** *** 10266,10272 **** --- 10267,10276 ---- colnr_T curswant = -1; if (list2fpos(argvars, &pos, NULL, &curswant) == FAIL) + { + EMSG(_(e_invarg)); return; + } line = pos.lnum; col = pos.col; #ifdef FEAT_VIRTUALEDIT *** ../vim-7.4.1092/src/testdir/test_alot.vim 2016-01-04 22:05:08.854156424 +0100 --- src/testdir/test_alot.vim 2016-01-15 14:09:02.740536395 +0100 *************** *** 2,7 **** --- 2,8 ---- " This makes testing go faster, since Vim doesn't need to restart. source test_backspace_opt.vim + source test_cursor_func.vim source test_lispwords.vim source test_menu.vim source test_searchpos.vim *** ../vim-7.4.1092/src/version.c 2016-01-15 15:29:04.920806005 +0100 --- src/version.c 2016-01-15 15:34:05.597576971 +0100 *************** *** 743,744 **** --- 743,746 ---- { /* Add new patch number below this line */ + /**/ + 1093, /**/ -- DENNIS: You can't expect to wield supreme executive power just 'cause some watery tart threw a sword at you! "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD /// 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 ///