Skip to content

Commit 3099b04

Browse files
committed
Merge branch 'edit-option-window' into main
2 parents a72ab0b + 84fc245 commit 3099b04

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

autoload/gnupg.vim

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" Name: autoload/gnupg.vim
2-
" Last Change: 2020 Nov 09
2+
" Last Change: 2020 Nov 11
33
" Maintainer: James McCoy <jamessan@jamessan.com>
44
" Original Author: Markus Braun <markus.braun@krawel.de>
55
" Summary: Vim plugin for transparent editing of gpg encrypted files.
@@ -685,7 +685,8 @@ function gnupg#edit_recipients()
685685
augroup GPGRecipients
686686
au! * <buffer>
687687
" add a autocommand to regenerate the recipients after a write
688-
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
688+
autocmd BufHidden,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
689+
autocmd BufUnload <buffer> exe 'au! GPGRecipients * <buffer='. expand('<abuf>') .'>'
689690
augroup END
690691

691692
" put some comments to the scratch buffer
@@ -768,8 +769,14 @@ function s:GPGFinishRecipientsBuffer()
768769

769770
" go to buffer before doing work
770771
if (bufnr("%") != expand("<abuf>"))
771-
" switch to scratch buffer window
772-
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
772+
let winnr = bufwinnr(expand('<afile>:p'))
773+
if winnr >= 0
774+
" switch to scratch buffer window
775+
execute 'silent! ' . winnr . "wincmd w"
776+
else
777+
call s:GPGDebug(3, '<<<<<<<< Leaving s:GPGFinishRecipientsBuffer() early because buffer is not displayed')
778+
return
779+
endif
773780
endif
774781

775782
" get the recipients from the scratch buffer
@@ -861,7 +868,8 @@ function gnupg#edit_options()
861868
augroup GPGOptions
862869
au! * <buffer>
863870
" add a autocommand to regenerate the options after a write
864-
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
871+
autocmd BufHidden,BufWriteCmd <buffer> call s:GPGFinishOptionsBuffer()
872+
autocmd BufUnload <buffer> exe 'au! GPGOptions * <buffer='. expand('<abuf>') .'>'
865873
augroup END
866874

867875
" put some comments to the scratch buffer
@@ -913,8 +921,14 @@ function s:GPGFinishOptionsBuffer()
913921

914922
" go to buffer before doing work
915923
if (bufnr("%") != expand("<abuf>"))
916-
" switch to scratch buffer window
917-
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
924+
let winnr = bufwinnr(expand('<afile>:p'))
925+
if winnr >= 0
926+
" switch to scratch buffer window
927+
execute 'silent! ' . winnr . "wincmd w"
928+
else
929+
call s:GPGDebug(3, '<<<<<<<< Leaving s:GPGFinishOptionsBuffer() early because buffer is not displayed')
930+
return
931+
endif
918932
endif
919933

920934
" clear options and unknownOptions

plugin/gnupg.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
" Name: gnupg.vim
2-
" Last Change: 2020 Nov 09
2+
" Last Change: 2020 Nov 11
33
" Maintainer: James McCoy <jamessan@jamessan.com>
44
" Original Author: Markus Braun <markus.braun@krawel.de>
55
" Summary: Vim plugin for transparent editing of gpg encrypted files.
@@ -15,7 +15,7 @@
1515
if (exists("g:loaded_gnupg") || &cp || exists("#GnuPG"))
1616
finish
1717
endif
18-
let g:loaded_gnupg = '2.7.0'
18+
let g:loaded_gnupg = '2.7.1-dev'
1919

2020
" check for correct vim version {{{2
2121
if (v:version < 702)

0 commit comments

Comments
 (0)