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

Root files #1617

Merged
merged 8 commits into from Oct 17, 2020
Merged

Root files #1617

merged 8 commits into from Oct 17, 2020

Conversation

slideclimb
Copy link
Collaborator

Fix #1612.

Summary of additions and changes

  • Use the document environment to determine root files instead of the document class.
  • Add an inspection that warns you when you have separated the document environment and document class.
  • Introduces a cache to store the root files for each file. Note that it is perfectly fine for LaTeX documents to have multiple root files. Other than the introduction of this cache, TeXiFy does not handle multiple root files anywhere (yet). However, the function PsiFile.findRootFile() is now deprecated in favor of PsiFile.findRootFiles() to encourage/force us to explicitly handle the cases of multiple root files. E.g., including a use package in all root files instead of in just one of the root files.
  • To my knowledge, the root magic comment works fine at the moment, see the example below.

How to test this pull request

  • Verify that stuff that needs the root file still works.
  • Verify that the magic comment works. Create main.tex as below and try the following:
    1. Without the magic root comment: use autocompletion to complete the \includegraphics command. A \usepackage{graphicx} will be inserted in test.tex.
    2. With the magic comment: use autocompletion to complete the \includegraphics command. A \usepackage{graphicx} will be inserted in main.tex.

main.tex

\documentclass{article}

\newcommand{\includebla}[1]{\include{#1}}

\begin{document}
    \includebla{test}
\end{document}

test.tex*

%! root = main.tex
\includegr<caret>

Wiki

@slideclimb slideclimb added this to the b0.7.1 milestone Oct 15, 2020
@slideclimb slideclimb changed the title Root file Root files Oct 15, 2020
Copy link
Collaborator

@PHPirates PHPirates left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive:

\begin{filecontents}{included.tex}
\end{filecontents}

\documentclass[11pt]{article}
\begin{document}
    \section{A title}\label{sec:a-title}
    \input{included.tex}
\end{document}

@PHPirates PHPirates merged commit e3a7946 into master Oct 17, 2020
@PHPirates PHPirates deleted the root-file branch October 17, 2020 08:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Inputting the preamble and the documentclass
2 participants