Mercurial > vim
diff src/bufwrite.c @ 25362:68a7e6d70a5e v8.2.3218
patch 8.2.3218: when using xchaha20 crypt undo file is not removed
Commit: https://github.com/vim/vim/commit/8a4c812ede5b01a8e71082c1ff4ebfcbf1bd515f
Author: Christian Brabandt <cb@256bit.org>
Date: Sun Jul 25 14:36:05 2021 +0200
patch 8.2.3218: when using xchaha20 crypt undo file is not removed
Problem: When using xchaha20 crypt undo file is not removed.
Solution: Reset 'undofile' and delete the file. (Christian Brabandt,
closes #8630, closes #8467)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sun, 25 Jul 2021 14:45:04 +0200 |
parents | 965d97f8208b |
children | d7e1cf30728c |
line wrap: on
line diff
--- 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);