Skip to content

Commit

Permalink
Merge branch 'edit-option-window' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
jamessan committed Nov 11, 2020
2 parents a72ab0b + 84fc245 commit 3099b04
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
28 changes: 21 additions & 7 deletions autoload/gnupg.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
" Name: autoload/gnupg.vim
" Last Change: 2020 Nov 09
" Last Change: 2020 Nov 11
" Maintainer: James McCoy <[email protected]>
" Original Author: Markus Braun <[email protected]>
" Summary: Vim plugin for transparent editing of gpg encrypted files.
Expand Down Expand Up @@ -685,7 +685,8 @@ function gnupg#edit_recipients()
augroup GPGRecipients
au! * <buffer>
" add a autocommand to regenerate the recipients after a write
autocmd BufHidden,BufUnload,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
autocmd BufHidden,BufWriteCmd <buffer> call s:GPGFinishRecipientsBuffer()
autocmd BufUnload <buffer> exe 'au! GPGRecipients * <buffer='. expand('<abuf>') .'>'
augroup END

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

" go to buffer before doing work
if (bufnr("%") != expand("<abuf>"))
" switch to scratch buffer window
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
let winnr = bufwinnr(expand('<afile>:p'))
if winnr >= 0
" switch to scratch buffer window
execute 'silent! ' . winnr . "wincmd w"
else
call s:GPGDebug(3, '<<<<<<<< Leaving s:GPGFinishRecipientsBuffer() early because buffer is not displayed')
return
endif
endif

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

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

" go to buffer before doing work
if (bufnr("%") != expand("<abuf>"))
" switch to scratch buffer window
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
let winnr = bufwinnr(expand('<afile>:p'))
if winnr >= 0
" switch to scratch buffer window
execute 'silent! ' . winnr . "wincmd w"
else
call s:GPGDebug(3, '<<<<<<<< Leaving s:GPGFinishOptionsBuffer() early because buffer is not displayed')
return
endif
endif

" clear options and unknownOptions
Expand Down
4 changes: 2 additions & 2 deletions plugin/gnupg.vim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
" Name: gnupg.vim
" Last Change: 2020 Nov 09
" Last Change: 2020 Nov 11
" Maintainer: James McCoy <[email protected]>
" Original Author: Markus Braun <[email protected]>
" Summary: Vim plugin for transparent editing of gpg encrypted files.
Expand All @@ -15,7 +15,7 @@
if (exists("g:loaded_gnupg") || &cp || exists("#GnuPG"))
finish
endif
let g:loaded_gnupg = '2.7.0'
let g:loaded_gnupg = '2.7.1-dev'

" check for correct vim version {{{2
if (v:version < 702)
Expand Down

0 comments on commit 3099b04

Please sign in to comment.