Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incoherent error log when using input #2256

Closed
sgorblex opened this issue Nov 24, 2021 · 4 comments
Closed

Incoherent error log when using input #2256

sgorblex opened this issue Nov 24, 2021 · 4 comments
Labels

Comments

@sgorblex
Copy link

Description

In a project with \input{file}, errors are correctly reported in the errors window with the correct file and line number, whereas warnings report the name of the main file (I'm not sure about the line number). This also effects jumping when typing <CR> on said warning.

Steps to reproduce

I've tried this on both my Arch machines with Neovim and on a fresh Ubuntu docker with Vim (I'll use the latter example as it's simpler).

~/.vimrc:

set nocompatible
set encoding=utf-8

call plug#begin('~/.vim/plugged')
Plug 'lervag/vimtex'
call plug#end()

(only vim-plug and vimtex installed)

The example project has the following two files:
main.tex:

\documentclass{article}
\usepackage{amsmath}

\begin{document}
Lorem ipsum dolor sit amet,
\input{sourceme}
\end{document}

sourceme.tex:

consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
\begin{equation}
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
\end{equation}

Open one of the two .tex and type <leader>cc.

Expected behavior

In the error window:

sourceme.tex|4 warning| Overfull \hbox (130.72998pt too wide) detected at line 4

(and correct jumping)

Actual behavior

main.tex|4 warning| Overfull \hbox (130.72998pt too wide) detected at line 4

(and wrong jumping)

Do you use a latexmkrc file?

No

VimtexInfo

System info
  OS: Linux 5.15.4-arch1-1
  Vim version: VIM 8.1 (1-2269)
  Has clientserver: false

VimTeX project: main
  base: main.tex
  root: /root/project
  tex: /root/project/main.tex
  main parser: current file verified
  document class: article
  packages: amsbsy amsgen amsmath amsopn amstext
  source files:
    main.tex
    sourceme.tex
  compiler: latexmk
    engine: -pdf
    options:
      -verbose
      -file-line-error
      -synctex=1
      -interaction=nonstopmode
    callback: 1
    continuous: 1
    executable: latexmk
    job:
      jobid: process 7912 run
      output: /tmp/v7ahdMp/0
      cmd: max_print_line=2000 latexmk -verbose -file-line-error -synctex=1 -interaction=nonstopmode -pdf -pvc -e '$pdf_previewer = "xdg-open"' -e '$compiling_cmd = ($compiling_cmd ? $compiling_cmd . " ; " : "") . "echo vimtex_compiler_callback_compiling"' -e '$success_cmd = ($success_cmd ? $success_cmd . " ; " : "") . "echo vimtex_compiler_callback_success"' -e '$failure_cmd = ($failure_cmd ? $failure_cmd . " ; " : "") . "echo vimtex_compiler_callback_failure"' 'main.tex'
      pid: 7912
  viewer: General
  qf method: LaTeX logfile
@sgorblex sgorblex added the bug label Nov 24, 2021
@lervag
Copy link
Owner

lervag commented Nov 27, 2021

Thanks! I assume you're the one who mentioned this on reddit. Sorry for the delay in responding; a lot of stuff happening IRL. But I will look into this when I get the time!

stev47 added a commit to stev47/vimtex that referenced this issue Nov 29, 2021
The log pattern for file inclusion does not seem to have a closing
bracket immediately after.
Fixes lervag#2256.
@lervag
Copy link
Owner

lervag commented Nov 29, 2021

I've pushed an improvement now in 2f164ee. It may still require some tweaks, so let me know if you find false positives/negatives.

@lervag lervag closed this as completed Nov 29, 2021
@stev47
Copy link

stev47 commented Nov 30, 2021

Does not seem to work for e.g.

\documentclass{minimal}

\begin{filecontents*}[overwrite]{source.tex}
  \clearpage
  \rule{2\textwidth}{1pt}\par
\end{filecontents*}

\begin{document}
  ~
  \input{source.tex}
\end{document}

where the log contains the lines

(./warnings.aux) (./source.tex [1]
Overfull \hbox (489.75499pt too wide) in paragraph at lines 2--2
[][]
) [2] (./warnings.aux) )

So there can be garbage after the filename.

To be safe one would probably need to parse the log for matching opening and closing parantheses and remember the current file context like e.g. the latexrun compiler does. There may still be non-matching parantheses inside of warnings/errors which can throw you off.

lervag added a commit that referenced this issue Nov 30, 2021
@lervag
Copy link
Owner

lervag commented Nov 30, 2021

We could probably implement a more robust and strict parser, but for now, I think this particular case can be pragmatically handled. If it works now I'll be happy with that, else I'll consider to go for the more robust approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants