diff src/testdir/test_undo.vim @ 31406:627d4f236ac8 v9.0.1036

patch 9.0.1036: undo misbehaves when writing from an insert mode mapping Commit: https://github.com/vim/vim/commit/3f8f82772313af9f2417b06651f30988b63e1c96 Author: Bram Moolenaar <Bram@vim.org> Date: Thu Dec 8 21:49:35 2022 +0000 patch 9.0.1036: undo misbehaves when writing from an insert mode mapping Problem: Undo misbehaves when writing from an insert mode mapping. Solution: Sync undo when writing. (closes https://github.com/vim/vim/issues/11674)
author Bram Moolenaar <Bram@vim.org>
date Thu, 08 Dec 2022 23:00:03 +0100
parents 0913cd44fdfa
children 257ab4ee8e4a
line wrap: on
line diff
--- a/src/testdir/test_undo.vim
+++ b/src/testdir/test_undo.vim
@@ -3,6 +3,9 @@
 " undo-able pieces.  Do that by setting 'undolevels'.
 " Also tests :earlier and :later.
 
+source check.vim
+source screendump.vim
+
 func Test_undotree()
   new
 
@@ -775,4 +778,30 @@ func Test_undo_mark()
   bwipe!
 endfunc
 
+func Test_undo_after_write()
+  " use a terminal to make undo work like when text is typed
+  CheckRunVimInTerminal
+
+  let lines =<< trim END
+      edit Xtestfile.txt
+      set undolevels=100 undofile
+      imap . <Cmd>write<CR>
+      write
+  END
+  call writefile(lines, 'Xtest_undo_after_write', 'D')
+  let buf = RunVimInTerminal('-S Xtest_undo_after_write', #{rows: 6})
+
+  call term_sendkeys(buf, "Otest.\<CR>boo!!!\<Esc>")
+  sleep 100m
+  call term_sendkeys(buf, "u")
+  call VerifyScreenDump(buf, 'Test_undo_after_write_1', {})
+
+  call term_sendkeys(buf, "u")
+  call VerifyScreenDump(buf, 'Test_undo_after_write_2', {})
+
+  call StopVimInTerminal(buf)
+  call delete('Xtestfile.txt')
+endfunc
+
+
 " vim: shiftwidth=2 sts=2 expandtab