aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-07-14 06:38:26 +0800
committerzeertzjq <zeertzjq@outlook.com>2024-07-14 13:39:40 +0800
commit9093fbdd026f088d923fea374a96a8b01ca0df3a (patch)
treec7499162182654955099ca94e39b23a446f56f05 /test
parent49ba36becd0bbf1052802b846f418aee673b28a5 (diff)
downloadrneovim-9093fbdd026f088d923fea374a96a8b01ca0df3a.tar.gz
rneovim-9093fbdd026f088d923fea374a96a8b01ca0df3a.tar.bz2
rneovim-9093fbdd026f088d923fea374a96a8b01ca0df3a.zip
vim-patch:9.1.0573: ex: no implicit print for single addresses
Problem: ex: no implicit print for single addresses Solution: explicitly print even during single addresses, as requested by POSIX (Mohamed Akram) See the POSIX behaviour here: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ex.html#tag_20_40_13_03 Section 6b closes: vim/vim#15230 https://github.com/vim/vim/commit/c25a7084e9ae1f78c28ddcbe1fa23374cfdf1e03 Co-authored-by: Mohamed Akram <mohd.akram@outlook.com>
Diffstat (limited to 'test')
-rw-r--r--test/old/testdir/setup.vim19
-rw-r--r--test/old/testdir/test_ex_mode.vim11
2 files changed, 28 insertions, 2 deletions
diff --git a/test/old/testdir/setup.vim b/test/old/testdir/setup.vim
index 2e4085ce03..6f400c5e32 100644
--- a/test/old/testdir/setup.vim
+++ b/test/old/testdir/setup.vim
@@ -32,8 +32,8 @@ if exists('s:did_load')
endif
if g:testname !~ 'test_mapping.vim$'
" Make "Q" switch to Ex mode.
- " This does not work for all tests.
- nnoremap Q gQ
+ " This does not work for all tests as Nvim only supports Vim Ex mode.
+ nnoremap Q gQ<Cmd>call<SID>ExStart()<CR>
endif
endif
@@ -45,6 +45,21 @@ if exists('s:did_load')
endif
let s:did_load = 1
+func s:ExStart()
+ call feedkeys($"\<Cmd>call{expand('<SID>')}ExMayEnd()\<CR>")
+endfunc
+
+func s:ExMayEnd()
+ " When :normal runs out of characters in Vim, the behavior is different in
+ " normal Ex mode vs. Vim Ex mode.
+ " - In normal Ex mode, "\n" is used.
+ " - In Vim Ex mode, Ctrl-C is used.
+ " Nvim only supports Vim Ex mode, so emulate the normal Ex mode behavior.
+ if state('m') == '' && mode(1) == 'cv' && getcharstr(1) == "\<C-C>"
+ call feedkeys("\n")
+ endif
+endfunc
+
" Clear Nvim default user commands, mappings and menus.
comclear
mapclear
diff --git a/test/old/testdir/test_ex_mode.vim b/test/old/testdir/test_ex_mode.vim
index 42f08868a0..31615ec47d 100644
--- a/test/old/testdir/test_ex_mode.vim
+++ b/test/old/testdir/test_ex_mode.vim
@@ -282,4 +282,15 @@ func Test_ex_mode_large_indent()
endfunc
+" Testing implicit print command
+func Test_implicit_print()
+ new
+ call setline(1, ['one', 'two', 'three'])
+ call feedkeys('Q:let a=execute(":1,2")', 'xt')
+ call feedkeys('Q:let b=execute(":3")', 'xt')
+ call assert_equal('one two', a->split('\n')->join(' '))
+ call assert_equal('three', b->split('\n')->join(' '))
+ bw!
+endfunc
+
" vim: shiftwidth=2 sts=2 expandtab