summaryrefslogtreecommitdiffstats
path: root/src/bufwrite.c
diff options
context:
space:
mode:
authorChristian Brabandt <cb@256bit.org>2021-07-25 14:36:05 +0200
committerBram Moolenaar <Bram@vim.org>2021-07-25 14:36:05 +0200
commit8a4c812ede5b01a8e71082c1ff4ebfcbf1bd515f (patch)
tree2da838678bac4dd3d5fa1681e818517421e0e86b /src/bufwrite.c
parent3ed0d9379683246a77aa8c1a59da7a0ac6395339 (diff)
patch 8.2.3218: when using xchaha20 crypt undo file is not removedv8.2.3218
Problem: When using xchaha20 crypt undo file is not removed. Solution: Reset 'undofile' and delete the file. (Christian Brabandt, closes #8630, closes #8467)
Diffstat (limited to 'src/bufwrite.c')
-rw-r--r--src/bufwrite.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/bufwrite.c b/src/bufwrite.c
index e480e57e7c..a38fb1c0e8 100644
--- a/src/bufwrite.c
+++ b/src/bufwrite.c
@@ -1982,8 +1982,6 @@ restore_backup:
write_info.bw_start_lnum = start;
#ifdef FEAT_PERSISTENT_UNDO
- // TODO: if the selected crypt method prevents the undo file from being
- // written, and existing undo file should be deleted.
write_undo_file = (buf->b_p_udf
&& overwriting
&& !append
@@ -1991,11 +1989,22 @@ restore_backup:
# ifdef CRYPT_NOT_INPLACE
// writing undo file requires
// crypt_encode_inplace()
- && (curbuf->b_cryptstate == NULL
- || crypt_works_inplace(curbuf->b_cryptstate))
+ && (buf->b_cryptstate == NULL
+ || crypt_works_inplace(buf->b_cryptstate))
# endif
&& reset_changed
&& !checking_conversion);
+# ifdef CRYPT_NOT_INPLACE
+ // remove undo file if encrypting it is not possible
+ if (buf->b_p_udf
+ && overwriting
+ && !append
+ && !filtering
+ && !checking_conversion
+ && buf->b_cryptstate != NULL
+ && !crypt_works_inplace(buf->b_cryptstate))
+ u_undofile_reset_and_delete(buf);
+# endif
if (write_undo_file)
// Prepare for computing the hash value of the text.
sha256_start(&sha_ctx);