From 8da3c4e536ae9ef47b1938f16297d9f580e95b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karl=20Yngve=20Lerv=C3=A5g?= Date: Tue, 15 Jul 2014 13:41:12 +0200 Subject: [PATCH] Fixed TOC closest index issue --- autoload/latex/toc.vim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/autoload/latex/toc.vim b/autoload/latex/toc.vim index b96fcc5..60400e6 100644 --- a/autoload/latex/toc.vim +++ b/autoload/latex/toc.vim @@ -34,16 +34,15 @@ function! latex#toc#open() let b:toc_numbers = 1 let b:calling_win = bufwinnr(calling_buf) - " Add TOC entries (keep track of closest index) + " Add TOC entries (and keep track of closest index) let index = 0 let closest_index = 0 for entry in toc call append('$', entry.number . "\t" . entry.title) + let index += 1 - if closest_index == 0 - if calling_file == entry.file && calling_line > entry.line - let closest_index = index - endif + if entry.file == calling_file && entry.line <= calling_line + let closest_index = index endif endfor