mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #29696 from zeertzjq/vim-9.1.0573
vim-patch:9.1.{0573,0574,0582}
This commit is contained in:
commit
f0eb855607
@ -1927,6 +1927,16 @@ These two commands will keep on asking for lines, until you type a line
|
|||||||
containing only a ".". Watch out for lines starting with a backslash, see
|
containing only a ".". Watch out for lines starting with a backslash, see
|
||||||
|line-continuation|.
|
|line-continuation|.
|
||||||
|
|
||||||
|
Text typed after a "|" command separator is used first. So the following
|
||||||
|
command in ex mode: >
|
||||||
|
:a|one
|
||||||
|
two
|
||||||
|
.
|
||||||
|
:visual
|
||||||
|
<appends the following text, after the cursor line: >
|
||||||
|
one
|
||||||
|
two
|
||||||
|
<
|
||||||
NOTE: These commands cannot be used with |:global| or |:vglobal|.
|
NOTE: These commands cannot be used with |:global| or |:vglobal|.
|
||||||
":append" and ":insert" don't work properly in between ":if" and
|
":append" and ":insert" don't work properly in between ":if" and
|
||||||
":endif", ":for" and ":endfor", ":while" and ":endwhile".
|
":endif", ":for" and ":endfor", ":while" and ":endwhile".
|
||||||
|
@ -342,6 +342,7 @@ gg Goto line [count], default first line, on the first
|
|||||||
|
|
||||||
*:[range]*
|
*:[range]*
|
||||||
:[range] Set the cursor on the last line number in [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"
|
[range] can also be just one line number, e.g., ":1"
|
||||||
or ":'m".
|
or ":'m".
|
||||||
In contrast with |G| this command does not modify the
|
In contrast with |G| this command does not modify the
|
||||||
|
@ -2784,7 +2784,11 @@ void ex_append(exarg_T *eap)
|
|||||||
indent = get_indent_lnum(lnum);
|
indent = get_indent_lnum(lnum);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (eap->ea_getline == NULL) {
|
if (*eap->arg == '|') {
|
||||||
|
// Get the text after the trailing bar.
|
||||||
|
theline = xstrdup(eap->arg + 1);
|
||||||
|
*eap->arg = NUL;
|
||||||
|
} else if (eap->ea_getline == NULL) {
|
||||||
// No getline() function, use the lines that follow. This ends
|
// No getline() function, use the lines that follow. This ends
|
||||||
// when there is no more.
|
// when there is no more.
|
||||||
if (eap->nextcmd == NULL || *eap->nextcmd == NUL) {
|
if (eap->nextcmd == NULL || *eap->nextcmd == NUL) {
|
||||||
|
@ -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
|
if (ea.skip) { // skip this if inside :if
|
||||||
goto doend;
|
goto doend;
|
||||||
}
|
}
|
||||||
|
assert(errormsg == NULL);
|
||||||
errormsg = ex_range_without_command(&ea);
|
errormsg = ex_range_without_command(&ea);
|
||||||
goto doend;
|
goto doend;
|
||||||
}
|
}
|
||||||
@ -2425,13 +2426,17 @@ char *ex_errmsg(const char *const msg, const char *const arg)
|
|||||||
return ex_error_buf;
|
return ex_error_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The "+" string used in place of an empty command in Ex mode.
|
||||||
|
/// This string is used in pointer comparison.
|
||||||
|
static char exmode_plus[] = "+";
|
||||||
|
|
||||||
/// Handle a range without a command.
|
/// Handle a range without a command.
|
||||||
/// Returns an error message on failure.
|
/// Returns an error message on failure.
|
||||||
static char *ex_range_without_command(exarg_T *eap)
|
static char *ex_range_without_command(exarg_T *eap)
|
||||||
{
|
{
|
||||||
char *errormsg = NULL;
|
char *errormsg = NULL;
|
||||||
|
|
||||||
if (*eap->cmd == '|' || (exmode_active && eap->line1 != eap->line2)) {
|
if (*eap->cmd == '|' || (exmode_active && eap->cmd != exmode_plus + 1)) {
|
||||||
eap->cmdidx = CMD_print;
|
eap->cmdidx = CMD_print;
|
||||||
eap->argt = EX_RANGE | EX_COUNT | EX_TRLBAR;
|
eap->argt = EX_RANGE | EX_COUNT | EX_TRLBAR;
|
||||||
if ((errormsg = invalid_range(eap)) == NULL) {
|
if ((errormsg = invalid_range(eap)) == NULL) {
|
||||||
@ -2490,7 +2495,7 @@ int parse_command_modifiers(exarg_T *eap, const char **errormsg, cmdmod_T *cmod,
|
|||||||
if (*eap->cmd == NUL && exmode_active
|
if (*eap->cmd == NUL && exmode_active
|
||||||
&& getline_equal(eap->ea_getline, eap->cookie, getexline)
|
&& getline_equal(eap->ea_getline, eap->cookie, getexline)
|
||||||
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
|
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count) {
|
||||||
eap->cmd = "+";
|
eap->cmd = exmode_plus;
|
||||||
if (!skip_only) {
|
if (!skip_only) {
|
||||||
ex_pressedreturn = true;
|
ex_pressedreturn = true;
|
||||||
}
|
}
|
||||||
@ -4107,7 +4112,12 @@ void separate_nextcmd(exarg_T *eap)
|
|||||||
&& !(eap->argt & EX_NOTRLCOM)
|
&& !(eap->argt & EX_NOTRLCOM)
|
||||||
&& (eap->cmdidx != CMD_at || p != eap->arg)
|
&& (eap->cmdidx != CMD_at || p != eap->arg)
|
||||||
&& (eap->cmdidx != CMD_redir
|
&& (eap->cmdidx != CMD_redir
|
||||||
|| p != eap->arg + 1 || p[-1] != '@')) || *p == '|' || *p == '\n') {
|
|| p != eap->arg + 1 || p[-1] != '@'))
|
||||||
|
|| (*p == '|'
|
||||||
|
&& eap->cmdidx != CMD_append
|
||||||
|
&& eap->cmdidx != CMD_change
|
||||||
|
&& eap->cmdidx != CMD_insert)
|
||||||
|
|| *p == '\n') {
|
||||||
// We remove the '\' before the '|', unless EX_CTRLV is used
|
// We remove the '\' before the '|', unless EX_CTRLV is used
|
||||||
// AND 'b' is present in 'cpoptions'.
|
// AND 'b' is present in 'cpoptions'.
|
||||||
if ((vim_strchr(p_cpo, CPO_BAR) == NULL
|
if ((vim_strchr(p_cpo, CPO_BAR) == NULL
|
||||||
|
@ -2729,7 +2729,7 @@ static int vgetorpeek(bool advance)
|
|||||||
timedout = true;
|
timedout = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// In Ex-mode \n is compatible with original Vim behaviour.
|
|
||||||
// For the command line only CTRL-C always breaks it.
|
// For the command line only CTRL-C always breaks it.
|
||||||
// For the cmdline window: Alternate between ESC and
|
// For the cmdline window: Alternate between ESC and
|
||||||
// CTRL-C: ESC for most situations and CTRL-C to close the
|
// CTRL-C: ESC for most situations and CTRL-C to close the
|
||||||
|
@ -48,7 +48,7 @@ describe('Ex mode', function()
|
|||||||
command('set noincsearch nohlsearch inccommand=')
|
command('set noincsearch nohlsearch inccommand=')
|
||||||
local screen = Screen.new(60, 6)
|
local screen = Screen.new(60, 6)
|
||||||
screen:attach()
|
screen:attach()
|
||||||
command([[call setline(1, ['foo foo', 'foo foo', 'foo foo'])]])
|
command([[call setline(1, repeat(['foo foo'], 4))]])
|
||||||
command([[set number]])
|
command([[set number]])
|
||||||
feed('gQ')
|
feed('gQ')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
@ -110,12 +110,24 @@ describe('Ex mode', function()
|
|||||||
:^ |
|
:^ |
|
||||||
]])
|
]])
|
||||||
|
|
||||||
|
-- The printed line should overwrite the colon
|
||||||
|
feed('<CR>')
|
||||||
|
screen:expect([[
|
||||||
|
{8: 2 }foo foo |
|
||||||
|
^^^q |
|
||||||
|
{8: 2 }foo foo |
|
||||||
|
{8: 3 }foo foo |
|
||||||
|
{8: 4 }foo foo |
|
||||||
|
:^ |
|
||||||
|
]])
|
||||||
|
|
||||||
feed(':vi<CR>')
|
feed(':vi<CR>')
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{8: 1 }foo bar |
|
{8: 1 }foo bar |
|
||||||
{8: 2 }foo foo |
|
{8: 2 }foo foo |
|
||||||
{8: 3 }^foo foo |
|
{8: 3 }foo foo |
|
||||||
{1:~ }|*2
|
{8: 4 }^foo foo |
|
||||||
|
{1:~ }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
@ -32,8 +32,8 @@ if exists('s:did_load')
|
|||||||
endif
|
endif
|
||||||
if g:testname !~ 'test_mapping.vim$'
|
if g:testname !~ 'test_mapping.vim$'
|
||||||
" Make "Q" switch to Ex mode.
|
" Make "Q" switch to Ex mode.
|
||||||
" This does not work for all tests.
|
" This does not work for all tests as Nvim only supports Vim Ex mode.
|
||||||
nnoremap Q gQ
|
nnoremap Q gQ<Cmd>call<SID>ExStart()<CR>
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -45,6 +45,21 @@ if exists('s:did_load')
|
|||||||
endif
|
endif
|
||||||
let s:did_load = 1
|
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.
|
" Clear Nvim default user commands, mappings and menus.
|
||||||
comclear
|
comclear
|
||||||
mapclear
|
mapclear
|
||||||
|
@ -69,7 +69,7 @@ func Test_Ex_substitute()
|
|||||||
CheckRunVimInTerminal
|
CheckRunVimInTerminal
|
||||||
let buf = RunVimInTerminal('', {'rows': 6})
|
let buf = RunVimInTerminal('', {'rows': 6})
|
||||||
|
|
||||||
call term_sendkeys(buf, ":call setline(1, ['foo foo', 'foo foo', 'foo foo'])\<CR>")
|
call term_sendkeys(buf, ":call setline(1, repeat(['foo foo'], 4))\<CR>")
|
||||||
call term_sendkeys(buf, ":set number\<CR>")
|
call term_sendkeys(buf, ":set number\<CR>")
|
||||||
call term_sendkeys(buf, "gQ")
|
call term_sendkeys(buf, "gQ")
|
||||||
call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
|
call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
|
||||||
@ -91,8 +91,14 @@ func Test_Ex_substitute()
|
|||||||
|
|
||||||
" Pressing enter in ex mode should print the current line
|
" Pressing enter in ex mode should print the current line
|
||||||
call term_sendkeys(buf, "\<CR>")
|
call term_sendkeys(buf, "\<CR>")
|
||||||
call WaitForAssert({-> assert_match(' 3 foo foo',
|
call WaitForAssert({-> assert_match(' 3 foo foo', term_getline(buf, 5))}, 1000)
|
||||||
\ term_getline(buf, 5))}, 1000)
|
call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
|
" The printed line should overwrite the colon
|
||||||
|
call term_sendkeys(buf, "\<CR>")
|
||||||
|
call WaitForAssert({-> assert_match(' 3 foo foo', term_getline(buf, 4))}, 1000)
|
||||||
|
call WaitForAssert({-> assert_match(' 4 foo foo', term_getline(buf, 5))}, 1000)
|
||||||
|
call WaitForAssert({-> assert_match(':', term_getline(buf, 6))}, 1000)
|
||||||
|
|
||||||
call term_sendkeys(buf, ":vi\<CR>")
|
call term_sendkeys(buf, ":vi\<CR>")
|
||||||
call WaitForAssert({-> assert_match('foo bar', term_getline(buf, 1))}, 1000)
|
call WaitForAssert({-> assert_match('foo bar', term_getline(buf, 1))}, 1000)
|
||||||
@ -282,4 +288,23 @@ func Test_ex_mode_large_indent()
|
|||||||
endfunc
|
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
|
||||||
|
|
||||||
|
" Test inserting text after the trailing bar
|
||||||
|
func Test_insert_after_trailing_bar()
|
||||||
|
new
|
||||||
|
call feedkeys("Qi|\nfoo\n.\na|bar\nbar\n.\nc|baz\n.", "xt")
|
||||||
|
call assert_equal(['', 'foo', 'bar', 'baz'], getline(1, '$'))
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
Loading…
Reference in New Issue
Block a user