Skip to content
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

Region folding. Fix Microsoft/vscode#46591 #84

Merged
merged 2 commits into from
Apr 12, 2018
Merged

Conversation

octref
Copy link
Contributor

@octref octref commented Apr 11, 2018

No description provided.

@@ -92,6 +93,44 @@ export function getFoldingRegions(document: TextDocument): FoldingRangeList {
* All comments are marked as `Comment`
*/
case TokenType.Comment: {
// CSS region folding
if (token.text === '/* #region */') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use a regexp here to allow any number of whitespaces and a description after the 'region'.

assertRanges(input, [r(0, 4, 'region'), r(1, 2)]);
});
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add some tests with incorrect nesting, e.g. the

/* #region */
& .bar {
/* #endregion  */
}

The region should win...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "should win"? Currently this outputs (0, 2) and (1, 2) regions. Is that not the expected result?

I'll just merge what I have in and feel free to open another issue for this one, if this is not what you are expecting.

Copy link
Contributor

@aeschli aeschli Apr 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regions can not intersect. Maybe look at this example:

/* #region */
.bar {
/* #endregion  */
// hello
}

[0,2] and [1,3] would be illegal.
-> once you see the /* #endregion */, discard all open ranges until you see the open /* #region */. The extected result is [0,2]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, will open a new issue to track this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created #85.

@octref octref merged commit 0f7bc59 into master Apr 12, 2018
@octref octref deleted the octref/regionFolding branch April 12, 2018 17:23
@aeschli aeschli added this to the April 2018 milestone Jun 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants