Hi Bram!
On Fr, 23 Dez 2011, Bram Moolenaar wrote:
> Christian Brabandt wrote:
>
> > (reposting, as this message did not show up yet)
> >
> > Hi Bram,
> > this patch fixes this issue from the todo-list:
> >
> > When setting 'undofile' while the file is already loaded, but
> > unchanged, try to read the undo file. Requires computing a checksum
> > of the text. (Andy Wokula)
>
> Very nice. I'll look into it soon.
>
> For bonus points: how about adding a test in testdir/test72.in?
[X] Done
Merry Christmas everybody!
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
diff --git a/src/option.c b/src/option.c
--- a/src/option.c
+++ b/src/option.c
@@ -7516,6 +7516,37 @@
compatible_set();
}
+#ifdef FEAT_PERSISTENT_UNDO
+ /* 'undofile' */
+ else if ((int *)varp == &curbuf->b_p_udf ||
+ (int *)varp == &p_udf)
+ {
+ buf_T *buf = curbuf;
+ char_u hash[UNDO_HASH_SIZE];
+
+ /* set or setglobal udf, iterate overall buffers
+ * and try to read in the undofile, if one exists */
+ if ((opt_flags & OPT_GLOBAL) || !opt_flags)
+ {
+ for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next){
+ if (!curbufIsChanged())
+ {
+ u_compute_hash(hash);
+ u_read_undo(NULL, hash, NULL);
+ }
+ }
+ }
+ else
+ /* setlocal udf, only check for current buffer */
+ if (!curbufIsChanged())
+ {
+ u_compute_hash(hash);
+ u_read_undo(NULL, hash, NULL);
+ }
+ curbuf = buf;
+ }
+#endif
+
/* 'list', 'number' */
else if ((int *)varp == &curwin->w_p_list
|| (int *)varp == &curwin->w_p_nu
diff --git a/src/testdir/test72.in b/src/testdir/test72.in
--- a/src/testdir/test72.in
+++ b/src/testdir/test72.in
@@ -51,6 +51,12 @@
:e Xtestfile
uuu:w >>test.out
:"
+:" Test that reading the undofiles when setting undofile works
+:set noundofile ul=0
+i
+u:e! Xtestfile
+:set undofile ul=100
+uuuuuu:w >>test.out
:" And now with encryption, cryptmethod=zip
:e! Xtestfile
:set undofile cm=zip
diff --git a/src/testdir/test72.ok b/src/testdir/test72.ok
--- a/src/testdir/test72.ok
+++ b/src/testdir/test72.ok
@@ -7,6 +7,16 @@
eight
nine
ten
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
monday
wednesday
thursday