diff options
-rw-r--r-- | runtime/doc/motion.txt | 1 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 3 | ||||
-rw-r--r-- | src/nvim/getchar.c | 2 | ||||
-rw-r--r-- | test/old/testdir/setup.vim | 19 | ||||
-rw-r--r-- | test/old/testdir/test_ex_mode.vim | 11 |
5 files changed, 32 insertions, 4 deletions
diff --git a/runtime/doc/motion.txt b/runtime/doc/motion.txt index e80969c583..26e4ada7d4 100644 --- a/runtime/doc/motion.txt +++ b/runtime/doc/motion.txt @@ -342,6 +342,7 @@ gg Goto line [count], default first line, on the first *:[range]* :[range] Set the cursor on the last line number in [range]. + In Ex mode, print the lines in [range]. [range] can also be just one line number, e.g., ":1" or ":'m". In contrast with |G| this command does not modify the diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 2495b673e4..6fae8f091e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -2079,6 +2079,7 @@ static char *do_one_cmd(char **cmdlinep, int flags, cstack_T *cstack, LineGetter if (ea.skip) { // skip this if inside :if goto doend; } + assert(errormsg == NULL); errormsg = ex_range_without_command(&ea); goto doend; } @@ -2431,7 +2432,7 @@ static char *ex_range_without_command(exarg_T *eap) { char *errormsg = NULL; - if (*eap->cmd == '|' || (exmode_active && eap->line1 != eap->line2)) { + if (*eap->cmd == '|' || exmode_active) { eap->cmdidx = CMD_print; eap->argt = EX_RANGE | EX_COUNT | EX_TRLBAR; if ((errormsg = invalid_range(eap)) == NULL) { diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index d6534a08ff..154a6a636a 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -2729,7 +2729,7 @@ static int vgetorpeek(bool advance) timedout = true; continue; } - // In Ex-mode \n is compatible with original Vim behaviour. + // For the command line only CTRL-C always breaks it. // For the cmdline window: Alternate between ESC and // CTRL-C: ESC for most situations and CTRL-C to close the 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 |