mirror of
https://github.com/neovim/neovim.git
synced 2025-10-01 15:38:33 +00: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:
@@ -41,6 +41,10 @@ func WriteScript(name)
|
||||
\ ' set nomodified',
|
||||
\ 'endfunc',
|
||||
\ '',
|
||||
\ 'func SwitchWindows()',
|
||||
\ ' call timer_start(0, {-> execute("wincmd p|wincmd p", "")})',
|
||||
\ 'endfunc',
|
||||
\ '',
|
||||
\ 'call setline(1, "other buffer")',
|
||||
\ 'set nomodified',
|
||||
\ 'new',
|
||||
@@ -103,6 +107,28 @@ func Test_prompt_editing()
|
||||
call delete(scriptName)
|
||||
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 MyPromptCallback(x, text)
|
||||
" 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
|
||||
// mode when we left it.
|
||||
restart_edit = win->w_buffer->b_prompt_insert;
|
||||
// mode when we left it and not already in Insert mode.
|
||||
if ((State & INSERT) == 0) {
|
||||
restart_edit = win->w_buffer->b_prompt_insert;
|
||||
}
|
||||
}
|
||||
|
||||
/// Closes all windows for buffer `buf`.
|
||||
|
Reference in New Issue
Block a user