Return early from Finish functions when buffer is not displayed

When bufwinnr() returns -1, the buffer isn't currently displayed.  In
this case, we need to return so the contents of a different buffer
aren't used for recipients/options.
This commit is contained in:
James McCoy
2020-11-11 13:06:05 -05:00
parent 6b56cdceda
commit 84fc245438

View File

@@ -769,8 +769,14 @@ function s:GPGFinishRecipientsBuffer()
" go to buffer before doing work
if (bufnr("%") != expand("<abuf>"))
let winnr = bufwinnr(expand('<afile>:p'))
if winnr >= 0
" switch to scratch buffer window
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
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
@@ -915,8 +921,14 @@ function s:GPGFinishOptionsBuffer()
" go to buffer before doing work
if (bufnr("%") != expand("<abuf>"))
let winnr = bufwinnr(expand('<afile>:p'))
if winnr >= 0
" switch to scratch buffer window
execute 'silent! ' . bufwinnr(expand("<afile>:p")) . "wincmd w"
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