From 9329403402f9d1a3160daa54d0633b62fb1f2b96 Mon Sep 17 00:00:00 2001 From: James McCoy Date: Wed, 30 May 2012 23:48:43 -0400 Subject: [PATCH] GPGFinishRecipientsBuffer: Use the GPG ID, if present, to avoid repeat prompts Whenever GPGFinishRecipientsBuffer is called, the buffer is processed to convert names to IDs. However, this was ignoring any existing ID information in the buffer. This meant that if a person had multiple keys, the user would be prompted to disambiguate the keys after every :GPGEditRecipients session. Parsing the ID out of the recipients buffer avoids the unnecessary prompting. Signed-off-by: James McCoy --- plugin/gnupg.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugin/gnupg.vim b/plugin/gnupg.vim index c6430f8..3325901 100644 --- a/plugin/gnupg.vim +++ b/plugin/gnupg.vim @@ -796,13 +796,13 @@ function s:GPGFinishRecipientsBuffer() " delete the autocommand autocmd! * - " get the recipients from the scratch buffer let recipients = [] let lines = getline(1,"$") for recipient in lines - " delete all text after magic string - let recipient = substitute(recipient, s:GPGMagicString . ".*$", "", "") + let matches = matchlist(recipient, '^\(.\{-}\)\%(' . s:GPGMagicString . '(ID:\s\+\(' . s:keyPattern . '\)\s\+.*\)\=$') + + let recipient = matches[2] ? matches[2] : matches[1] " delete all spaces at beginning and end of the recipient " also delete a '!' at the beginning of the recipient