Permalink
Browse files

patch 8.0.1290: seq_cur of undotree() wrong after undo

Problem:    seq_cur of undotree() wrong after undo.
Solution:   Get the actual sequence number instead of decrementing the current
            one. (Ozaki Kiichi, closes #2319)
  • Loading branch information...
brammool committed Nov 11, 2017
1 parent 7f2e9d7 commit 80eaddd3a0bc47cb14168964678420cfe03a2502
Showing with 77 additions and 10 deletions.
  1. +69 −9 src/testdir/test_undo.vim
  2. +6 −1 src/undo.c
  3. +2 −0 src/version.c
View
@@ -4,22 +4,82 @@
" Also tests :earlier and :later.
func Test_undotree()
exe "normal Aabc\<Esc>"
new
normal! Aabc
set ul=100
let d = undotree()
call assert_equal(1, d.seq_last)
call assert_equal(1, d.seq_cur)
call assert_equal(0, d.save_last)
call assert_equal(0, d.save_cur)
call assert_equal(1, len(d.entries))
call assert_equal(1, d.entries[0].newhead)
call assert_equal(1, d.entries[0].seq)
call assert_true(d.entries[0].time <= d.time_cur)
normal! Adef
set ul=100
let d = undotree()
call assert_equal(2, d.seq_last)
call assert_equal(2, d.seq_cur)
call assert_equal(0, d.save_last)
call assert_equal(0, d.save_cur)
call assert_equal(2, len(d.entries))
call assert_equal(1, d.entries[0].seq)
call assert_equal(1, d.entries[1].newhead)
call assert_equal(2, d.entries[1].seq)
call assert_true(d.entries[1].time <= d.time_cur)
undo
set ul=100
exe "normal Adef\<Esc>"
let d = undotree()
call assert_equal(2, d.seq_last)
call assert_equal(1, d.seq_cur)
call assert_equal(0, d.save_last)
call assert_equal(0, d.save_cur)
call assert_equal(2, len(d.entries))
call assert_equal(1, d.entries[0].seq)
call assert_equal(1, d.entries[1].curhead)
call assert_equal(1, d.entries[1].newhead)
call assert_equal(2, d.entries[1].seq)
call assert_true(d.entries[1].time == d.time_cur)
normal! Aghi
set ul=100
let d = undotree()
call assert_equal(3, d.seq_last)
call assert_equal(3, d.seq_cur)
call assert_equal(0, d.save_last)
call assert_equal(0, d.save_cur)
call assert_equal(2, len(d.entries))
call assert_equal(1, d.entries[0].seq)
call assert_equal(2, d.entries[1].alt[0].seq)
call assert_equal(1, d.entries[1].newhead)
call assert_equal(3, d.entries[1].seq)
call assert_true(d.entries[1].time <= d.time_cur)
undo
set ul=100
let d = undotree()
call assert_true(d.seq_last > 0)
call assert_true(d.seq_cur > 0)
call assert_true(d.seq_cur < d.seq_last)
call assert_true(len(d.entries) > 0)
" TODO: check more members of d
call assert_equal(3, d.seq_last)
call assert_equal(1, d.seq_cur)
call assert_equal(0, d.save_last)
call assert_equal(0, d.save_cur)
call assert_equal(2, len(d.entries))
call assert_equal(1, d.entries[0].seq)
call assert_equal(2, d.entries[1].alt[0].seq)
call assert_equal(1, d.entries[1].curhead)
call assert_equal(1, d.entries[1].newhead)
call assert_equal(3, d.entries[1].seq)
call assert_true(d.entries[1].time == d.time_cur)
w! Xtest
call assert_equal(d.save_last + 1, undotree().save_last)
let d = undotree()
call assert_equal(1, d.save_cur)
call assert_equal(1, d.save_last)
call delete('Xtest')
bwipe Xtest
bwipe! Xtest
endfunc
func FillBuffer()
View
@@ -2863,9 +2863,14 @@ u_undoredo(int undo)
/* Remember where we are for "g-" and ":earlier 10s". */
curbuf->b_u_seq_cur = curhead->uh_seq;
if (undo)
{
/* We are below the previous undo. However, to make ":earlier 1s"
* work we compute this as being just above the just undone change. */
--curbuf->b_u_seq_cur;
if (curhead->uh_next.ptr != NULL)
curbuf->b_u_seq_cur = curhead->uh_next.ptr->uh_seq;
else
curbuf->b_u_seq_cur = 0;
}
/* Remember where we are for ":earlier 1f" and ":later 1f". */
if (curhead->uh_save_nr != 0)
View
@@ -761,6 +761,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
1290,
/**/
1289,
/**/

0 comments on commit 80eaddd

Please sign in to comment.