Thursday, February 23, 2017

Re: Disabling persistent undo for a file mask

Hi RingoRangoRongo!

On Do, 23 Feb 2017, RingoRangoRongo wrote:

> Just confirmed same behaviour with VIM - Vi IMproved 7.3 (vim -u NONE):
>
> :set undolevels=1000
> :set undofile
> :set undodir
> :autocmd BufNewFile,BufRead,BufWrite *.sec setlocal ul=-1
>
> :sav test.sec " no undo file exists
>
> insert random text
>
> :w " undo file appears
>
> insert more random test
>
> :w " undo file disappears
>
> Looks like a bug? :)

Vim will write an undofile (call the internal C function u_write_undo()
for writing the undo file), if the undofile option is set, which it is
in your case. Now you have just set undolevels to -1, but the undo
information is only discarded, if another step has to be saved for undo,
until then the undo information is still kept in memory (and written out
to a file, if you write the file). Once the undo history has been
purged, Vim the internal C function u_write_undo() will skip writing the
file after it has deleted the old file.

Setting 'verbose' to a higher value might also give some clues. The
writeundofile function gives some status then.

Back then when undo persistence was implemented, there were quite some
discussions if one should have another function for discarding the undo
information (there is also a Debian wishlist bug open for that I think).
I think I have even made a patch for that. But in the end it was never
done, because a simple change is enough to purge the undo state (e.g.
https://github.com/chrisbra/histwin.vim/blob/master/autoload/histwin.vim#L1049-L1072)

Best,
Christian
--
Die Wissenschaft ist der Verstand der Welt, die Kunst ihre Seele.
-- Maxim Gorkij

--
--
You received this message from the "vim_use" 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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments: