mirror of
https://github.com/Ascyii/vim-gnupg.git
synced 2026-01-01 06:14:24 -05:00
Restore cursor position after write.
This commit is contained in:
@@ -280,6 +280,13 @@ endf
|
|||||||
" encrypts the buffer to all previous recipients
|
" encrypts the buffer to all previous recipients
|
||||||
"
|
"
|
||||||
fun s:GPGEncrypt()
|
fun s:GPGEncrypt()
|
||||||
|
" save cursor position
|
||||||
|
let s:GPGCursorPosition = getpos(".")
|
||||||
|
call s:GPGDebug(2, "saved cursor position " . string(s:GPGCursorPosition))
|
||||||
|
|
||||||
|
" switch buffer to binary mode
|
||||||
|
set bin
|
||||||
|
|
||||||
" guard for unencrypted files
|
" guard for unencrypted files
|
||||||
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
||||||
echohl GPGWarning
|
echohl GPGWarning
|
||||||
@@ -358,6 +365,29 @@ fun s:GPGEncrypt()
|
|||||||
return
|
return
|
||||||
endi
|
endi
|
||||||
|
|
||||||
|
endf
|
||||||
|
|
||||||
|
" Function: s:GPGEncryptPost() {{{2
|
||||||
|
"
|
||||||
|
" undo changes don by encrypt, after writing
|
||||||
|
"
|
||||||
|
fun s:GPGEncryptPost()
|
||||||
|
|
||||||
|
if (exists("b:GPGEncrypted") && b:GPGEncrypted == 0)
|
||||||
|
return
|
||||||
|
endi
|
||||||
|
|
||||||
|
" undo encryption of buffer content
|
||||||
|
silent u
|
||||||
|
|
||||||
|
" switch back from binary mode
|
||||||
|
set nobin
|
||||||
|
|
||||||
|
" restore cursor position
|
||||||
|
call setpos('.', s:GPGCursorPosition)
|
||||||
|
call s:GPGDebug(2, "restored cursor position " . string(s:GPGCursorPosition))
|
||||||
|
|
||||||
|
" refresh screen
|
||||||
redraw!
|
redraw!
|
||||||
endf
|
endf
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user