latex-lsp / texlab

An implementation of the Language Server Protocol for LaTeX
GNU General Public License v3.0
1.55k stars 53 forks source link

Incorrect handling of `\subimport` for multi-file projects. #540

Closed anand-bala closed 2 years ago

anand-bala commented 2 years ago

I am using Neovim's builtin LSP with texlab and I noticed that textDocument/forwardSearch isn't handled properly for when the project contains a sub-file included using \subimport from the import package. This can be reproduced with the following files:

main.tex:

\documentclass[11pt]{article}

\usepackage{import}
\usepackage{lipsum}

\title{Minimal Example}

\begin{document}
\maketitle

\section{Main file}

\lipsum[1]

\subimport{}{stuff}
\end{document}

stuff.tex:

\section{Imported file}

\lipsum[2]

Changing the \subimport{}{stuff} to \input{stuff} makes this work as expected.

There is potentially another problem also, but I will refer you to neovim/nvim-lspconfig#1675 for more details.

pfoerster commented 2 years ago

Thanks for the detailed report! I was able to reproduce the problem on my machine. The fix itself is quite simple (9f778cc).

There is potentially another problem also, but I will refer you to neovim/nvim-lspconfig#1675 for more details.

Thanks for the ping. 432a7d38acef557c986a258875a2129b2133757f should fix this problem.

Please let me know if one of the issues is still present.

anand-bala commented 2 years ago

Wow! Thank you for the really quick fix!

UPDATE:

Turns out the original reason I found this bug still doesn't work correctly 😅 . With the same files, if I run the command for textDocument/forwardSearch, I get an Error response when using \subimport but the command works properly for \input. Note that the only reason I am using \subimport as opposed to \input is that the files are nested.

Thanks for your help!

anand-bala commented 2 years ago

Looks like this is an issue with xelatex not generating the synctex correctly for \subimport. Thanks for the help!