changeset 13890:3aac8d62351c v8.0.1816

patch 8.0.1816: no test for setcmdpos() commit https://github.com/vim/vim/commit/ff3be4fe1e2e723de48b826cb992c798e296c41e Author: Bram Moolenaar <Bram@vim.org> Date: Sat May 12 13:18:46 2018 +0200 patch 8.0.1816: no test for setcmdpos() Problem: No test for setcmdpos(). Solution: Add a test. (Dominique Pelle, closes https://github.com/vim/vim/issues/2901)
author Christian Brabandt <cb@256bit.org>
date Sat, 12 May 2018 13:30:06 +0200
parents c50f74ab8035
children 6418f95b0eb1
files src/testdir/test_cmdline.vim src/version.c
diffstat 2 files changed, 23 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_cmdline.vim
+++ b/src/testdir/test_cmdline.vim
@@ -470,4 +470,25 @@ func Test_verbosefile()
   call delete('Xlog')
 endfunc
 
+func Test_setcmdpos()
+  func InsertTextAtPos(text, pos)
+    call assert_equal(0, setcmdpos(a:pos))
+    return a:text
+  endfunc
+
+  " setcmdpos() with position in the middle of the command line.
+  call feedkeys(":\"12\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt')
+  call assert_equal('"1ab2', @:)
+
+  call feedkeys(":\"12\<C-R>\<C-R>=InsertTextAtPos('a', 3)\<CR>b\<CR>", 'xt')
+  call assert_equal('"1b2a', @:)
+
+  " setcmdpos() with position beyond the end of the command line.
+  call feedkeys(":\"12\<C-B>\<C-R>=InsertTextAtPos('a', 10)\<CR>b\<CR>", 'xt')
+  call assert_equal('"12ab', @:)
+
+  " setcmdpos() returns 1 when not editing the command line.
+  call assert_equal(1, setcmdpos(3))
+endfunc
+
 set cpo&
--- a/src/version.c
+++ b/src/version.c
@@ -762,6 +762,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1816,
+/**/
     1815,
 /**/
     1814,