-
Notifications
You must be signed in to change notification settings - Fork 31k
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
add an explicit based folding strategy #53910
Conversation
The actual 'indentation' strategy is actually 'indentation & predefined markers'. |
@aeschli I agree, for #36002, the pull request need to be reworked. But let's review the current folding strategies:
If we add user markers, we get:
But, the It's about readability of code (even with correctly formatted and commented code). In I hope I was good enough so you can see the advantage to add another strategy 😃 |
Just some food for thought (and clarification on what Besides the indentation based folding strategy, we also have ranges coming from folding range providers. Folding range providers can be added by extensions through code. We have such providers for TypeScript, JSON, CSS... 'auto' means the best available strategy is chosen.
Note that folding range provider have full control of the ranges. Neither indention based ranges nor predefined markers are merged in. Instead, we expect the folding range provider to correctly add ranges for the predefined markers (he has a better understanding of the language and can better detect markers in comments or string literals. You could implement your feature also as a folding range provider. But if another extension also provides folding provider for the language, both will be merged, resulting in the extra nesting that you described above. |
I've tried with an extension (Zokugun Folding) which add user markers (in a quick&dirty way). But with the
I see three ways to resolve those:
The third option would be the best because like you said, the folding range provider has a better understanding of the language. But it would need to be modified to support those new settings. So the second one can be good solution until all folding range providers support the new settings. What do you think? |
I see two ways:
b.
|
I would go with b. It's better than my But I have a question, should the |
I'd have |
Yes, that's fine. What is the next step? |
If you have interest (and time) a PR would be great. Unfortunately, I don't know when I will have cycles to work on it. |
The PR has been submitted and the updated extension is available at zokugun/vscode-explicit-folding. |
} | ||
} | ||
|
||
const length = startIndexes.length; |
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.
Can use destructures
const { length } = startIndexes;
closed in favor of #54200 |
Hello,
I've added an explicit based folding strategy. It can resolve the followings issues: #41633 & #36002.
It can be easily configured like: