Skip to content

Commit 44eae48

Browse files
zeertzjqchrisbra
authored andcommitted
vim-patch:9.1.0893: No test that undofile format does not regress (#37193)
Problem: No test that undofile format does not regress Solution: include a sample undofile to make sure we are always able to read it This is so, that we don't unintentionally change the undofile format and make sure we can load an undo file that has been created by an older Vim. closes: vim/vim#16127 vim/vim@14382c8 Convert the undo file in samples/ using method from #13973. Co-authored-by: Christian Brabandt <cb@256bit.org> (cherry picked from commit 94f7302)
1 parent 46f569a commit 44eae48

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
one
2+
two
3+
three
1.38 KB
Binary file not shown.

test/old/testdir/test_undo.vim

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -883,4 +883,33 @@ func Test_undo_range_normal()
883883
bwipe!
884884
endfunc
885885

886+
func Test_load_existing_undofile()
887+
CheckFeature persistent_undo
888+
sp samples/test_undo.txt
889+
let mess=execute(':verbose rundo samples/test_undo.txt.undo')
890+
call assert_match('Finished reading undo file', mess)
891+
892+
call assert_equal(['one', 'two', 'three'], getline(1, '$'))
893+
norm! u
894+
call assert_equal(['one', 'two'], getline(1, '$'))
895+
norm! u
896+
call assert_equal(['one'], getline(1, '$'))
897+
norm! u
898+
call assert_equal([''], getline(1, '$'))
899+
let mess = execute(':norm! u')
900+
call assert_equal([''], getline(1, '$'))
901+
call assert_match('Already at oldest change', mess)
902+
exe ":norm! \<c-r>"
903+
call assert_equal(['one'], getline(1, '$'))
904+
exe ":norm! \<c-r>"
905+
call assert_equal(['one', 'two'], getline(1, '$'))
906+
exe ":norm! \<c-r>"
907+
call assert_equal(['one', 'two', 'three'], getline(1, '$'))
908+
let mess = execute(":norm! \<c-r>")
909+
call assert_equal(['one', 'two', 'three'], getline(1, '$'))
910+
call assert_match('Already at newest change', mess)
911+
bw!
912+
endfunc
913+
914+
886915
" vim: shiftwidth=2 sts=2 expandtab

0 commit comments

Comments
 (0)