Hi Dmitry!
On Sa, 25 Aug 2012, Dmitry Frank wrote:
> 2012/8/25 Christian Brabandt <[email protected]>
>
> > Hi Dmitry!
> >
> > On Sa, 25 Aug 2012, Dmitry Frank wrote:
> >
> > > Of course, if you close Vim, then change file by another app, then open
> > > this file in Vim again, then, expectedly, undo history should be lost.
> > > But in my example, Vim reloads the changes after file is changed. And, at
> > > this moment, changes aren't lost: *Vim wrote reloaded changes as just a
> > > single change in undohistory*. This is really good, check this.
> > >
> >
> > Yes, this is expected, because when reloading, Vim saves the complete
> > buffer in the undotree and therefore can keep the undo history. See :h
> > 'undoreload'
> >
> > > But if user close Vim now, then these changes is lost.
> >
> > Hm, I guess, you need to save the file first, before quitting. That is
> > indeed a little bit strange.
I think, this patch fixes it.
regards,
Christian
--
Wir sehen in unser Leben doch nur als in ein zerstückeltes
zurück, weil das Versäumte, Misslungene uns immer zuerst
entgegentritt und das Geleistete, Erreichte in der Einbildungskraft
überwiegt.
-- Goethe, Maximen und Reflektionen, Nr. 17
--
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
diff --git a/src/fileio.c b/src/fileio.c
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -7060,8 +7060,22 @@
}
if (reload)
+ {
/* Reload the buffer. */
buf_reload(buf, orig_mode);
+#ifdef FEAT_PERSISTENT_UNDO
+ if (buf->b_p_udf && buf->b_ffname != NULL)
+ {
+ char_u hash[UNDO_HASH_SIZE];
+ buf_T *save_curbuf = curbuf;
+
+ curbuf = buf;
+ u_compute_hash(hash);
+ u_write_undo(NULL, FALSE, buf, hash);
+ curbuf = save_curbuf;
+ }
+#endif
+ }
#ifdef FEAT_AUTOCMD
/* Trigger FileChangedShell when the file was changed in any way. */