Mercurial > vim
comparison 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 |
comparison
equal
deleted
inserted
replaced
31405:a49b1c42f649 | 31406:627d4f236ac8 |
---|---|
1 " Tests for the undo tree. | 1 " Tests for the undo tree. |
2 " Since this script is sourced we need to explicitly break changes up in | 2 " Since this script is sourced we need to explicitly break changes up in |
3 " undo-able pieces. Do that by setting 'undolevels'. | 3 " undo-able pieces. Do that by setting 'undolevels'. |
4 " Also tests :earlier and :later. | 4 " Also tests :earlier and :later. |
5 | |
6 source check.vim | |
7 source screendump.vim | |
5 | 8 |
6 func Test_undotree() | 9 func Test_undotree() |
7 new | 10 new |
8 | 11 |
9 normal! Aabc | 12 normal! Aabc |
773 call assert_equal([0, 2, 1, 0], getpos("'[")) | 776 call assert_equal([0, 2, 1, 0], getpos("'[")) |
774 call assert_equal([0, 2, 1, 0], getpos("']")) | 777 call assert_equal([0, 2, 1, 0], getpos("']")) |
775 bwipe! | 778 bwipe! |
776 endfunc | 779 endfunc |
777 | 780 |
781 func Test_undo_after_write() | |
782 " use a terminal to make undo work like when text is typed | |
783 CheckRunVimInTerminal | |
784 | |
785 let lines =<< trim END | |
786 edit Xtestfile.txt | |
787 set undolevels=100 undofile | |
788 imap . <Cmd>write<CR> | |
789 write | |
790 END | |
791 call writefile(lines, 'Xtest_undo_after_write', 'D') | |
792 let buf = RunVimInTerminal('-S Xtest_undo_after_write', #{rows: 6}) | |
793 | |
794 call term_sendkeys(buf, "Otest.\<CR>boo!!!\<Esc>") | |
795 sleep 100m | |
796 call term_sendkeys(buf, "u") | |
797 call VerifyScreenDump(buf, 'Test_undo_after_write_1', {}) | |
798 | |
799 call term_sendkeys(buf, "u") | |
800 call VerifyScreenDump(buf, 'Test_undo_after_write_2', {}) | |
801 | |
802 call StopVimInTerminal(buf) | |
803 call delete('Xtestfile.txt') | |
804 endfunc | |
805 | |
806 | |
778 " vim: shiftwidth=2 sts=2 expandtab | 807 " vim: shiftwidth=2 sts=2 expandtab |