diff options
author | Matthew Malcomson <hardenedapple@gmail.com> | 2017-01-26 10:41:05 +0000 |
---|---|---|
committer | Justin M. Keyes <justinkz@gmail.com> | 2017-01-31 05:46:55 +0100 |
commit | d25649fa012013b9ee5b048c8272db4dd50191d6 (patch) | |
tree | e41f2cfe20b1f50668e5bd36a802411eb2742399 /src | |
parent | 39a6f835e779af56ade69e9eb1b4a1981e7032cd (diff) | |
download | rneovim-d25649fa012013b9ee5b048c8272db4dd50191d6.tar.gz rneovim-d25649fa012013b9ee5b048c8272db4dd50191d6.tar.bz2 rneovim-d25649fa012013b9ee5b048c8272db4dd50191d6.zip |
undo: :earlier, g-: Set b_u_seq_cur correctly. (#6016)
Previously alternate branches were not accounted for properly, with this
change g- after an undo to a branch point works.
The current sequence number b_u_seq_cur is used in undo_time(), in
u_doit() this was calculated by subtracting one from the curhead
sequence number.
The curhead header entry represents the change that was just undone, so
the sequence number we want is that of the change we have moved to. This
is the sequence number of the undo head that is the uh_next element of
this curhead. That sequence number is not always one less than the
curhead sequence number -- there may have been an alternate branch at
this point.
Instead of subtracting one, we now directly find the sequence number of
curhead->uh_next.
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/undo.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/nvim/undo.c b/src/nvim/undo.c index 4d56046bc1..129308ad3e 100644 --- a/src/nvim/undo.c +++ b/src/nvim/undo.c @@ -1710,7 +1710,8 @@ bool u_undo_and_forget(int count) if (curbuf->b_u_curhead) { to_forget->uh_alt_next.ptr = NULL; curbuf->b_u_curhead->uh_alt_prev.ptr = to_forget->uh_alt_prev.ptr; - curbuf->b_u_seq_cur = curbuf->b_u_curhead->uh_seq-1; + curbuf->b_u_seq_cur = curbuf->b_u_curhead->uh_next.ptr ? + curbuf->b_u_curhead->uh_next.ptr->uh_seq : 0; } else if (curbuf->b_u_newhead) { curbuf->b_u_seq_cur = curbuf->b_u_newhead->uh_seq; } @@ -2321,7 +2322,8 @@ static void u_undoredo(int undo) 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; + curbuf->b_u_seq_cur = curhead->uh_next.ptr ? + curhead->uh_next.ptr->uh_seq : 0; /* Remember where we are for ":earlier 1f" and ":later 1f". */ if (curhead->uh_save_nr != 0) { |