James-Yu / LaTeX-Workshop

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

Incorrect syntax highlight for `.dtx` files concerning `\iffalse` #4231

Closed NemoYuan2008 closed 3 months ago

NemoYuan2008 commented 3 months ago

Please fill the following fields with a star (*) and provide as much related information as possible.

Pre-checks*

Please change the following [ ] to [x] for confirmation.

  • [x] The issue has not been reported in this repository.
  • [x] The issue remains after disabling all other extensions and restarting Visual Studio Code.
  • [x] The FAQ cannot address the issue.
  • [x] The issue is not related to compiling a document, or the document can be successfully compiled in the OS terminal but not in Visual Studio Code with this extension.

Environment*

Please write exact version numbers instead of descriptors such as latest.

  • Operating System: Windows 11
  • Visual Studio Code Version: 1.88.1
  • LaTeX Workshop Version: 9.19.2
  • TeX Distribution Version: TeX Live 2024

The Issue*

The syntax highlight is incorrect for the following simple .dtx file, the \fi on line 5 is not matched with \iffalse on line 1. image

% \iffalse meta-comment
%
% Some comments and Copyright info
%
% \fi
%
% \iffalse
%<package>\NeedsTeXFormat{LaTeX2e}
%<package>\ProvidesPackage{mypkg}
%
%<*driver>
\documentclass{ltxdoc}
\begin{document}
\DocInput{⟨package⟩.dtx}
\end{document}
%</driver>
% \fi
%
% \title{Some Title}
% \author{name}
%
% \maketitle
%
% \begin{abstract}
% Some text here.
% \end{abstract}
%
% \section{Introduction}
% Some text here.
%
%    \begin{macrocode}
\newcommand{\YOURMACRO}{}
%    \end{macrocode}

Logs

LaTeX Workshop Output*

[22:17:12.792][Logger] New log placeholder %WS1% registered for d:\Study\restatablethm .
[22:17:12.792][Extension] Initializing LaTeX Workshop.
[22:17:12.934][Build][Recipe] Set $LATEXWORKSHOP_DOCKER_LATEX: ""
[22:17:12.995][Server] Creating LaTeX Workshop http and websocket server.
[22:17:13.066][Format][Bib] Bibtex format config: {"tab":"  ","case":"lowercase","left":"{","right":"}","trailingComma":false,"sort":["key"],"alignOnEqual":true,"sortFields":false,"fieldsOrder":[],"firstEntries":["string","xdata"]}
[22:17:13.116][Server] Server successfully started: {"address":"127.0.0.1","family":"IPv4","port":55722} .
[22:17:13.128][Extension] Extension root: c:\Users\yuan\.vscode\extensions\james-yu.latex-workshop-9.19.2
[22:17:13.128][Extension] $PATH: D:\Program Files (x86)\VMware\VMware Player\bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;d:\Program Files\Git\cmd;D:\Apps\conda;D:\Apps\conda\Library\mingw-w64\bin;D:\Apps\conda\Library\usr\bin;D:\Apps\conda\Library\bin;D:\Apps\conda\Scripts;C:\Users\yuan\AppData\Local\Microsoft\WindowsApps;D:\Program Files\Microsoft VS Code\bin;C:\Users\yuan\AppData\Local\JetBrains\Toolbox\scripts;D:\Program Files\texlive\2024\bin\windows
[22:17:13.129][Extension] $SHELL: undefined
[22:17:13.129][Extension] $LANG: undefined
[22:17:13.129][Extension] $LC_ALL: undefined
[22:17:13.129][Extension] process.platform: win32
[22:17:13.129][Extension] process.arch: x64
[22:17:13.129][Extension] vscode.env.appName: Visual Studio Code
[22:17:13.129][Extension] vscode.env.remoteName: undefined
[22:17:13.129][Extension] vscode.env.uiKind: 1
[22:17:13.132][Config] latex-workshop.latex.recipe.default: "lastUsed" .
[22:17:13.170][Extension] Trigger characters for intellisense of LaTeX documents: ["\\",",","{"]
[22:17:13.171][Root] Current workspace folders: ["file:///d:/Study/restatablethm"]
[22:17:13.171][Extension] LaTeX Workshop initialized.
[22:17:13.172][Root] Found root file from active editor: %WS1%\test.dtx
[22:17:13.172][Root] Root file changed: from %WS1%\test.dtx to %WS1%\test.dtx, langID doctex . Refresh dependencies
[22:17:13.172][Event] ROOT_FILE_CHANGED: "d:\\Study\\restatablethm\\test.dtx"
[22:17:13.173][Cacher][Watcher] Reset.
[22:17:13.173][Cacher][Watcher] Reset.
[22:17:13.175][Cacher] Adding %WS1%\test.dtx .
[22:17:13.175][Cacher][Watcher] Watched %WS1%\test.dtx with a new .* watcher on %WS1% .
[22:17:13.175][Event] FILE_WATCHED: "d:\\Study\\restatablethm\\test.dtx"
[22:17:13.177][Event] ROOT_FILE_SEARCHED
[22:17:13.188][Server] valdOrigin is http://127.0.0.1:55722
suzizecat commented 3 months ago

Hi ! To add on this issue, I encountered the same problem on a .sty file when using the following syntaxes (which are technically the same):

% Simple let
\let\iftoto\iffalse

% Let with indirection
\def\@varname{iftoto}
\expandafter\let\csname\@varname\endcsname\iffalse\relax

I am using:

Cube707 commented 3 months ago

just encountered this myself. this seems to be a regression in v9.19.2

v9.19.1 v9.19.2
jlelong commented 3 months ago

This is related to https://github.com/jlelong/vscode-latex-basics/pull/78. I will look at it shortly.