James-Yu / LaTeX-Workshop

Boost LaTeX typesetting efficiency with preview, compile, autocomplete, colorize, and more.
MIT License
10.47k stars 519 forks source link

IntelliSense doesn't work when a tex file is read by include command #4252

Closed suikan4github closed 3 months ago

suikan4github commented 3 months ago

Pre-checks*

Environment*

The Issue*

Reproduction Steps

  1. Create demo.tex and fox.tex with the following contents.
  2. Build the document.
  3. Try to write \ref{} command.
  4. The completion works well only when you read the fox.tex with the input command.

Following are the demo file contents.

% demo.tex
\documentclass[a5]{book}

% Book info
\title{Intellisense demo}
\author{foo bar}
\date{\today}

% Body
\begin{document}

% Showing title
\maketitle

% IntelliSense doesn't work
\include{fox.tex}

% IntelliSense does work
%\input{fox.tex}

\end{document}
% fox.tex
\chapter{A quick brown fox}
\label{chap:quick_brown_fox}

A quick brown fox jumps over the lazy dog.

There is a repository that has an entire demo project to reproduce the problem. Run the following commands to clone.

git clone https://github.com/suikan4github/failure-demo.git
cd failure-demo
git checkout latex-workshop-intellisense

Expected Behavior

Screenshots

The IntelliSense fails when a file is read with the include command. include

The IntelliSense works well when a file is read with the input command. The IntelliSense fails when a file is read with the include command. input

Logs

LaTeX Workshop Output*

Please paste the whole log messages below, not parts of ones. The log should start with New log placeholder %WS1% registered.

I could not find the log. 

Developer Tools Console

Please paste the whole log messages below, not parts of ones. This console logs can sometimes be very important in many cases. To access the log, click Help -> Toggle Developer Tools -> Console.

Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/TeX.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/LaTeX.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.bibtex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/Bibtex.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/markdown-latex-combined.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/cpp-grammar-bailout.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope source.cpp.embedded.macro.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/cpp/syntaxes/cpp.embedded.macro.tmLanguage.json.
New grammar file: file:///c%3A/Users/takem/.vscode/extensions/jeff-hykin.better-cpp-syntax-1.17.2/autogenerated/cpp.embedded.macro.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope source.cpp.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/cpp/syntaxes/cpp.tmLanguage.json.
New grammar file: file:///c%3A/Users/takem/.vscode/extensions/jeff-hykin.better-cpp-syntax-1.17.2/autogenerated/cpp.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/TeX.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/LaTeX.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.bibtex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/Bibtex.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/markdown-latex-combined.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/cpp-grammar-bailout.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope source.cpp.embedded.macro.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/cpp/syntaxes/cpp.embedded.macro.tmLanguage.json.
New grammar file: file:///c%3A/Users/takem/.vscode/extensions/jeff-hykin.better-cpp-syntax-1.17.2/autogenerated/cpp.embedded.macro.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope source.cpp.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/cpp/syntaxes/cpp.tmLanguage.json.
New grammar file: file:///c%3A/Users/takem/.vscode/extensions/jeff-hykin.better-cpp-syntax-1.17.2/autogenerated/cpp.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/TeX.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/LaTeX.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.bibtex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/Bibtex.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/markdown-latex-combined.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/cpp-grammar-bailout.tmLanguage.json
register @ ../../../vs/workbenc…nWorker.worker.js:6
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/TeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/TeX.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/LaTeX.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/LaTeX.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.bibtex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/Bibtex.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/Bibtex.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope text.tex.markdown_latex_combined.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/markdown-latex-combined.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/markdown-latex-combined.tmLanguage.json
register @ TMScopeRegistry.ts:46
TMScopeRegistry.ts:46 Overwriting grammar scope name to file mapping for scope source.cpp.embedded.latex.
Old grammar file: file:///c%3A/Program%20Files/Microsoft%20VS%20Code/resources/app/extensions/latex/syntaxes/cpp-grammar-bailout.tmLanguage.json.
New grammar file: vscode-remote://wsl%2Bubuntu-22.04/home/takemasa/.vscode-server/extensions/james-yu.latex-workshop-9.20.0/syntax/cpp-grammar-bailout.tmLanguage.json
register @ TMScopeRegistry.ts:46

Anything Else?

Add any other context about the problem below.

James-Yu commented 3 months ago
image image
suikan4github commented 3 months ago

I have narrowed down the condition of the problem.

Adding the following line to my settings.json caused this problem.

    "latex-workshop.view.outline.commands": [],

The minimum settings.json to reproduce this problem at my environment is :

{
    "latex-workshop.latex.clean.fileTypes": [
        "*.aux",
        "*.bbl",
        "*.blg",
        "*.idx",
        "*.ind",
        "*.lof",
        "*.lot",
        "*.out",
        "*.toc",
        "*.acn",
        "*.acr",
        "*.alg",
        "*.glg",
        "*.glo",
        "*.gls",
        "*.ist",
        "*.fls",
        "*.log",
        "*.fdb_latexmk",
        "*.snm",
        "*.nav",
        "*.dvi",
        "*.synctex.gz"
    ],
    "latex-workshop.latex.outDir": "out",
    "latex-workshop.latex.recipes": [
        {
            "name": "latexmk",
            "tools": [
                "latexmk-process"
            ]
        },
    ],
    "latex-workshop.latex.tools": [
        {
            "name": "latexmk-process",
            "command": "latexmk",
            "args": [
                "-outdir=%OUTDIR%",
                "%DOC%"
            ],
            "env": {}
        }
    ],
    //-----------------------
    "latex-workshop.view.outline.commands": [],
}
abogatskiy commented 3 months ago

I've found that in my case this issue was caused by me deleting "latex-workshop.view.outline.commands": "label" from the settings. Restoring it fixed the issue with Intellisense for references, but obviously now all of these labels are polluting the document outline on the left. Is there a way around this?

Edit: actually I'm realizing that must not be the source of the bug, but only a partial workaround. Intelligence still fails to suggest commands defined in my preamble (separate file). Specifying the root file didn't help.