Skip to content

Commit

Permalink
feat: improve overflow/underflow qf parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
lervag committed Nov 29, 2021
1 parent d9e05f5 commit 2f164ee
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 22 deletions.
9 changes: 8 additions & 1 deletion autoload/vimtex/qf/latexlog.vim
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,16 @@ function! s:fix_paths_hbox_warning(qf, log, root) abort " {{{1
let l:index = match(a:log, '\V' . escape(a:qf.text, '\'))
if l:index < 0 | return v:false | endif

let l:file = matchstr(a:log[l:index - 1], '^\s*(\zs\f\+\ze)\s*$')
" Search for a line above the Overflow/Underflow message that specifies the
" correct source filename
for l:lnum in range(l:index - 1, 1, -1)
let l:file = matchstr(a:log[l:lnum], '(\zs\f\+\ze)\?\s*$')
if !empty(l:file) | break | endif
endfor

if empty(l:file) | return v:false | endif

" Do some simple parsing and cleanup of the filename
if !vimtex#paths#is_abs(l:file)
let l:file = simplify(a:root . '/' . l:file)
endif
Expand Down
60 changes: 42 additions & 18 deletions test/test-quickfix-fix-path/main.log
Original file line number Diff line number Diff line change
@@ -1,24 +1,29 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.16 (TeX Live 2015/Arch Linux) (preloaded format=pdflatex 2015.11.16) 20 NOV 2015 09:29
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/Arch Linux) (preloaded format=pdflatex 2021.5.25) 29 NOV 2021 22:44
entering extended mode
\write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**main.tex
(./main.tex
LaTeX2e <2015/10/01> patch level 2
Babel <3.9m> and hyphenation patterns for 79 languages loaded.
(/usr/share/texmf-dist/tex/latex/base/minimal.cls
LaTeX2e <2020-10-01> patch level 4
L3 programming layer <2021-02-18> (/usr/share/texmf-dist/tex/latex/base/minimal.cls
Document Class: minimal 2001/05/25 Standard LaTeX minimal class
) (./main.aux)
) (/usr/share/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def
File: l3backend-pdftex.def 2021-03-18 L3 backend support: PDF output (pdfTeX)
\l__color_backend_stack_int=\count179
\l__pdf_internal_box=\box47
) (./main.aux (./test.aux))
\openout1 = `main.aux'.

LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 2.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 2.
LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 2.
LaTeX Font Info: ... okay on input line 2.
Expand All @@ -44,20 +49,39 @@ misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.

) [1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}] (./main.aux) )
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <7> on input line 4.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <5> on input line 4.

Overfull \hbox (5.97499pt too wide) detected at line 6
\OML/cmm/m/it/10 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
[]

) [1{/var/lib/texmf/fonts/map/pdftex/updmap/pdftex.map}]
\openout2 = `test-new.aux'.

(./test-new.tex)
Overfull \hbox (550.24501pt too wide) in paragraph at lines 3--5
[]
[]

[2

] (./main.aux (./test-new.aux)) )
Here is how much of TeX's memory you used:
22 strings out of 493054
359 string characters out of 6140585
53374 words of memory out of 5000000
3632 multiletter control sequences out of 15000+600000
3640 words of font info for 14 fonts, out of 8000000 for 9000
209 strings out of 478994
5029 string characters out of 5864751
286933 words of memory out of 5000000
17771 multiletter control sequences out of 15000+600000
403430 words of font info for 27 fonts, out of 8000000 for 9000
1141 hyphenation exceptions out of 8191
14i,4n,10p,124b,92s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on main.pdf (1 page, 10101 bytes).
38i,4n,46p,133b,85s stack positions out of 5000i,500n,10000p,200000b,80000s
</usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmmi10.pfb></usr/share/texmf-dist/fonts/type1/public/amsfonts/cm/cmr10.pfb>
Output written on main.pdf (2 pages, 20997 bytes).
PDF statistics:
12 PDF objects out of 1000 (max. 8388607)
7 compressed objects within 1 object stream
19 PDF objects out of 1000 (max. 8388607)
12 compressed objects within 1 object stream
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)

1 change: 1 addition & 0 deletions test/test-quickfix-fix-path/main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
\begin{document}
\errorcommand{blah}
\input{test.tex}
\include{test-new}
\end{document}
3 changes: 3 additions & 0 deletions test/test-quickfix-fix-path/test-new.tex
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
More sample text

\hspace{1000pt}
4 changes: 3 additions & 1 deletion test/test-quickfix-fix-path/test.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

\anothererrorcommand{blah}


\begin{equation}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{equation}

6 changes: 4 additions & 2 deletions test/test-quickfix-fix-path/test.vim
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ catch /VimTeX: No log file found/
endtry

let s:qf = getqflist()
call assert_true(len(s:qf) == 2)
call assert_equal(bufname(s:qf[1].bufnr), './test.tex')"}}}
call assert_equal(4, len(s:qf))
call assert_equal('./test.tex', bufname(s:qf[1].bufnr))
call assert_equal('./test.tex', bufname(s:qf[2].bufnr))
call assert_equal('test-new.tex', bufname(s:qf[3].bufnr))

call vimtex#test#finished()

0 comments on commit 2f164ee

Please sign in to comment.