Mercurial > vim
changeset 20415:b582eb6ef192 v8.2.0762
patch 8.2.0762: buffer is not considered modified after setting crypt key
Commit: https://github.com/vim/vim/commit/76cb68309794def0fa7d1f2f72dd694b822186a5
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri May 15 22:30:38 2020 +0200
patch 8.2.0762: buffer is not considered modified after setting crypt key
Problem: Buffer is not considered modified after setting crypt key.
Solution: Set the modified flag. (Christian Brabandt, closes https://github.com/vim/vim/issues/6082)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 15 May 2020 22:45:04 +0200 |
parents | cbf8715299d8 |
children | 5ab2bc28e113 |
files | src/optionstr.c src/testdir/test_crypt.vim src/version.c |
diffstat | 3 files changed, 31 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/optionstr.c +++ b/src/optionstr.c @@ -1157,8 +1157,11 @@ did_set_string_option( if (STRCMP(curbuf->b_p_key, oldval) != 0) // Need to update the swapfile. + { ml_set_crypt_key(curbuf, oldval, *curbuf->b_p_cm == NUL ? p_cm : curbuf->b_p_cm); + changed_internal(); + } } else if (gvarp == &p_cm)
--- a/src/testdir/test_crypt.vim +++ b/src/testdir/test_crypt.vim @@ -110,3 +110,29 @@ func Test_crypt_key_mismatch() bwipe! endfunc +func Test_crypt_set_key_changes_buffer() + + new Xtest1.txt + call setline(1, 'nothing') + set cryptmethod=blowfish2 + call feedkeys(":X\<CR>foobar\<CR>foobar\<CR>", 'xt') + call assert_fails(":q", "E37:") + w + set key=anotherkey + call assert_fails(":bw") + w + call feedkeys(":X\<CR>foobar\<CR>foobar\<CR>", 'xt') + call assert_fails(":bw") + w + let winnr = winnr() + wincmd p + call setwinvar(winnr, '&key', 'yetanotherkey') + wincmd p + call assert_fails(":bw") + w + + set cryptmethod& + set key= + bwipe! + call delete('Xtest1.txt') +endfunc