From 9093fbdd026f088d923fea374a96a8b01ca0df3a Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 14 Jul 2024 06:38:26 +0800 Subject: 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 --- test/old/testdir/setup.vim | 19 +++++++++++++++++-- test/old/testdir/test_ex_mode.vim | 11 +++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) (limited to 'test') 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 gQcallExStart() endif endif @@ -45,6 +45,21 @@ if exists('s:did_load') endif let s:did_load = 1 +func s:ExStart() + call feedkeys($"\call{expand('')}ExMayEnd()\") +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) == "\" + 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 -- cgit