texstudio-org / texstudio

TeXstudio is a fully featured LaTeX editor. Our goal is to make writing LaTeX documents as easy and comfortable as possible.
http://www.texstudio.org/
GNU General Public License v3.0
2.85k stars 346 forks source link

Find Usages+Replace all changes hidden files which will not be saved #3865

Open octaeder opened 3 weeks ago

octaeder commented 3 weeks ago

Environment

Expected behavior

After replacing labels in hidden files these files should be saved when compiling or using save all

Actual behavior

When I open a root document with a label and use Find Usages (context menu) the search results can be changed by using Replace all. This can affect hidden files. In this case the changed label there will not take effect because compiling will not save the hidden file. Also using Save All will not save it. Thus latex will throw missing label messages.

How to reproduce

root:

\documentclass{article}
\begin{document}
\input{a1}
$\sqrt{2}$\ref{sec:root-inline}
\end{document}

a1.tex:

\section{root inline}\label{sec:root-inline}
$\sqrt{2}$
muzimuzhi commented 3 weeks ago

What do you meant "hidden files", .aux files? Or sub files loaded by the root one?

octaeder commented 3 weeks ago

txs scans the document tree (included files) beginning from the root (depending on options set). The root is an open file, maybe you have opened other included files. All other files are opened by txs as hidden files. You can open a list of opened files as well as a list of hidden files:

image

dbitouze commented 3 weeks ago

How to reproduce

@octaeder BTW, when you want to provide an example of a main file and one or several subfiles, you can do that as a self content file thanks to the filecontents environment:

\begin{filecontents}[overwrite]{a1.tex}
\section{root inline}\label{sec:root-inline}
$\sqrt{2}$
\end{filecontents}

\documentclass{article}
\begin{document}
\input{a1}
$\sqrt{2}$\ref{sec:root-inline}
\end{document}
octaeder commented 3 weeks ago

@dbitouze Nice feature, but obviously this is one file for txs and hence there is no hidden file.

octaeder commented 3 weeks ago

I think this is fixed with yesterdays commits