File: lbdbq-inputlist.dpatch

package info (click to toggle)
vim-scripts 20080722-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 4,352 kB
  • ctags: 2,300
  • sloc: perl: 451; sh: 370; xml: 95; makefile: 25
file content (34 lines) | stat: -rw-r--r-- 1,275 bytes parent folder | download
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
32
33
34
#! /bin/sh /usr/share/dpatch/dpatch-run
## lbdbq-inputlist.dpatch by James Vega <jamessan@debian.org>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Correct the use of inputlist's results so the user can press Enter to 
## DP: cancel

@DPATCH@
Index: plugin/lbdbq.vim
===================================================================
--- a/plugin/lbdbq.vim	(revision 1237)
+++ b/plugin/lbdbq.vim	(working copy)
@@ -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