diff src/testdir/test_terminal.vim @ 15557:c0560da7873e v8.1.0786

patch 8.1.0786: ml_get error when updating the status line commit https://github.com/vim/vim/commit/10772307c4e5299ed45470f92779f089a00d841e Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jan 20 18:25:54 2019 +0100 patch 8.1.0786: ml_get error when updating the status line Problem: ml_get error when updating the status line and a terminal had its scrollback cleared. (Chris Patuzzo) Solution: Check the cursor position when drawing the status line. (closes #3830)
author Bram Moolenaar <Bram@vim.org>
date Sun, 20 Jan 2019 18:30:06 +0100
parents a0a1bd12e48c
children f611222a4349
line wrap: on
line diff
--- a/src/testdir/test_terminal.vim
+++ b/src/testdir/test_terminal.vim
@@ -1719,3 +1719,28 @@ func Test_term_gettitle()
 
   exe term . 'bwipe!'
 endfunc
+
+" When drawing the statusline the cursor position may not have been updated
+" yet.
+" 1. create a terminal, make it show 2 lines
+" 2. 0.5 sec later: leave terminal window, execute "i"
+" 3. 0.5 sec later: clear terminal window, now it's 1 line
+" 4. 0.5 sec later: redraw, including statusline (used to trigger bug)
+" 4. 0.5 sec later: should be done, clean up
+func Test_terminal_statusline()
+  if !has('unix')
+    return
+  endif
+  set statusline=x
+  terminal
+  let tbuf = bufnr('')
+  call term_sendkeys(tbuf, "clear; echo a; echo b; sleep 1; clear\n")
+  call timer_start(500, { tid -> feedkeys("\<C-w>j", 'tx') })
+  call timer_start(1500, { tid -> feedkeys("\<C-l>", 'tx') })
+  au BufLeave * if &buftype == 'terminal' | silent! normal i | endif
+
+  sleep 2
+  exe tbuf . 'bwipe!'
+  au! BufLeave
+  set statusline=
+endfunc