]> granicus.if.org Git - vim/commitdiff
patch 8.2.0762: buffer is not considered modified after setting crypt key v8.2.0762
authorBram Moolenaar <Bram@vim.org>
Fri, 15 May 2020 20:30:38 +0000 (22:30 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 15 May 2020 20:30:38 +0000 (22:30 +0200)
Problem:    Buffer is not considered modified after setting crypt key.
Solution:   Set the modified flag. (Christian Brabandt, closes #6082)

src/optionstr.c
src/testdir/test_crypt.vim
src/version.c

index 17613a656712f638d32dafbc5d3f662075e2de67..ff0186f429d0bbe1a6659f1ff87a3253d82f7c1d 100644 (file)
@@ -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)
index ab62d84708cd7b3d4fe7e920ab2698e2ddf6ac00..fa26ba5501889b263c93640bdae717362e63ebce 100644 (file)
@@ -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
index c631d54fecc9609a09fa3e40ce4358425976857d..90773d3f9a5543d8a7849cc4572fd8f0341cf4b7 100644 (file)
@@ -746,6 +746,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    762,
 /**/
     761,
 /**/