Commits

Anonymous committed c4898d6

updated for version 7.3.392
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)

Comments (0)

Files changed (4)

 	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

src/testdir/test72.in

 :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

src/testdir/test72.ok

 eight
 nine
 ten
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
 monday
 wednesday
 thursday
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    392,
+/**/
     391,
 /**/
     390,