mirror of
https://github.com/neovim/neovim.git
synced 2025-09-06 11:28:22 +00:00
vim-patch:9.1.0582: Printed line doesn't overwrite colon when pressing Enter in Ex mode
Problem: Printed line no longer overwrites colon when pressing Enter in
Ex mode (after 9.1.0573).
Solution: Restore the behavior of pressing Enter in Ex mode.
(zeertzjq)
closes: vim/vim#15258
7d664bf0eb
This commit is contained in:
@@ -2426,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) {
|
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) {
|
||||||
@@ -2491,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;
|
||||||
}
|
}
|
||||||
|
@@ -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)
|
||||||
|
@@ -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)
|
||||||
|
Reference in New Issue
Block a user