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 compare other properties when remove block spans #75515

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

Cosifne
Copy link
Member

@Cosifne Cosifne commented Oct 15, 2024

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

Right now you can't call collapse to definition in this case:
collapseToDefinition

It is regressed back in #71064
In that PR we want to support a scenario:

M1(M2(
))

only M2 will be collapsed.
The implementation is to compare the start line of the block span (later it changes to compare both start & end line in #74413)

However, the problem is in the lamda case:

public class YY
{
    public void YX() => System.Linq.Enumerable.Range(10, 100).Any(x =>
    {
        return x == 10;
    });
}

Method YX and lambda

x => {
 return x == 10;
}

generate two block spans with same line start and line end. But AutoCollapse proprety is different,

autoCollapse: !node.IsParentKind(SyntaxKind.LocalFunctionStatement)));

Fix is to also compare other properties in Block span when remove them from the context.

After the PR:
17 12CollapseLambdaFix

@Cosifne Cosifne requested a review from a team as a code owner October 15, 2024 19:21
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Oct 15, 2024
@Cosifne Cosifne merged commit d2e011d into dotnet:main Oct 16, 2024
25 checks passed
@Cosifne Cosifne deleted the dev/shech/FixCollapseToDefinition branch October 16, 2024 18:28
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Oct 16, 2024
Cosifne added a commit to Cosifne/roslyn that referenced this pull request Oct 16, 2024
…efinition

Also compare other properties when remove block spans
@Cosifne Cosifne mentioned this pull request Oct 16, 2024
Cosifne added a commit that referenced this pull request Oct 16, 2024
@akhera99 akhera99 modified the milestones: Next, 17.13 P1 Oct 28, 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 VSCode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants