Fixed bug in TOC activate

Bug was reported in LaTeX-Box-Team/LaTeX-Box#165.
This commit is contained in:
Karl Yngve Lervåg 2014-04-13 15:06:06 +02:00
parent 6220f5d1ea
commit 770c902f04

View File

@ -99,16 +99,18 @@ endfunction
" {{{1 s:toc_escape_title " {{{1 s:toc_escape_title
function! s:toc_escape_title(titlestr) function! s:toc_escape_title(titlestr)
" Credit goes to Marcin Szamotulski for the following fix. It allows to let titlestr = substitute(a:titlestr, '\\[a-zA-Z@]*\>\s*{\?', '.*', 'g')
" match through commands added by TeX. let titlestr = substitute(titlestr, '}', '', 'g')
let titlestr = substitute(titlestr, '\%(\.\*\s*\)\{2,}', '.*', 'g')
let titlestr = substitute(a:titlestr, '\\\w*\>\s*\%({[^}]*}\)\?', '.*', 'g') return titlestr
let titlestr = escape(titlestr, '\')
return substitute(titlestr, ' ', '\\_\\s\\+', 'g')
endfunction endfunction
" {{{1 s:toc_find_match " {{{1 s:toc_find_match
function! s:toc_find_match(strsearch, duplicates, files) function! s:toc_find_match(strsearch, duplicates, files)
if len(a:files) == 0
echoerr "Could not find: " . a:strsearch
return
endif
call s:toc_open_buf(a:files[0]) call s:toc_open_buf(a:files[0])
let dups = a:duplicates let dups = a:duplicates
@ -128,19 +130,16 @@ function! s:toc_find_match(strsearch,duplicates,files)
endif endif
call s:toc_find_match(a:strsearch, dups, a:files[1:]) call s:toc_find_match(a:strsearch, dups, a:files[1:])
endfunction endfunction
" {{{1 s:toc_open_buf " {{{1 s:toc_open_buf
function! s:toc_open_buf(file) function! s:toc_open_buf(file)
let bnr = bufnr(a:file) let bnr = bufnr(a:file)
if bnr == -1 if bnr == -1
execute 'badd ' . a:file execute 'badd ' . a:file
let bnr = bufnr(a:file) let bnr = bufnr(a:file)
endif endif
execute 'buffer! ' . bnr execute 'buffer! ' . bnr
endfunction endfunction
" {{{1 s:toc_toggle_numbers " {{{1 s:toc_toggle_numbers