From 161485e8355d492f36f9e01e54321d00199d28de Mon Sep 17 00:00:00 2001 From: James McCoy Date: Sun, 18 Nov 2018 09:57:15 -0500 Subject: [PATCH] Only use ":'[,']w" for FileWriteCmd BufWriteCmd writes the whole buffer, so it can use the bare ":w". Other plugins may manipulate the '[/'] marks on save, which can cause the write with marks to not write the entire buffer. Closes: jamessan/vim-gnupg#96 Signed-off-by: James McCoy --- plugin/gnupg.vim | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/plugin/gnupg.vim b/plugin/gnupg.vim index 8c7b08b..f0f8f52 100644 --- a/plugin/gnupg.vim +++ b/plugin/gnupg.vim @@ -1,5 +1,5 @@ " Name: gnupg.vim -" Last Change: 2018 Aug 06 +" Last Change: 2018 Nov 18 " Maintainer: James McCoy " Original Author: Markus Braun " Summary: Vim plugin for transparent editing of gpg encrypted files. @@ -746,7 +746,12 @@ function s:GPGEncrypt() " encrypt the buffer let destfile = tempname() - let cmd = { 'level': 1, 'ex': "'[,']write !" } + let cmd = { 'level': 1, 'ex': "write !" } + " Only use '[,'] for FileWriteCmd since other plugins may need to change + " them for a normal BufWriteCmd. + if auType == 'FileWrite' + let cmd.ex = "'[,']" . cmd.ex + endif let cmd.args = '--quiet --no-encrypt-to ' . options let cmd.redirect = '>' . s:shellescape(destfile, { 'special': 1, 'cygpath': 1 }) silent call s:GPGExecute(cmd)