From d25649fa012013b9ee5b048c8272db4dd50191d6 Mon Sep 17 00:00:00 2001 From: Matthew Malcomson Date: Thu, 26 Jan 2017 10:41:05 +0000 Subject: 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. --- test/functional/ui/inccommand_spec.lua | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'test/functional/ui/inccommand_spec.lua') diff --git a/test/functional/ui/inccommand_spec.lua b/test/functional/ui/inccommand_spec.lua index 41ebfd2334..6da22b6a3a 100644 --- a/test/functional/ui/inccommand_spec.lua +++ b/test/functional/ui/inccommand_spec.lua @@ -352,6 +352,14 @@ describe(":substitute, 'inccommand' preserves undo", function() feed("2u") feed(substring .. "") + expect([[ + 1]]) + feed("g-") + expect([[ + ]]) + feed("g+") + expect([[ + 1]]) feed("") expect([[ 1 @@ -374,9 +382,7 @@ describe(":substitute, 'inccommand' preserves undo", function() 2]]) end - -- TODO(vim): This does not work, even in Vim. - -- Waiting for fix (perhaps from upstream). - pending("at a non-leaf of the undo tree", function() + it("at a non-leaf of the undo tree", function() for _, case in pairs(cases) do for _, str in pairs(substrings) do for _, redoable in pairs({true}) do -- cgit