summaryrefslogtreecommitdiffstats
path: root/src/option.c
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
commit374d32d70f880651aa5e73371a38c5d0a9ccfaf0 (patch)
tree01aba618ad11352d458ca6974a49f2c63e6b6e0b /src/option.c
parent79a2a49c5a2c973d14923894b63582d749774b94 (diff)
updated for version 7.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)
Diffstat (limited to 'src/option.c')
-rw-r--r--src/option.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/option.c b/src/option.c
index 65c53ce565..f6ed2d3706 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