summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBram Moolenaar <bram@vim.org>2012-01-04 19:34:37 +0100
committerBram Moolenaar <bram@vim.org>2012-01-04 19:34:37 +0100
commit5290869748352552a93359940820b9ce6a33f8e8 (patch)
treeb40d492420db7253f105cc3914d8be3bc420b83b
parentd7d6f110764ebb62b63225f52ac4e64b4638caee (diff)
downloadvim-5290869748352552a93359940820b9ce6a33f8e8.tar.gz
updated for version 7.3.392v7.3.392v7-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)
-rw-r--r--src/option.c24
-rw-r--r--src/testdir/test72.in6
-rw-r--r--src/testdir/test72.ok10
-rw-r--r--src/version.c2
4 files changed, 42 insertions, 0 deletions
diff --git a/src/option.c b/src/option.c
index 65c53ce5..f6ed2d37 100644
--- a/src/option.c
+++ b/src/option.c
@@ -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
diff --git a/src/testdir/test72.in b/src/testdir/test72.in
index 6acb6d8f..220adad6 100644
--- a/src/testdir/test72.in
+++ b/src/testdir/test72.in
@@ -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
+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
index 44210c94..bb267d0d 100644
--- a/src/testdir/test72.ok
+++ b/src/testdir/test72.ok
@@ -7,6 +7,16 @@ seven
eight
nine
ten
+one
+two
+three
+four
+five
+six
+seven
+eight
+nine
+ten
monday
wednesday
thursday
diff --git a/src/version.c b/src/version.c
index d8cf62cf..fea42774 100644
--- a/src/version.c
+++ b/src/version.c
@@ -715,6 +715,8 @@ static char *(features[]) =
static int included_patches[] =
{ /* Add new patch number below this line */
/**/
+ 392,
+/**/
391,
/**/
390,