mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #19945 from zeertzjq/vim-8.2.0911
vim-patch:8.2.{0911,0923}: cmdwin interrupted
This commit is contained in:
commit
22f9200302
@ -4184,9 +4184,13 @@ void wipe_buffer(buf_T *buf, bool aucmd)
|
||||
/// @param bufnr Buffer to switch to, or 0 to create a new buffer.
|
||||
///
|
||||
/// @see curbufIsChanged()
|
||||
void buf_open_scratch(handle_T bufnr, char *bufname)
|
||||
///
|
||||
/// @return FAIL for failure, OK otherwise
|
||||
int buf_open_scratch(handle_T bufnr, char *bufname)
|
||||
{
|
||||
(void)do_ecmd((int)bufnr, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL);
|
||||
if (do_ecmd((int)bufnr, NULL, NULL, NULL, ECMD_ONE, ECMD_HIDE, NULL) == FAIL) {
|
||||
return FAIL;
|
||||
}
|
||||
apply_autocmds(EVENT_BUFFILEPRE, NULL, NULL, false, curbuf);
|
||||
(void)setfname(curbuf, bufname, NULL, true);
|
||||
apply_autocmds(EVENT_BUFFILEPOST, NULL, NULL, false, curbuf);
|
||||
@ -4194,4 +4198,5 @@ void buf_open_scratch(handle_T bufnr, char *bufname)
|
||||
set_option_value_give_err("bt", 0L, "nofile", OPT_LOCAL);
|
||||
set_option_value_give_err("swf", 0L, NULL, OPT_LOCAL);
|
||||
RESET_BINDING(curwin);
|
||||
return OK;
|
||||
}
|
||||
|
@ -4073,17 +4073,27 @@ static int open_cmdwin(void)
|
||||
ga_clear(&winsizes);
|
||||
return K_IGNORE;
|
||||
}
|
||||
// Don't let quitting the More prompt make this fail.
|
||||
got_int = false;
|
||||
|
||||
// Set "cmdwin_type" before any autocommands may mess things up.
|
||||
cmdwin_type = get_cmdline_type();
|
||||
cmdwin_level = ccline.level;
|
||||
|
||||
// Create empty command-line buffer.
|
||||
buf_open_scratch(0, _("[Command Line]"));
|
||||
if (buf_open_scratch(0, _("[Command Line]")) == FAIL) {
|
||||
// Some autocommand messed it up?
|
||||
win_close(curwin, true, false);
|
||||
ga_clear(&winsizes);
|
||||
cmdwin_type = 0;
|
||||
return Ctrl_C;
|
||||
}
|
||||
// Command-line buffer has bufhidden=wipe, unlike a true "scratch" buffer.
|
||||
set_option_value_give_err("bh", 0L, "wipe", OPT_LOCAL);
|
||||
curwin->w_p_rl = cmdmsg_rl;
|
||||
cmdmsg_rl = false;
|
||||
curbuf->b_p_ma = true;
|
||||
curwin->w_p_fen = false;
|
||||
curwin->w_p_rl = cmdmsg_rl;
|
||||
cmdmsg_rl = false;
|
||||
|
||||
// Don't allow switching to another buffer.
|
||||
curbuf->b_ro_locked++;
|
||||
|
@ -3,6 +3,7 @@
|
||||
source check.vim
|
||||
source screendump.vim
|
||||
source view_util.vim
|
||||
source shared.vim
|
||||
|
||||
func Test_complete_tab()
|
||||
call writefile(['testfile'], 'Xtestfile')
|
||||
@ -1453,6 +1454,32 @@ func Test_cmdwin_tabpage()
|
||||
tabclose!
|
||||
endfunc
|
||||
|
||||
func Test_cmdwin_interrupted()
|
||||
CheckScreendump
|
||||
|
||||
" aborting the :smile output caused the cmdline window to use the current
|
||||
" buffer.
|
||||
let lines =<< trim [SCRIPT]
|
||||
au WinNew * smile
|
||||
[SCRIPT]
|
||||
call writefile(lines, 'XTest_cmdwin')
|
||||
|
||||
let buf = RunVimInTerminal('-S XTest_cmdwin', {'rows': 18})
|
||||
" open cmdwin
|
||||
call term_sendkeys(buf, "q:")
|
||||
call WaitForAssert({-> assert_match('-- More --', term_getline(buf, 18))})
|
||||
" quit more prompt for :smile command
|
||||
call term_sendkeys(buf, "q")
|
||||
call WaitForAssert({-> assert_match('^$', term_getline(buf, 18))})
|
||||
" execute a simple command
|
||||
call term_sendkeys(buf, "aecho 'done'\<CR>")
|
||||
call VerifyScreenDump(buf, 'Test_cmdwin_interrupted', {})
|
||||
|
||||
" clean up
|
||||
call StopVimInTerminal(buf)
|
||||
call delete('XTest_cmdwin')
|
||||
endfunc
|
||||
|
||||
" Test for backtick expression in the command line
|
||||
func Test_cmd_backtick()
|
||||
CheckNotMSWindows " FIXME: see #19297
|
||||
|
@ -1,6 +1,7 @@
|
||||
local helpers = require('test.functional.helpers')(after_each)
|
||||
local Screen = require('test.functional.ui.screen')
|
||||
local clear = helpers.clear
|
||||
local command = helpers.command
|
||||
local feed = helpers.feed
|
||||
local feed_command = helpers.feed_command
|
||||
local exec = helpers.exec
|
||||
@ -141,3 +142,81 @@ describe('cmdline', function()
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('cmdwin', function()
|
||||
before_each(clear)
|
||||
|
||||
-- oldtest: Test_cmdwin_interrupted()
|
||||
it('still uses a new buffer when interrupting more prompt on open', function()
|
||||
local screen = Screen.new(30, 16)
|
||||
screen:set_default_attr_ids({
|
||||
[0] = {bold = true, foreground = Screen.colors.Blue}, -- NonText
|
||||
[1] = {bold = true, reverse = true}, -- StatusLine
|
||||
[2] = {reverse = true}, -- StatusLineNC
|
||||
[3] = {bold = true, foreground = Screen.colors.SeaGreen}, -- MoreMsg
|
||||
[4] = {bold = true}, -- ModeMsg
|
||||
})
|
||||
screen:attach()
|
||||
command('set more')
|
||||
command('autocmd WinNew * highlight')
|
||||
feed('q:')
|
||||
screen:expect({any = '{3:%-%- More %-%-}^'})
|
||||
feed('q')
|
||||
screen:expect([[
|
||||
|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{2:[No Name] }|
|
||||
{0::}^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{1:[Command Line] }|
|
||||
|
|
||||
]])
|
||||
feed([[aecho 'done']])
|
||||
screen:expect([[
|
||||
|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{2:[No Name] }|
|
||||
{0::}echo 'done'^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{1:[Command Line] }|
|
||||
{4:-- INSERT --} |
|
||||
]])
|
||||
feed('<CR>')
|
||||
screen:expect([[
|
||||
^ |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
done |
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user