From 874bd187f288fc8d954c1e799e29cd9123dd7402 Mon Sep 17 00:00:00 2001 From: Markus Braun Date: Wed, 23 Jan 2008 08:58:02 +0000 Subject: [PATCH] Made gnupg.vim hopefully encoding safe, needs testing. --- plugin/gnupg.vim | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugin/gnupg.vim b/plugin/gnupg.vim index a3d024d..3910e47 100644 --- a/plugin/gnupg.vim +++ b/plugin/gnupg.vim @@ -297,6 +297,16 @@ fun s:GPGEncrypt() let s:GPGCursorPosition = getpos(".") call s:GPGDebug(2, "saved cursor position " . string(s:GPGCursorPosition)) + " store encoding and switch to a safe one + if &fileencoding != &encoding + let s:GPGEncoding = &encoding + let &encoding = &fileencoding + call s:GPGDebug(2, "encoding was \"" . s:GPGEncoding . "\", switched to \"" . &encoding . "\"") + else + let s:GPGEncoding = "" + call s:GPGDebug(2, "encoding and fileencoding are the same (\"" . &encoding . "\"), not switching") + endi + " switch buffer to binary mode set bin @@ -396,6 +406,12 @@ fun s:GPGEncryptPost() " switch back from binary mode set nobin + " restore encoding + if s:GPGEncoding != "" + let &encoding = s:GPGEncoding + call s:GPGDebug(2, "restored encoding \"" . &encoding . "\"") + endi + " restore cursor position call setpos('.', s:GPGCursorPosition) call s:GPGDebug(2, "restored cursor position " . string(s:GPGCursorPosition))