changeset 24204:ec71c859e94c v8.2.2643

patch 8.2.2643: various code not covered by tests Commit: https://github.com/vim/vim/commit/1f448d906b3c516e5864dc5bae3ddbf3664ee649 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 22 19:37:06 2021 +0100 patch 8.2.2643: various code not covered by tests Problem: Various code not covered by tests. Solution: Add a few more test. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/7995)
author Bram Moolenaar <Bram@vim.org>
date Mon, 22 Mar 2021 19:45:04 +0100
parents b78600b6b609
children f8f6ec7d7652
files src/testdir/test_edit.vim src/testdir/test_functions.vim src/testdir/test_mapping.vim src/testdir/test_termcodes.vim src/testdir/test_undo.vim src/version.c
diffstat 6 files changed, 83 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/testdir/test_edit.vim
+++ b/src/testdir/test_edit.vim
@@ -411,6 +411,33 @@ func Test_edit_13()
   bwipe!
 endfunc
 
+" Test for autoindent removing indent when insert mode is stopped.  Some parts
+" of the code is exercised only when interactive mode is used. So use Vim in a
+" terminal.
+func Test_autoindent_remove_indent()
+  CheckRunVimInTerminal
+  let buf = RunVimInTerminal('-N Xfile', {'rows': 6, 'cols' : 20})
+  call TermWait(buf)
+  call term_sendkeys(buf, ":set autoindent\n")
+  " leaving insert mode in a new line with indent added by autoindent, should
+  " remove the indent.
+  call term_sendkeys(buf, "i\<Tab>foo\<CR>\<Esc>")
+  " Need to delay for sometime, otherwise the code in getchar.c will not be
+  " exercised.
+  call TermWait(buf, 50)
+  " when a line is wrapped and the cursor is at the start of the second line,
+  " leaving insert mode, should move the cursor back to the first line.
+  call term_sendkeys(buf, "o" .. repeat('x', 20) .. "\<Esc>")
+  " Need to delay for sometime, otherwise the code in getchar.c will not be
+  " exercised.
+  call TermWait(buf, 50)
+  call term_sendkeys(buf, ":w\n")
+  call TermWait(buf)
+  call StopVimInTerminal(buf)
+  call assert_equal(["\tfoo", '', repeat('x', 20)], readfile('Xfile'))
+  call delete('Xfile')
+endfunc
+
 func Test_edit_CR()
   " Test for <CR> in insert mode
   " basically only in quickfix mode ist tested, the rest
--- a/src/testdir/test_functions.vim
+++ b/src/testdir/test_functions.vim
@@ -1431,7 +1431,7 @@ func Test_input_func()
   call assert_equal('item1 item2 item3', c)
 
   " Test for using special characters as default input
-  call feedkeys(":let c = input('name? ', \"x\<BS>y\")\<CR>\<CR>", 'xt')
+  call feedkeys(":let c = input('name? ', \"x\\<BS>y\")\<CR>\<CR>", 'xt')
   call assert_equal('y', c)
 
   " Test for using <CR> as default input
--- a/src/testdir/test_mapping.vim
+++ b/src/testdir/test_mapping.vim
@@ -1389,4 +1389,14 @@ func Test_map_cmdkey_redo()
   ounmap i-
 endfunc
 
+" Test for using <script> with a map to remap characters in rhs
+func Test_script_local_remap()
+  new
+  inoremap <buffer> <SID>xyz mno
+  inoremap <buffer> <script> abc st<SID>xyzre
+  normal iabc
+  call assert_equal('stmnore', getline(1))
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_termcodes.vim
+++ b/src/testdir/test_termcodes.vim
@@ -2314,4 +2314,38 @@ func Test_Keycode_Translation()
   endfor
 endfunc
 
+" Test for terminal keycodes that doesn't have termcap entries
+func Test_special_term_keycodes()
+  new
+  " Test for <xHome>, <S-xHome> and <C-xHome>
+  " send <K_SPECIAL> <KS_EXTRA> keycode
+  call feedkeys("i\<C-K>\x80\xfd\x3f\n", 'xt')
+  " send <K_SPECIAL> <KS_MODIFIER> bitmap <K_SPECIAL> <KS_EXTRA> keycode
+  call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3f\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3f\n", 'xt')
+  " Test for <xEnd>, <S-xEnd> and <C-xEnd>
+  call feedkeys("i\<C-K>\x80\xfd\x3d\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3d\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3d\n", 'xt')
+  " Test for <zHome>, <S-zHome> and <C-zHome>
+  call feedkeys("i\<C-K>\x80\xfd\x40\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x40\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x40\n", 'xt')
+  " Test for <zEnd>, <S-zEnd> and <C-zEnd>
+  call feedkeys("i\<C-K>\x80\xfd\x3e\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfc\x2\x80\xfd\x3e\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfc\x4\x80\xfd\x3e\n", 'xt')
+  " Test for <xUp>, <xDown>, <xLeft> and <xRight>
+  call feedkeys("i\<C-K>\x80\xfd\x41\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfd\x42\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfd\x43\n", 'xt')
+  call feedkeys("i\<C-K>\x80\xfd\x44\n", 'xt')
+  call assert_equal(['<Home>', '<S-Home>', '<C-Home>',
+        \ '<End>', '<S-End>', '<C-End>',
+        \ '<Home>', '<S-Home>', '<C-Home>',
+        \ '<End>', '<S-End>', '<C-End>',
+        \ '<Up>', '<Down>', '<Left>', '<Right>', ''], getline(1, '$'))
+  bw!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/testdir/test_undo.vim
+++ b/src/testdir/test_undo.vim
@@ -747,4 +747,13 @@ func Test_redo_repeat_numbered_register(
   bwipe!
 endfunc
 
+" Test for redo in insert mode using CTRL-O with multibyte characters
+func Test_redo_multibyte_in_insert_mode()
+  new
+  call feedkeys("a\<C-K>ft", 'xt')
+  call feedkeys("uiHe\<C-O>.llo", 'xt')
+  call assert_equal("He\ufb05llo", getline(1))
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -751,6 +751,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2643,
+/**/
     2642,
 /**/
     2641,