mirror of
https://github.com/vim/vim.git
synced 2025-07-25 10:54:51 -04:00
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.
This commit is contained in:
parent
8af87bd6b1
commit
34c20ff85b
@ -39,6 +39,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',
|
||||||
@ -99,6 +103,27 @@ func Test_prompt_editing()
|
|||||||
call delete(scriptName)
|
call delete(scriptName)
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_prompt_switch_windows()
|
||||||
|
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
|
||||||
|
@ -757,6 +757,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
3671,
|
||||||
/**/
|
/**/
|
||||||
3670,
|
3670,
|
||||||
/**/
|
/**/
|
||||||
|
@ -2268,8 +2268,9 @@ entering_window(win_T *win)
|
|||||||
stop_insert_mode = FALSE;
|
stop_insert_mode = FALSE;
|
||||||
|
|
||||||
// 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;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user