vim: fix some error checking in NM_search_thread_id()
authorBart Trojanowski <bart@jukie.net>
Thu, 26 Nov 2009 00:26:36 +0000 (19:26 -0500)
committerBart Trojanowski <bart@jukie.net>
Thu, 26 Nov 2009 00:27:38 +0000 (19:27 -0500)
vim/plugin/notmuch.vim

index e1822a41c241978bb086b43e03734393019f6360..ade2e45df9a168d4fc09f611e4b04e05be94d4c9 100644 (file)
@@ -351,12 +351,15 @@ function! s:NM_search_thread_id()
         if !exists('b:nm_raw_lines')
                 echoe 'no b:nm_raw_lines'
                 return ''
         if !exists('b:nm_raw_lines')
                 echoe 'no b:nm_raw_lines'
                 return ''
-        else
-                let line = line('.')
-                let info = b:nm_raw_lines[line-1]
-                let what = split(info, '\s\+')[0]
-                return what
         endif
         endif
+        let mnum = line('.') - 1
+        if len(b:nm_raw_lines) <= mnum
+                return ''
+        endif
+        echo 'len=' . string(len(b:nm_raw_lines)) . '  mnum=' . string(mnum)
+        let info = b:nm_raw_lines[mnum]
+        let what = split(info, '\s\+')[0]
+        return what
 endfunction
 
 function! s:NM_search_add_remove_tags(prompt, prefix, intags)
 endfunction
 
 function! s:NM_search_add_remove_tags(prompt, prefix, intags)