mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.2.3671: restarting Insert mode in prompt buffer too often
Problem: Restarting Insert mode in prompt buffer too often when a callback
switches windows and comes back. (Sean Dewar)
Solution: Do not set "restart_edit" when already in Insert mode.
34c20ff85b
As Test_prompt_switch_windows is skipped, implement it in prompt_buffer_spec.
Replace the 50ms term_wait calls with poke_eventloop (test seems to work anyway
without them, so maybe they're not required?)
The new test does include a duplicate screen test that may generate a "screen
test succeeded immediately" warning, but this is done to match the Vim test.
This commit is contained in:
parent
0f792b284f
commit
361f548437
@ -41,6 +41,10 @@ func WriteScript(name)
|
|||||||
\ ' set nomodified',
|
\ ' set nomodified',
|
||||||
\ 'endfunc',
|
\ 'endfunc',
|
||||||
\ '',
|
\ '',
|
||||||
|
\ 'func SwitchWindows()',
|
||||||
|
\ ' call timer_start(0, {-> execute("wincmd p|wincmd p", "")})',
|
||||||
|
\ 'endfunc',
|
||||||
|
\ '',
|
||||||
\ 'call setline(1, "other buffer")',
|
\ 'call setline(1, "other buffer")',
|
||||||
\ 'set nomodified',
|
\ 'set nomodified',
|
||||||
\ 'new',
|
\ 'new',
|
||||||
@ -103,6 +107,28 @@ func Test_prompt_editing()
|
|||||||
call delete(scriptName)
|
call delete(scriptName)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_prompt_switch_windows()
|
||||||
|
throw 'skipped: TODO'
|
||||||
|
call CanTestPromptBuffer()
|
||||||
|
let scriptName = 'XpromptSwitchWindows'
|
||||||
|
call WriteScript(scriptName)
|
||||||
|
|
||||||
|
let buf = RunVimInTerminal('-S ' . scriptName, {'rows': 12})
|
||||||
|
call WaitForAssert({-> assert_equal('cmd:', term_getline(buf, 1))})
|
||||||
|
call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 12))})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<C-O>:call SwitchWindows()\<CR>")
|
||||||
|
call term_wait(buf, 50)
|
||||||
|
call WaitForAssert({-> assert_match('-- INSERT --', term_getline(buf, 12))})
|
||||||
|
|
||||||
|
call term_sendkeys(buf, "\<Esc>")
|
||||||
|
call term_wait(buf, 50)
|
||||||
|
call WaitForAssert({-> assert_match('^ *$', term_getline(buf, 12))})
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete(scriptName)
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_prompt_garbage_collect()
|
func Test_prompt_garbage_collect()
|
||||||
func MyPromptCallback(x, text)
|
func MyPromptCallback(x, text)
|
||||||
" NOP
|
" NOP
|
||||||
|
@ -2271,8 +2271,10 @@ void entering_window(win_T *const win)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// When entering the prompt window restart Insert mode if we were in Insert
|
// When entering the prompt window restart Insert mode if we were in Insert
|
||||||
// mode when we left it.
|
// mode when we left it and not already in Insert mode.
|
||||||
restart_edit = win->w_buffer->b_prompt_insert;
|
if ((State & INSERT) == 0) {
|
||||||
|
restart_edit = win->w_buffer->b_prompt_insert;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Closes all windows for buffer `buf`.
|
/// Closes all windows for buffer `buf`.
|
||||||
|
@ -31,6 +31,10 @@ describe('prompt buffer', function()
|
|||||||
func TimerFunc(text)
|
func TimerFunc(text)
|
||||||
call append(line("$") - 1, 'Result: "' . a:text .'"')
|
call append(line("$") - 1, 'Result: "' . a:text .'"')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func SwitchWindows()
|
||||||
|
call timer_start(0, {-> execute("wincmd p|wincmd p", "")})
|
||||||
|
endfunc
|
||||||
]])
|
]])
|
||||||
feed_command("set noshowmode | set laststatus=0")
|
feed_command("set noshowmode | set laststatus=0")
|
||||||
feed_command("call setline(1, 'other buffer')")
|
feed_command("call setline(1, 'other buffer')")
|
||||||
@ -167,6 +171,51 @@ describe('prompt buffer', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('switch windows', function()
|
||||||
|
feed_command("set showmode")
|
||||||
|
feed("i")
|
||||||
|
screen:expect([[
|
||||||
|
cmd: ^ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
[Prompt] [+] |
|
||||||
|
other buffer |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
-- INSERT -- |
|
||||||
|
]])
|
||||||
|
feed("<C-O>:call SwitchWindows()<CR>")
|
||||||
|
poke_eventloop()
|
||||||
|
screen:expect([[
|
||||||
|
cmd: ^ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
[Prompt] [+] |
|
||||||
|
other buffer |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
-- INSERT -- |
|
||||||
|
]])
|
||||||
|
feed("<Esc>")
|
||||||
|
poke_eventloop()
|
||||||
|
screen:expect([[
|
||||||
|
cmd:^ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
[Prompt] [+] |
|
||||||
|
other buffer |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
~ |
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
it('keeps insert mode after aucmd_restbuf in callback', function()
|
it('keeps insert mode after aucmd_restbuf in callback', function()
|
||||||
source [[
|
source [[
|
||||||
let s:buf = nvim_create_buf(1, 1)
|
let s:buf = nvim_create_buf(1, 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user