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

Also checking line end when block structure is filtered #74413

Merged
merged 2 commits into from
Jul 18, 2024

Conversation

Cosifne
Copy link
Member

@Cosifne Cosifne commented Jul 17, 2024

Fix https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2094051

Reason:
In PR #71064, it introduced a trick to only fold the inner method2 in this case:

Method1(Method2(
))

Method1's block is skipped because it has the same start line as Method2

However this introduce problem because in this case

        If str.Contains("foo") Then

        End If

In VB, we first provide the block structure of If, also we provide the block structure for foo because it is a string literal https://github.com/dotnet/roslyn/blob/release/dev17.10/src/Features/CSharp/Portable/Structure/Providers/StringLiteralExpressionStructureProvider.cs

Because foo and If statement both have the same start line, If statement is removed from the block structure span.

Later, because foo's structure is removed because its start line and end line are same.

Fix:
Instead of only checking for the start line, also check the end line when trying to remove the block. It should still work for case

Method1(Method2(
))

the block structure of Method1 would still be removed. and it's safer when dealing with other cases.

Before:
image

After:
image

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Jul 17, 2024
@Cosifne Cosifne marked this pull request as ready for review July 17, 2024 19:14
@Cosifne Cosifne requested a review from a team as a code owner July 17, 2024 19:14
@CyrusNajmabadi
Copy link
Member

Can you show a picture showing how the user experience has changed? Thanks!

@Cosifne
Copy link
Member Author

Cosifne commented Jul 17, 2024

Can you show a picture showing how the user experience has changed? Thanks!

Editing now...

@@ -72,6 +72,7 @@ public async Task IdentifierThatLooksLikeCode()

await VerifyBlockSpansAsync(code,
Region("textspan3", "/* now everything is commented (); ...", autoCollapse: true),
Region("textspan2", "hint2", CSharpStructureHelpers.Ellipsis, autoCollapse: false),
Copy link
Member Author

Choose a reason for hiding this comment

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

@Cosifne Cosifne merged commit 4f51b73 into dotnet:main Jul 18, 2024
25 checks passed
@Cosifne Cosifne deleted the dev/shech/FixMissingCollapse branch July 18, 2024 18:24
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Jul 18, 2024
arunchndr pushed a commit that referenced this pull request Jul 22, 2024
Also checking line end when block structure is filtered
arunchndr pushed a commit that referenced this pull request Jul 22, 2024
Also checking line end when block structure is filtered
arunchndr pushed a commit that referenced this pull request Jul 22, 2024
Also checking line end when block structure is filtered
@RikkiGibson RikkiGibson modified the milestones: Next, 17.12 P1 Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants