texstudio icon indicating copy to clipboard operation
texstudio copied to clipboard

Main document not recognized after automatically creating new included/inputted .tex file from main document

Open Euan-Wall opened this issue 2 years ago • 9 comments

Environment

  • TeXstudio: 4.5.2
  • Qt: 6.5.0
  • OS: Windows 10 Professional 22H2
  • TeX distribution: MikTeX

Expected behavior

At the moment, when using a main document, if user includes or inputs a file that does not exist in the directory, TeXstudio asks if user would like to create that file. The file is created and opened in a new tab, where user can edit it.

Actual behavior

When going directly to the new tab, syntax highlighting which depends on the main file does not work: see screenshot below. Commands which require the main file to be parsed are marked as errors. TeXstudio must be restarted for them to be parsed properly.

image

How to reproduce

  1. Create main.tex or other master file with a minimal preamble (document type).
  2. Type \input{test-file} or \input{test-file}
  3. Navigate to test-file using the sidebar : TeXstudio asks whether to create the file.
  4. Try to use commands like \section in new file.

Euan-Wall avatar Apr 28 '23 07:04 Euan-Wall

can't reproduce with current dev. build. Please try against a dev build.

sunderme avatar Apr 29 '23 07:04 sunderme

I,m having the same Problem

Environment: TeXstudio: 4.5.2 Qt: 6.5.0 OS: Windows 10 TeX distribution: MikTeX

Added Information to the behavior The hole file will compile correctly when compiling the main file

How to reproduce Create main.tex or other master file with a minimal preamble (document type). Include a packet like amsmath and type \input{test-file} Navigate to test-file using the sidebar : TeXstudio asks whether to create the file. Try to use commands that get introduced in the main file like \begin{align*} form the packet amsmath

Jarle28 avatar May 06 '23 10:05 Jarle28

there were some changes in dev to cwls regarding chapter and the like. from then on the completer will recognize \chapter, \section... even in a single new document without any other text. So the question is what about commands from packages? And it seems to me that this isn't working. as said above:

image

A first hint that something may be wrong is the red color of the include name in the structure pane.

Contents of file zzz.tex is:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\input{inc.tex}
\end{document}

octaeder avatar May 06 '23 14:05 octaeder

@sunderme You still can't reproduce? Ensure you closed all tabs before ending txs. Start txt, open new editor, paste Latex code given above (with the \input), click on inc in structure pane, confirm creation of that file, and enter in the file's editor \begin{ali or ali. Use ctrl+alt+space to complete command. But completer won't find align envs. win10, current dev txs.

octaeder avatar May 27 '23 00:05 octaeder

@sunderme As a first note: I see a crash. I try If I can reproduce.

crashed with signal Assert failure: fileName.isEmpty() || pairedFileInfo.isAbsolute() at something in C:/msys64/home/WDAG/texstudio-org/texstudio/src/latexdocument.cpp:112

octaeder avatar May 28 '23 15:05 octaeder

in my build (git 4.6.0alpha1-14-g20b1b8dda) folder a file named file.tex exists (it is from the last test and contains the align* env created with completer). start empty txs and enter in an empty editor (or use wizard):

image

Now click on the label file in the structure pane and txs crashes immediately.

octaeder avatar May 28 '23 17:05 octaeder

crash fixed, but the file doesn't open on click or on context menu (Open Document) in structure and Toc pane:

image

octaeder avatar May 28 '23 19:05 octaeder

that is because an untitled/unsaved file does not have a root path to load an included file.

sunderme avatar May 29 '23 15:05 sunderme

but the file existes as file.tex (sorry, this may not be immediately obvious from the comments): in my build folder a file named file.tex exists

octaeder avatar May 29 '23 16:05 octaeder