\ ' set nomodified',
\ 'endfunc',
\ '',
+ \ 'func SwitchWindows()',
+ \ ' call timer_start(0, {-> execute("wincmd p|wincmd p", "")})',
+ \ 'endfunc',
+ \ '',
\ 'call setline(1, "other buffer")',
\ 'set nomodified',
\ 'new',
call delete(scriptName)
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 MyPromptCallback(x, text)
" NOP
stop_insert_mode = FALSE;
// 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;
}
#endif