Minor fixes to toc window open
This commit is contained in:
parent
664a1affc4
commit
c6fe12f646
@ -25,10 +25,10 @@ function! latex#toc#open()
|
|||||||
if g:latex_toc_resize
|
if g:latex_toc_resize
|
||||||
silent exe "set columns+=" . g:latex_toc_width
|
silent exe "set columns+=" . g:latex_toc_width
|
||||||
endif
|
endif
|
||||||
silent exe g:latex_toc_split_side g:latex_toc_width . 'vnew LaTeX\ TOC'
|
|
||||||
|
|
||||||
" Parse TOC data
|
" Parse TOC data
|
||||||
if auxfile == ""
|
if auxfile == ""
|
||||||
|
silent exe g:latex_toc_split_side g:latex_toc_width . 'vnew LaTeX\ TOC'
|
||||||
call append('$', "TeX file not compiled")
|
call append('$', "TeX file not compiled")
|
||||||
else
|
else
|
||||||
let toc = s:read_toc(auxfile, texfile)
|
let toc = s:read_toc(auxfile, texfile)
|
||||||
@ -36,12 +36,14 @@ function! latex#toc#open()
|
|||||||
let b:toc = toc.data
|
let b:toc = toc.data
|
||||||
let b:toc_numbers = 1
|
let b:toc_numbers = 1
|
||||||
let b:calling_win = bufwinnr(calling_buf)
|
let b:calling_win = bufwinnr(calling_buf)
|
||||||
|
silent exe g:latex_toc_split_side g:latex_toc_width . 'vnew LaTeX\ TOC'
|
||||||
|
|
||||||
" Add TOC entries and jump to the closest section
|
" Add TOC entries
|
||||||
for entry in toc.data
|
for entry in toc.data
|
||||||
call append('$', entry['number'] . "\t" . entry['text'])
|
call append('$', entry['number'] . "\t" . entry['text'])
|
||||||
endfor
|
endfor
|
||||||
|
|
||||||
|
" Jump to the closest section
|
||||||
execute 'normal! ' . (closest_index + 1) . 'G'
|
execute 'normal! ' . (closest_index + 1) . 'G'
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -164,7 +166,6 @@ endfunction
|
|||||||
"
|
"
|
||||||
function! s:find_closest_section(toc, file)
|
function! s:find_closest_section(toc, file)
|
||||||
if !has_key(a:toc.fileindices, a:file)
|
if !has_key(a:toc.fileindices, a:file)
|
||||||
echoerr 'File not included in main tex file!'
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -175,11 +176,12 @@ function! s:find_closest_section(toc, file)
|
|||||||
let i = (imax + imin) / 2
|
let i = (imax + imin) / 2
|
||||||
let tocindex = a:toc.fileindices[a:file][i]
|
let tocindex = a:toc.fileindices[a:file][i]
|
||||||
let entry = a:toc.data[tocindex]
|
let entry = a:toc.data[tocindex]
|
||||||
let titlestr = entry['text']
|
let titlestr = substitute(entry['text'],
|
||||||
|
\ '\\\w*\>\s*\%({[^}]*}\)\?', '.*', 'g')
|
||||||
let titlestr = escape(titlestr, '\')
|
let titlestr = escape(titlestr, '\')
|
||||||
let titlestr = substitute(titlestr, ' ', '\\_\\s\\+', 'g')
|
let titlestr = substitute(titlestr, ' ', '\\_\\s\\+', 'g')
|
||||||
let [lnum, cnum]
|
let [lnum, cnum]
|
||||||
\ = searchpos('\\'.entry['level'].'\_\s*{'.titlestr.'}', 'nW')
|
\ = searchpos('\\'.entry['level'].'\_\s*{'.titlestr.'}', 'cnW')
|
||||||
if lnum
|
if lnum
|
||||||
let imax = i
|
let imax = i
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user