James-Yu / LaTeX-Workshop

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

Support code folding for DocTeX #4426

Closed huangyxi closed 1 month ago

huangyxi commented 1 month ago

This pull request enhances the LaTeX-Workshop extension by adding support for VSCode code folding for DocTeX files. The new functionality includes:

  1. Sections Folding: Adds support for folding LaTeX section commands in DocTeX, such as % \section{abc}.
  2. DocStrip Guards Folding: Adds support for folding DocStrip guard ranges with patterns like %<*abc> to %</abc>, where abc can be replaced with characters such as |, ',', &, !, -, _, (, ).
  3. [UPDATED] meta-comment: Adds support for folding DocTeX from % \iffalse meta-comment to % \fi.

Showcase for the l3doc class:

image
James-Yu commented 1 month ago

Thanks for your contribution. Please extend a new doctex folding class for the implementation. It would be fine if you need to make envRegex a class instance variable.

huangyxi commented 1 month ago

Thank you for your response. I have updated the structure of the new DocTeX folding class, and added a new folding pattern that matches from % \iffalse meta-comment to % \fi.

huangyxi commented 1 month ago

I think it is ready for another review.

huangyxi commented 1 month ago

The getEnvironmentFoldingRanges method has been separated into both classes.