comparison src/testdir/test_terminal.vim @ 26598:b3ac5a4dc158 v8.2.3828

patch 8.2.3828: when opening a terminal from a timer first typed char is lost Commit: https://github.com/vim/vim/commit/8103527da7f12ff21c2566222748518ee093432c Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 16 18:02:07 2021 +0000 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.
author Bram Moolenaar <Bram@vim.org>
date Thu, 16 Dec 2021 19:15:04 +0100
parents 7a74515dde6b
children 8bb07c88ac27
comparison
equal deleted inserted replaced
26597:0a31a23836de 26598:b3ac5a4dc158
1594 " 3. 0.5 sec later: clear terminal window, now it's 1 line 1594 " 3. 0.5 sec later: clear terminal window, now it's 1 line
1595 " 4. 0.5 sec later: redraw, including statusline (used to trigger bug) 1595 " 4. 0.5 sec later: redraw, including statusline (used to trigger bug)
1596 " 4. 0.5 sec later: should be done, clean up 1596 " 4. 0.5 sec later: should be done, clean up
1597 func Test_terminal_statusline() 1597 func Test_terminal_statusline()
1598 CheckUnix 1598 CheckUnix
1599 CheckFeature timers
1599 1600
1600 set statusline=x 1601 set statusline=x
1601 terminal 1602 terminal
1602 let tbuf = bufnr('') 1603 let tbuf = bufnr('')
1603 call term_sendkeys(tbuf, "clear; echo a; echo b; sleep 1; clear\n") 1604 call term_sendkeys(tbuf, "clear; echo a; echo b; sleep 1; clear\n")
1607 1608
1608 sleep 2 1609 sleep 2
1609 exe tbuf . 'bwipe!' 1610 exe tbuf . 'bwipe!'
1610 au! BufLeave 1611 au! BufLeave
1611 set statusline= 1612 set statusline=
1613 endfunc
1614
1615 func CheckTerminalWindowWorks(buf)
1616 call WaitForAssert({-> assert_match('!sh \[running\]', term_getline(a:buf, 10))})
1617 call term_sendkeys(a:buf, "exit\<CR>")
1618 call WaitForAssert({-> assert_match('!sh \[finished\]', term_getline(a:buf, 10))})
1619 call term_sendkeys(a:buf, ":q\<CR>")
1620 call WaitForAssert({-> assert_match('^\~', term_getline(a:buf, 10))})
1621 endfunc
1622
1623 func Test_start_terminal_from_timer()
1624 CheckUnix
1625 CheckFeature timers
1626
1627 " Open a terminal window from a timer, typed text goes to the terminal
1628 call writefile(["call timer_start(100, { -> term_start('sh') })"], 'XtimerTerm')
1629 let buf = RunVimInTerminal('-S XtimerTerm', {})
1630 call CheckTerminalWindowWorks(buf)
1631
1632 " do the same in Insert mode
1633 call term_sendkeys(buf, ":call timer_start(200, { -> term_start('sh') })\<CR>a")
1634 call CheckTerminalWindowWorks(buf)
1635
1636 call StopVimInTerminal(buf)
1637 call delete('XtimerTerm')
1612 endfunc 1638 endfunc
1613 1639
1614 func Test_terminal_window_focus() 1640 func Test_terminal_window_focus()
1615 let winid1 = win_getid() 1641 let winid1 = win_getid()
1616 terminal 1642 terminal