Karsten Hopp eb6742
To: vim_dev@googlegroups.com
Karsten Hopp eb6742
Subject: Patch 7.3.392
Karsten Hopp eb6742
Fcc: outbox
Karsten Hopp eb6742
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp eb6742
Mime-Version: 1.0
Karsten Hopp eb6742
Content-Type: text/plain; charset=UTF-8
Karsten Hopp eb6742
Content-Transfer-Encoding: 8bit
Karsten Hopp eb6742
------------
Karsten Hopp eb6742
Karsten Hopp eb6742
Patch 7.3.392
Karsten Hopp eb6742
Problem:    When setting 'undofile' while the file is already loaded but
Karsten Hopp eb6742
	    unchanged, try reading the undo file. (Andy Wokula)
Karsten Hopp eb6742
Solution:   Compute a checksum of the text when 'undofile' is set. (Christian
Karsten Hopp eb6742
	    Brabandt)
Karsten Hopp eb6742
Files:	    src/option.c, src/testdir/test72.in, src/testdir/test72.ok
Karsten Hopp eb6742
Karsten Hopp eb6742
Karsten Hopp eb6742
*** ../vim-7.3.391/src/option.c	2011-11-30 11:31:25.000000000 +0100
Karsten Hopp eb6742
--- src/option.c	2012-01-04 19:34:11.000000000 +0100
Karsten Hopp eb6742
***************
Karsten Hopp eb6742
*** 7516,7521 ****
Karsten Hopp eb6742
--- 7516,7545 ----
Karsten Hopp eb6742
  	compatible_set();
Karsten Hopp eb6742
      }
Karsten Hopp eb6742
  
Karsten Hopp eb6742
+ #ifdef FEAT_PERSISTENT_UNDO
Karsten Hopp eb6742
+     /* 'undofile' */
Karsten Hopp eb6742
+     else if ((int *)varp == &curbuf->b_p_udf || (int *)varp == &p_udf)
Karsten Hopp eb6742
+     {
Karsten Hopp eb6742
+ 	char_u	hash[UNDO_HASH_SIZE];
Karsten Hopp eb6742
+ 	buf_T	*save_curbuf = curbuf;
Karsten Hopp eb6742
+ 
Karsten Hopp eb6742
+ 	for (curbuf = firstbuf; curbuf != NULL; curbuf = curbuf->b_next)
Karsten Hopp eb6742
+ 	{
Karsten Hopp eb6742
+ 	    /* When 'undofile' is set globally: for every buffer, otherwise
Karsten Hopp eb6742
+ 	     * only for the current buffer: Try to read in the undofile, if
Karsten Hopp eb6742
+ 	     * one exists and the buffer wasn't changed. */
Karsten Hopp eb6742
+ 	    if ((curbuf == save_curbuf
Karsten Hopp eb6742
+ 				|| (opt_flags & OPT_GLOBAL) || opt_flags == 0)
Karsten Hopp eb6742
+ 		    && !curbufIsChanged())
Karsten Hopp eb6742
+ 	    {
Karsten Hopp eb6742
+ 		u_compute_hash(hash);
Karsten Hopp eb6742
+ 		u_read_undo(NULL, hash, curbuf->b_fname);
Karsten Hopp eb6742
+ 	    }
Karsten Hopp eb6742
+ 	}
Karsten Hopp eb6742
+ 	curbuf = save_curbuf;
Karsten Hopp eb6742
+     }
Karsten Hopp eb6742
+ #endif
Karsten Hopp eb6742
+ 
Karsten Hopp eb6742
      /* 'list', 'number' */
Karsten Hopp eb6742
      else if ((int *)varp == &curwin->w_p_list
Karsten Hopp eb6742
  	  || (int *)varp == &curwin->w_p_nu
Karsten Hopp eb6742
*** ../vim-7.3.391/src/testdir/test72.in	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp eb6742
--- src/testdir/test72.in	2012-01-04 19:04:17.000000000 +0100
Karsten Hopp eb6742
***************
Karsten Hopp eb6742
*** 51,56 ****
Karsten Hopp eb6742
--- 51,62 ----
Karsten Hopp eb6742
  :e Xtestfile
Karsten Hopp eb6742
  uuu:w >>test.out
Karsten Hopp eb6742
  :"
Karsten Hopp eb6742
+ :" Test that reading the undofiles when setting undofile works
Karsten Hopp eb6742
+ :set noundofile ul=0
Karsten Hopp eb6742
+ i
Karsten Hopp eb6742
+ ?u:e! Xtestfile
Karsten Hopp eb6742
+ :set undofile ul=100
Karsten Hopp eb6742
+ uuuuuu:w >>test.out
Karsten Hopp eb6742
  :" And now with encryption, cryptmethod=zip
Karsten Hopp eb6742
  :e! Xtestfile
Karsten Hopp eb6742
  :set undofile cm=zip
Karsten Hopp eb6742
*** ../vim-7.3.391/src/testdir/test72.ok	2010-08-15 21:57:29.000000000 +0200
Karsten Hopp eb6742
--- src/testdir/test72.ok	2012-01-04 19:04:17.000000000 +0100
Karsten Hopp eb6742
***************
Karsten Hopp eb6742
*** 7,12 ****
Karsten Hopp eb6742
--- 7,22 ----
Karsten Hopp eb6742
  eight
Karsten Hopp eb6742
  nine
Karsten Hopp eb6742
  ten
Karsten Hopp eb6742
+ one
Karsten Hopp eb6742
+ two
Karsten Hopp eb6742
+ three
Karsten Hopp eb6742
+ four
Karsten Hopp eb6742
+ five
Karsten Hopp eb6742
+ six
Karsten Hopp eb6742
+ seven
Karsten Hopp eb6742
+ eight
Karsten Hopp eb6742
+ nine
Karsten Hopp eb6742
+ ten
Karsten Hopp eb6742
  monday
Karsten Hopp eb6742
  wednesday
Karsten Hopp eb6742
  thursday
Karsten Hopp eb6742
*** ../vim-7.3.391/src/version.c	2012-01-04 14:35:31.000000000 +0100
Karsten Hopp eb6742
--- src/version.c	2012-01-04 19:33:41.000000000 +0100
Karsten Hopp eb6742
***************
Karsten Hopp eb6742
*** 716,717 ****
Karsten Hopp eb6742
--- 716,719 ----
Karsten Hopp eb6742
  {   /* Add new patch number below this line */
Karsten Hopp eb6742
+ /**/
Karsten Hopp eb6742
+     392,
Karsten Hopp eb6742
  /**/
Karsten Hopp eb6742
Karsten Hopp eb6742
-- 
Karsten Hopp eb6742
BROTHER MAYNARD: Armaments Chapter Two Verses Nine to Twenty One.
Karsten Hopp eb6742
ANOTHER MONK:    And St.  Attila raised his hand grenade up on high saying "O
Karsten Hopp eb6742
                 Lord bless this thy hand grenade that with it thou mayest
Karsten Hopp eb6742
                 blow thine enemies to tiny bits, in thy mercy. "and the Lord
Karsten Hopp eb6742
                 did grin and people did feast upon the lambs and sloths and
Karsten Hopp eb6742
                 carp and anchovies and orang-utans and breakfast cereals and
Karsten Hopp eb6742
                 fruit bats and...
Karsten Hopp eb6742
BROTHER MAYNARD: Skip a bit brother ...
Karsten Hopp eb6742
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
Karsten Hopp eb6742
Karsten Hopp eb6742
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp eb6742
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp eb6742
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp eb6742
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///