mirror of
https://github.com/vim/vim.git
synced 2025-11-09 10:37:17 -05:00
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)
This commit is contained in:
@@ -4,22 +4,82 @@
|
|||||||
" Also tests :earlier and :later.
|
" Also tests :earlier and :later.
|
||||||
|
|
||||||
func Test_undotree()
|
func Test_undotree()
|
||||||
exe "normal Aabc\<Esc>"
|
new
|
||||||
|
|
||||||
|
normal! Aabc
|
||||||
set ul=100
|
set ul=100
|
||||||
exe "normal Adef\<Esc>"
|
|
||||||
set ul=100
|
|
||||||
undo
|
|
||||||
let d = undotree()
|
let d = undotree()
|
||||||
call assert_true(d.seq_last > 0)
|
call assert_equal(1, d.seq_last)
|
||||||
call assert_true(d.seq_cur > 0)
|
call assert_equal(1, d.seq_cur)
|
||||||
call assert_true(d.seq_cur < d.seq_last)
|
call assert_equal(0, d.save_last)
|
||||||
call assert_true(len(d.entries) > 0)
|
call assert_equal(0, d.save_cur)
|
||||||
" TODO: check more members of d
|
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
|
||||||
|
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_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
|
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')
|
call delete('Xtest')
|
||||||
bwipe Xtest
|
bwipe! Xtest
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func FillBuffer()
|
func FillBuffer()
|
||||||
|
|||||||
@@ -2863,9 +2863,14 @@ u_undoredo(int undo)
|
|||||||
/* Remember where we are for "g-" and ":earlier 10s". */
|
/* Remember where we are for "g-" and ":earlier 10s". */
|
||||||
curbuf->b_u_seq_cur = curhead->uh_seq;
|
curbuf->b_u_seq_cur = curhead->uh_seq;
|
||||||
if (undo)
|
if (undo)
|
||||||
|
{
|
||||||
/* We are below the previous undo. However, to make ":earlier 1s"
|
/* We are below the previous undo. However, to make ":earlier 1s"
|
||||||
* work we compute this as being just above the just undone change. */
|
* 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". */
|
/* Remember where we are for ":earlier 1f" and ":later 1f". */
|
||||||
if (curhead->uh_save_nr != 0)
|
if (curhead->uh_save_nr != 0)
|
||||||
|
|||||||
@@ -761,6 +761,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
1290,
|
||||||
/**/
|
/**/
|
||||||
1289,
|
1289,
|
||||||
/**/
|
/**/
|
||||||
|
|||||||
Reference in New Issue
Block a user