aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2022-07-09 16:28:14 +0800
committerzeertzjq <zeertzjq@outlook.com>2022-07-09 16:31:19 +0800
commit12f0ef669d8f826afbfcecf25b492ffad62d19e7 (patch)
tree7a38eddeac8a978d43d573fbbf7e9750827f5fad
parent798acbca1bfe54d7050cad0189c93bfce5ec6965 (diff)
downloadrneovim-12f0ef669d8f826afbfcecf25b492ffad62d19e7.tar.gz
rneovim-12f0ef669d8f826afbfcecf25b492ffad62d19e7.tar.bz2
rneovim-12f0ef669d8f826afbfcecf25b492ffad62d19e7.zip
vim-patch:8.2.0332: some code in ex_getln.c not covered by tests
Problem: Some code in ex_getln.c not covered by tests. Solution: Add a few more tests. (Yegappan Lakshmanan, closes vim/vim#5710) https://github.com/vim/vim/commit/d30ae2fc4acb3861fc7dc9618c1f90eee997d412
-rw-r--r--src/nvim/testdir/test_arabic.vim23
-rw-r--r--src/nvim/testdir/test_cmdline.vim51
2 files changed, 69 insertions, 5 deletions
diff --git a/src/nvim/testdir/test_arabic.vim b/src/nvim/testdir/test_arabic.vim
index b679ec4520..272937387d 100644
--- a/src/nvim/testdir/test_arabic.vim
+++ b/src/nvim/testdir/test_arabic.vim
@@ -562,3 +562,26 @@ func Test_shape_combination_isolated()
set arabicshape&
bwipe!
endfunc
+
+" Test for entering arabic character in a search command
+func Test_arabic_chars_in_search_cmd()
+ new
+ set arabic
+ call feedkeys("i\nsghl!\<C-^>vim\<C-^>", 'tx')
+ call cursor(1, 1)
+ call feedkeys("/^sghl!\<C-^>vim$\<C-^>\<CR>", 'tx')
+ call assert_equal([2, 1], [line('.'), col('.')])
+
+ " Try searching in left-to-right mode
+ set rightleftcmd=
+ call cursor(1, 1)
+ call feedkeys("/^sghl!\<C-^>vim$\<CR>", 'tx')
+ call assert_equal([2, 1], [line('.'), col('.')])
+
+ set rightleftcmd&
+ set rightleft&
+ set arabic&
+ bwipe!
+endfunc
+
+" vim: shiftwidth=2 sts=2 expandtab
diff --git a/src/nvim/testdir/test_cmdline.vim b/src/nvim/testdir/test_cmdline.vim
index 5b9cd1c507..ef145d0b21 100644
--- a/src/nvim/testdir/test_cmdline.vim
+++ b/src/nvim/testdir/test_cmdline.vim
@@ -598,9 +598,6 @@ func Test_cmdline_paste()
endtry
call assert_equal("Xtestfile", bufname("%"))
- " Use an invalid expression for <C-\>e
- call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")')
-
" Try to paste an invalid register using <C-R>
call feedkeys(":\"one\<C-R>\<C-X>two\<CR>", 'xt')
call assert_equal('"onetwo', @:)
@@ -1349,9 +1346,53 @@ func Test_interrupt_compl()
set wildmode&
endfunc
+" Test for moving the cursor on the : command line
func Test_cmdline_edit()
- call feedkeys(":\"buffer\<Right>\<Home>\<Left>\<CR>", 'xt')
- call assert_equal("\"buffer", @:)
+ let str = ":one two\<C-U>"
+ let str ..= "one two\<C-W>\<C-W>"
+ let str ..= "\<Left>five\<Right>"
+ let str ..= "\<Home>two "
+ let str ..= "\<C-Left>one "
+ let str ..= "\<C-Right> three"
+ let str ..= "\<End>\<S-Left>four "
+ let str ..= "\<S-Right> six"
+ let str ..= "\<C-B>\"\<C-E> seven\<CR>"
+ call feedkeys(str, 'xt')
+ call assert_equal("\"one two three four five six seven", @:)
+endfunc
+
+" Test for moving the cursor on the / command line in 'rightleft' mode
+func Test_cmdline_edit_rightleft()
+ CheckFeature rightleft
+ set rightleft
+ set rightleftcmd=search
+ let str = "/one two\<C-U>"
+ let str ..= "one two\<C-W>\<C-W>"
+ let str ..= "\<Right>five\<Left>"
+ let str ..= "\<Home>two "
+ let str ..= "\<C-Right>one "
+ let str ..= "\<C-Left> three"
+ let str ..= "\<End>\<S-Right>four "
+ let str ..= "\<S-Left> six"
+ let str ..= "\<C-B>\"\<C-E> seven\<CR>"
+ call assert_fails("call feedkeys(str, 'xt')", 'E486:')
+ call assert_equal("\"one two three four five six seven", @/)
+ set rightleftcmd&
+ set rightleft&
+endfunc
+
+" Test for using <C-\>e in the command line to evaluate an expression
+func Test_cmdline_expr()
+ " Evaluate an expression from the beginning of a command line
+ call feedkeys(":abc\<C-B>\<C-\>e\"\\\"hello\"\<CR>\<CR>", 'xt')
+ call assert_equal('"hello', @:)
+
+ " Use an invalid expression for <C-\>e
+ call assert_beeps('call feedkeys(":\<C-\>einvalid\<CR>", "tx")')
+
+ " Insert literal <CTRL-\> in the command line
+ call feedkeys(":\"e \<C-\>\<C-Y>\<CR>", 'xt')
+ call assert_equal("\"e \<C-\>\<C-Y>", @:)
endfunc
" Test for normal mode commands not supported in the cmd window