-
Notifications
You must be signed in to change notification settings - Fork 535
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
Support code folding for DocTeX #4426
Conversation
Thanks for your contribution. Please extend a new doctex folding class for the implementation. It would be fine if you need to make |
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 |
I think it is ready for another review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The original FoldingProvider
class should not contain codes related to DocTeX.
} else if (match[9]) { | ||
keyword = '%<' + match[9] + '>' | ||
} else if (match[10]) { | ||
keyword = '%<' + match[10] + '>' | ||
} else if (match[11] || match[12]) { | ||
keyword = '%\\iffalse meta-comment' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They are only for DocTeX
src/language/folding.ts
Outdated
@@ -2,10 +2,11 @@ import * as vscode from 'vscode' | |||
|
|||
export class FoldingProvider implements vscode.FoldingRangeProvider { | |||
private readonly sectionRegex: RegExp[] = [] | |||
protected readonly envRegex = /\\(begin){(.*?)}|\\(begingroup)[%\s\\]|\\(end){(.*?)}|\\(endgroup)[%\s\\]|^%\s*#?([rR]egion)|^%\s*#?([eE]ndregion)|^%\s*<\*([|_()\-a-zA-Z0-9]+)>|^%\s*<\/([|_()\-a-zA-Z0-9]+)>|^%\s*\\iffalse\s*(meta-comment)|^%\s*\\(fi)/gm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems you add new matches to this regexp. Are they only for DocTeX?
@@ -113,11 +128,12 @@ export class FoldingProvider implements vscode.FoldingRangeProvider { | |||
} | |||
const lastItem = opStack[opStack.length - 1] | |||
|
|||
if ((match[4] || match[6] || match[8]) && lastItem && lastItem.keyword === item.keyword) { // match 'end' with its 'begin' | |||
if ((match[4] || match[6] || match[8] || match[10] || match[12]) && lastItem && lastItem.keyword === item.keyword) { // match 'end' with its 'begin' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above
The |
This pull request enhances the LaTeX-Workshop extension by adding support for VSCode code folding for DocTeX files. The new functionality includes:
% \section{abc}
.%<*abc>
to%</abc>
, whereabc
can be replaced with characters such as|, ',', &, !, -, _, (, )
.% \iffalse meta-comment
to% \fi
.Showcase for the
l3doc
class: