patch 8.1.1812: reading a truncted undo file hangs Vim
Problem: Reading a truncted undo file hangs Vim.
Solution: Check for reading EOF. (closes #4769)
diff --git a/src/testdir/test_undo.vim b/src/testdir/test_undo.vim
index 1440660..5154b20 100644
--- a/src/testdir/test_undo.vim
+++ b/src/testdir/test_undo.vim
@@ -335,6 +335,24 @@
call delete('Xundofile')
endfunc
+" Check that reading a truncted undo file doesn't hang.
+func Test_undofile_truncated()
+ new
+ call setline(1, 'hello')
+ set ul=100
+ wundo Xundofile
+ let contents = readfile('Xundofile', 'B')
+
+ " try several sizes
+ for size in range(20, 500, 33)
+ call writefile(contents[0:size], 'Xundofile')
+ call assert_fails('rundo Xundofile', 'E825:')
+ endfor
+
+ bwipe!
+" call delete('Xundofile')
+endfunc
+
" Test for undo working properly when executing commands from a register.
" Also test this in an empty buffer.
func Test_cmd_in_reg_undo()