]> granicus.if.org Git - vim/commitdiff
updated for version 7.3.392 v7.3.392
authorBram Moolenaar <Bram@vim.org>
Wed, 4 Jan 2012 18:34:37 +0000 (19:34 +0100)
committerBram Moolenaar <Bram@vim.org>
Wed, 4 Jan 2012 18:34:37 +0000 (19:34 +0100)
Problem:    When setting 'undofile' while the file is already loaded but
            unchanged, try reading the undo file. (Andy Wokula)
Solution:   Compute a checksum of the text when 'undofile' is set. (Christian
            Brabandt)

src/option.c
src/testdir/test72.in
src/testdir/test72.ok
src/version.c

index 65c53ce565c9b9bad0387b6eddb1f63799961fef..f6ed2d3706f978a691e857d5acc4164a93cfce69 100644 (file)
@@ -7516,6 +7516,30 @@ set_bool_option(opt_idx, varp, value, opt_flags)
        compatible_set();
     }
 
+#ifdef FEAT_PERSISTENT_UNDO
+    /* 'undofile' */
+    else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
+    {
+       char_u  hash[UNDO_HASH_SIZE];
+       buf_T   *save_curbuf = curbuf;
+
+       for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
+       {
+           /* When 'undofile' is set globally: for every buffer, otherwise
+            * only for the current buffer: Try to read in the undofile, if
+            * one exists and the buffer wasn't changed. */
+           if ((curbuf == save_curbuf
+                               || (opt_flags & OPT_GLOBAL) || opt_flags == 0)
+                   && !curbufIsChanged())
+           {
+               u_compute_hash(hash);
+               u_read_undo(NULL, hash, curbuf->b_fname);
+           }
+       }
+       curbuf = save_curbuf;
+    }
+#endif
+
     /* 'list', 'number' */
     else if ((int *)varp == &curwin->w_p_list
          || (int *)varp == &curwin->w_p_nu
index 6acb6d8f4acb2ba8e70ce929817d597fb48ad11f..220adad67ac66fe5b1c7e723caad445fa71be200 100644 (file)
@@ -51,6 +51,12 @@ dd:set ul=100
 :e Xtestfile
 uuu:w >>test.out
 :"
+:" Test that reading the undofiles when setting undofile works
+:set noundofile ul=0
+i
+\eu:e! Xtestfile
+:set undofile ul=100
+uuuuuu:w >>test.out
 :" And now with encryption, cryptmethod=zip
 :e! Xtestfile
 :set undofile cm=zip
index 44210c942a50f2f4105ebf7c7be2b284af31c154..bb267d0d8b76c1b65f1c3bb7e21d450824ff26e4 100644 (file)
@@ -7,6 +7,16 @@ seven
 eight
 nine
 ten
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
 monday
 wednesday
 thursday
index d8cf62cf49586975973a585f458725508a67ffa9..fea42774b2e6ff6ffd8acbff5b8e9cba854ce001 100644 (file)
@@ -714,6 +714,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    392,
 /**/
     391,
 /**/