Fixed bug where toc did not find input file
This commit is contained in:
parent
c6fe12f646
commit
4d73dfda98
@ -55,12 +55,10 @@ function! s:toc_activate(close)
|
|||||||
let titlestr = s:toc_escape_title(entry['text'])
|
let titlestr = s:toc_escape_title(entry['text'])
|
||||||
|
|
||||||
" Search for duplicates
|
" Search for duplicates
|
||||||
"
|
|
||||||
let i=0
|
let i=0
|
||||||
let entry_hash = entry['level'].titlestr
|
let entry_hash = entry['level'].titlestr
|
||||||
let duplicates = 0
|
let duplicates = 0
|
||||||
while i<n
|
while i<n
|
||||||
let i_entry = b:toc[n]
|
|
||||||
let i_hash = b:toc[i]['level'].s:toc_escape_title(b:toc[i]['text'])
|
let i_hash = b:toc[i]['level'].s:toc_escape_title(b:toc[i]['text'])
|
||||||
if i_hash == entry_hash
|
if i_hash == entry_hash
|
||||||
let duplicates += 1
|
let duplicates += 1
|
||||||
@ -72,24 +70,14 @@ function! s:toc_activate(close)
|
|||||||
|
|
||||||
execute b:calling_win . 'wincmd w'
|
execute b:calling_win . 'wincmd w'
|
||||||
|
|
||||||
let bnr = bufnr(entry['file'])
|
let files = [entry['file']]
|
||||||
if bnr == -1
|
for line in filter(readfile(entry['file']), 'v:val =~ ''\\input{''')
|
||||||
execute 'badd ' . entry['file']
|
call add(files, matchstr(line, '{\zs.*\ze\(\.tex\)\?}') . '.tex')
|
||||||
let bnr = bufnr(entry['file'])
|
endfor
|
||||||
endif
|
|
||||||
|
|
||||||
execute 'buffer! ' . bnr
|
" Find section in buffer (or inputted files)
|
||||||
|
call s:toc_find_match('\\' . entry['level'] . '\_\s*{' . titlestr . '}',
|
||||||
" skip duplicates
|
\ duplicates, files)
|
||||||
while duplicates > 0
|
|
||||||
if search('\\' . entry['level'] . '\_\s*{' . titlestr . '}', 'ws')
|
|
||||||
let duplicates -= 1
|
|
||||||
endif
|
|
||||||
endwhile
|
|
||||||
|
|
||||||
if search('\\' . entry['level'] . '\_\s*{' . titlestr . '}', 'ws')
|
|
||||||
normal! zv
|
|
||||||
endif
|
|
||||||
|
|
||||||
if a:close
|
if a:close
|
||||||
if g:latex_toc_resize
|
if g:latex_toc_resize
|
||||||
@ -119,6 +107,42 @@ function! s:toc_escape_title(titlestr)
|
|||||||
return substitute(titlestr, ' ', '\\_\\s\\+', 'g')
|
return substitute(titlestr, ' ', '\\_\\s\\+', 'g')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
" {{{1 s:toc_find_match
|
||||||
|
function! s:toc_find_match(strsearch,duplicates,files)
|
||||||
|
|
||||||
|
call s:toc_open_buf(a:files[0])
|
||||||
|
let dups = a:duplicates
|
||||||
|
|
||||||
|
" Skip duplicates
|
||||||
|
while dups > 0
|
||||||
|
if search(a:strsearch, 'w')
|
||||||
|
let dups -= 1
|
||||||
|
else
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
endwhile
|
||||||
|
|
||||||
|
if search(a:strsearch, 'w')
|
||||||
|
normal! zv
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
|
||||||
|
call s:toc_find_match(a:strsearch,dups,a:files[1:])
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" {{{1 s:toc_open_buf
|
||||||
|
function! s:toc_open_buf(file)
|
||||||
|
|
||||||
|
let bnr = bufnr(a:file)
|
||||||
|
if bnr == -1
|
||||||
|
execute 'badd ' . a:file
|
||||||
|
let bnr = bufnr(a:file)
|
||||||
|
endif
|
||||||
|
execute 'buffer! ' . bnr
|
||||||
|
|
||||||
|
endfunction
|
||||||
|
|
||||||
" {{{1 s:toc_toggle_numbers
|
" {{{1 s:toc_toggle_numbers
|
||||||
function! s:toc_toggle_numbers()
|
function! s:toc_toggle_numbers()
|
||||||
if b:toc_numbers
|
if b:toc_numbers
|
||||||
|
Loading…
x
Reference in New Issue
Block a user