mirror of
https://github.com/vim/vim.git
synced 2025-07-26 11:04:33 -04:00
patch 8.2.3828: when opening a terminal from a timer first typed char is lost
Problem: when opening a terminal from a timer the first typed character is lost. (Virginia Senioria) Solution: When opening a terminal while waiting for a character put K_IGNORE in the input buffer.
This commit is contained in:
parent
f79cbf6512
commit
8103527da7
@ -598,9 +598,14 @@ edit(
|
|||||||
{
|
{
|
||||||
c = safe_vgetc();
|
c = safe_vgetc();
|
||||||
|
|
||||||
if (stop_insert_mode)
|
if (stop_insert_mode
|
||||||
|
#ifdef FEAT_TERMINAL
|
||||||
|
|| (c == K_IGNORE && term_use_loop())
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
// Insert mode ended, possibly from a callback.
|
// Insert mode ended, possibly from a callback, or a timer
|
||||||
|
// must have opened a terminal window.
|
||||||
if (c != K_IGNORE && c != K_NOP)
|
if (c != K_IGNORE && c != K_NOP)
|
||||||
vungetc(c);
|
vungetc(c);
|
||||||
count = 0;
|
count = 0;
|
||||||
|
@ -739,6 +739,23 @@ term_start(
|
|||||||
curwin->w_buffer = curbuf;
|
curwin->w_buffer = curbuf;
|
||||||
++curbuf->b_nwindows;
|
++curbuf->b_nwindows;
|
||||||
}
|
}
|
||||||
|
else if (vgetc_busy
|
||||||
|
#ifdef FEAT_TIMERS
|
||||||
|
|| timer_busy
|
||||||
|
#endif
|
||||||
|
|| input_busy)
|
||||||
|
{
|
||||||
|
char_u ignore[4];
|
||||||
|
|
||||||
|
// When waiting for input need to return and possibly end up in
|
||||||
|
// terminal_loop() instead.
|
||||||
|
ignore[0] = K_SPECIAL;
|
||||||
|
ignore[1] = KS_EXTRA;
|
||||||
|
ignore[2] = KE_IGNORE;
|
||||||
|
ignore[3] = NUL;
|
||||||
|
ins_typebuf(ignore, REMAP_NONE, 0, TRUE, FALSE);
|
||||||
|
typebuf_was_filled = TRUE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1596,6 +1596,7 @@ endfunc
|
|||||||
" 4. 0.5 sec later: should be done, clean up
|
" 4. 0.5 sec later: should be done, clean up
|
||||||
func Test_terminal_statusline()
|
func Test_terminal_statusline()
|
||||||
CheckUnix
|
CheckUnix
|
||||||
|
CheckFeature timers
|
||||||
|
|
||||||
set statusline=x
|
set statusline=x
|
||||||
terminal
|
terminal
|
||||||
@ -1611,6 +1612,31 @@ func Test_terminal_statusline()
|
|||||||
set statusline=
|
set statusline=
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func CheckTerminalWindowWorks(buf)
|
||||||
|
call WaitForAssert({-> assert_match('!sh \[running\]', term_getline(a:buf, 10))})
|
||||||
|
call term_sendkeys(a:buf, "exit\<CR>")
|
||||||
|
call WaitForAssert({-> assert_match('!sh \[finished\]', term_getline(a:buf, 10))})
|
||||||
|
call term_sendkeys(a:buf, ":q\<CR>")
|
||||||
|
call WaitForAssert({-> assert_match('^\~', term_getline(a:buf, 10))})
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_start_terminal_from_timer()
|
||||||
|
CheckUnix
|
||||||
|
CheckFeature timers
|
||||||
|
|
||||||
|
" Open a terminal window from a timer, typed text goes to the terminal
|
||||||
|
call writefile(["call timer_start(100, { -> term_start('sh') })"], 'XtimerTerm')
|
||||||
|
let buf = RunVimInTerminal('-S XtimerTerm', {})
|
||||||
|
call CheckTerminalWindowWorks(buf)
|
||||||
|
|
||||||
|
" do the same in Insert mode
|
||||||
|
call term_sendkeys(buf, ":call timer_start(200, { -> term_start('sh') })\<CR>a")
|
||||||
|
call CheckTerminalWindowWorks(buf)
|
||||||
|
|
||||||
|
call StopVimInTerminal(buf)
|
||||||
|
call delete('XtimerTerm')
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_terminal_window_focus()
|
func Test_terminal_window_focus()
|
||||||
let winid1 = win_getid()
|
let winid1 = win_getid()
|
||||||
terminal
|
terminal
|
||||||
|
@ -749,6 +749,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 */
|
||||||
|
/**/
|
||||||
|
3828,
|
||||||
/**/
|
/**/
|
||||||
3827,
|
3827,
|
||||||
/**/
|
/**/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user