patch 8.0.1440: terminal window: some vterm responses are delayed
Problem: Terminal window: some vterm responses are delayed.
Solution: After writing input. check if there is output to read. (Ozaki
Kiichi, closes #2594)
diff --git a/src/testdir/test_search.vim b/src/testdir/test_search.vim
index 9b96b49..130562f 100644
--- a/src/testdir/test_search.vim
+++ b/src/testdir/test_search.vim
@@ -619,6 +619,8 @@
let buf = term_start([GetVimProg(), '--clean', '-c', 'set noswapfile', 'Xsearch.txt'], {'term_rows': 3})
call WaitFor({-> lines == [term_getline(buf, 1), term_getline(buf, 2)] })
+ " wait for vim to complete initialization
+ call term_wait(buf)
" Get attr of normal(a0), incsearch(a1), hlsearch(a2) highlight
call term_sendkeys(buf, ":set incsearch hlsearch\<cr>")
diff --git a/src/testdir/test_terminal.vim b/src/testdir/test_terminal.vim
index 3116b80..853c69c 100644
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -806,3 +806,26 @@
let cmd = "call term_start(0, {'curwin' : 1, 'term_finish' : 'close'})"
call assert_fails(cmd, 'E474')
endfunc
+
+func Test_terminal_response_to_control_sequence()
+ if !has('unix')
+ return
+ endif
+
+ let buf = Run_shell_in_terminal({})
+ call term_wait(buf)
+
+ call term_sendkeys(buf, s:python . " -c 'import sys;sys.stdout.write(\"\\x1b[6n\")'\<cr>")
+ " wait for the response of control sequence from libvterm (and send it to tty)
+ call term_wait(buf, 100)
+ " wait for output from tty to display
+ call term_wait(buf)
+ call assert_match(';\d\+R', term_getline(buf, 2))
+
+ call term_sendkeys(buf, "\<c-c>")
+ call term_wait(buf)
+ call Stop_shell_in_terminal(buf)
+
+ exe buf . 'bwipe'
+ unlet g:job
+endfunc