File: lbdbq-inputlist.diff

package info (click to toggle)
vim-scripts 20130814
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, stretch
  • size: 4,608 kB
  • ctags: 2,511
  • sloc: perl: 452; xml: 95; makefile: 25
file content (31 lines) | stat: -rw-r--r-- 1,152 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
## lbdbq-inputlist.diff by James Vega <jamessan@debian.org>
##
## Correct the use of inputlist's results so the user can press Enter to
## cancel

Index: vim-scripts/plugin/lbdbq.vim
===================================================================
--- vim-scripts.orig/plugin/lbdbq.vim
+++ vim-scripts/plugin/lbdbq.vim
@@ -47,14 +47,17 @@
     if empty(contacts)  " no matching (long) contact found
       return qstring
     elseif len(contacts) > 1  " multiple matches: disambiguate
-      echo "Choose a recipient for '" . qstring . "':"
-      let choices = []
-      let counter = 0
+      let choices = ["Choose a recipient for '" . qstring . "':"]
+      let counter = 1
       for contact in contacts
         let choices += [ printf("%2d. %s <%s>", counter, contact[0], contact[1]) ]
         let counter += 1
       endfor
-      let contact = contacts[inputlist(choices)]
+      let result = inputlist(choices)
+      if result <= 0 || result > len(choices)
+          return a:qstring
+      endif
+      let contact = contacts[result-1]
     else  " len(contacts) == 1, i.e. one single match
       let contact = contacts[0]
     endif