Hi Bram!

On Mi, 03 Nov 2010, Bram Moolenaar wrote:

> 
> 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.

Thanks for including it.

> 
> > 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.

Agreed, though the undotree() output is a little bit hard to read if you 
have many many undo branches.

> > 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.

Hm? If I use :undo {N} it moves to any branch that was specified, 
doesn't it?

> 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.

Don't know. But since the undotree() function can gives you all save 
numbers, it would make sense to jump right after that.

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

Thanks. I noticed that when working on the histwin plugin. Though there 
I switched to the undotree() function after patch 7.3.005 (I believe), 
which returns the correct time (and I can format it as needed).

regards,
Christian

-- 
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