Christian Brabandt wrote:

> Hi Bram,
> here are 3 patches that improve the undo-persistence.
> 
> Patch [1] sets the current save number to the last save number after 
> loading a file (see how 'save_cur' in the undotree() function is set to 
> zero after loading a file while it should probably be the same as 
> 'save_last'; compare this to how 'save_cur' changes after going back one 
> step in the undotree and return to the original state [e.g. after g-g+ 
> 'save_cur' is the same as 'save_last'])

That looks good.  Now after loading a file ":earlier 1f" goes to the
last-but-one saved state.

> Patch [2] Lets changenr() return the current save_nr, if the optional 
> argument save_nr is given and is one.
> Currently, it is not possible to know after which save nr the buffer is, 
> after moving around in the undo tree and :later <nr>f and :earlier <nr>f 
> jump around only relative to the current save marks. So to decide what 
> <nr> should be, one needs to know, after which save_nr the current 
> buffer is.

Why do this with an argument?  It makes more sense to add a new function
for this.  Although the "save_cur" entry returned by undotree() already
has this number.  It would be rarely used, thus a separate function
isn't really needed.

> Patch [3] :earlier <nr>f and :later <nr>f only move relative to the 
> current save number of the buffer. I think it would be nice to jump 
> right to the actual save number, as it is output with :undolist.
> This patch implements :undo <nr>f to let you jump right after the 
> specified save number. (Please verify, that the traversing the undo-tree 
> structure works as it is supposed to be. I am not sure this is correct, 
> though it seems to work)

The :undo command only moves in the current undo branch. This would make
it go to different branches, I don't like that.

Copying the logic to find the position in the undo tree is not a good
idea.  Let's keep this in undo_time().  Setting "target" to the right
value seems the only thing needed there.

On the other hand, does a user really remember the absolute save number?
Even the one from :undolist is not clear about what the state of the
text was.  It only mentions the last save in a branch.

I notice that ":undolist" only mentions the time, but now we have
persistent undo that may be several days ago.  I'll fix that.


-- 
       [Autumn changed into Winter ... Winter changed into Spring ...  Spring
       changed back into Autumn and Autumn gave Winter and Spring a miss and
       went straight on into Summer ...  Until one day ...]
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Raspunde prin e-mail lui