Closed swift502 closed 4 years ago
I see the marker list is incomplete. I'll try to address this with a different approach to parsing, so that the performance doesn't get worse with every added language.
I'll make a PR combined with nesting, as it's built upon this branch anyways.
Hi @swift502
It's so nice that someone is interested in this project!!
Even if there is a space between the hashtag and region, it would be better if it was recognized.
I keep finding more things since I started working on this.
VScode has all the functions for recognising regions and their nesting already implemented. I really don't understand why regions aren't displayed in the outline yet.
Every language has a regex for recognising it's region start and end. We can use exactly what VSCode uses to recognise regions for folding. https://github.com/microsoft/vscode/blob/ae245c9b1f06e79cec4829f8cd1555206b0ec8f2/extensions/csharp/language-configuration.json#L26-L31
This might be a valid way to get to the regex expressions directly. I hope extensions can access that information. I'll check when I get home. https://github.com/microsoft/vscode/blob/f74e473238aca7b79c08be761d99a0232838ca4c/src/vs/editor/contrib/folding/indentRangeProvider.ts#L28-L30
@berabue I wanted to make a better PR and abandon this one but ok 😃
I'll make a new PR with both region nesting and other improvements if you agree.
@swift502
Sorry, I am not yet familiar with open source.ðŸ˜
Thanks to you, I am learning hard.
Hi!
I really like your extension! At least until there's an official region outline support.
Here's my proposal for extending it to support all the region markers listed in https://code.visualstudio.com/updates/v1_17#_folding-regions
It should be fairly general. Instead of your
text.includes("#region")
, I opted fortext.trim().startsWith("#region")
to avoid any false positives. I tested it on my Typescript project and various libraries and found no false positives.I also made some subjective changes. Tell me if you don't like some (or either) of these behaviors. No hard feelings. 😄
If there's a region marker with nothing else, the displayed name is still region. I think this is more appealing than simply displaying a "#".
The region names are now trimmed.
I'd love to get this merged. I'll be happy to tweak things based on your feedback. Thanks!