From 7244f48322933317d0f0f4f10517c6a549761b41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Thu, 25 Aug 2016 09:34:06 +0200 Subject: [PATCH] Fixed #531: Error in cite compl. of thebibliography --- autoload/vimtex/complete.vim | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/autoload/vimtex/complete.vim b/autoload/vimtex/complete.vim index 16fb5e7..a199a3a 100644 --- a/autoload/vimtex/complete.vim +++ b/autoload/vimtex/complete.vim @@ -198,16 +198,19 @@ function! s:bib.search(regexp) dict " {{{2 " Find data from 'thebibliography' environments let lines = readfile(b:vimtex.tex) if match(lines, '\C\\begin{thebibliography}') >= 0 - for line in filter(filter(lines, 'v:val =~# ''\C\\bibitem'''), + for line in filter(filter(lines, + \ 'v:val =~# ''\C\\bibitem'''), \ 'v:val =~ a:regexp') - let match = matchlist(line, '\\bibitem{\([^}]*\)')[1] - call add(res, { - \ 'key': match, - \ 'type': '', - \ 'author': '', - \ 'year': '', - \ 'title': match, - \ }) + let matches = matchlist(line, '\\bibitem\(\[[^]]\]\)\?{\([^}]*\)') + if len(matches) > 1 + call add(res, { + \ 'key': matches[2], + \ 'type': '', + \ 'author': '', + \ 'year': '', + \ 'title': matches[2], + \ }) + endif endfor endif