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

Fix collapse to definitions for top-level statements #53324

Merged
merged 1 commit into from
May 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Microsoft.CodeAnalysis.CSharp.Syntax;
using Microsoft.CodeAnalysis.Structure;
using Microsoft.CodeAnalysis.Test.Utilities;
using Roslyn.Test.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Structure
Expand Down Expand Up @@ -412,5 +413,23 @@ void M()
await VerifyBlockSpansAsync(code,
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: false));
}

[WorkItem(52493, "https://github.com/dotnet/roslyn/issues/")]
[Fact, Trait(Traits.Feature, Traits.Features.Outlining)]
public async Task LocalFunctionInTopLevelStatement_AutoCollapse()
{
const string code = @"
Foo();
Bar();

{|hint:static void Foo(){|textspan:
{$$
// ...
}|}|}
";

await VerifyBlockSpansAsync(code,
Region("textspan", "hint", CSharpStructureHelpers.Ellipsis, autoCollapse: true));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ protected override void CollectBlockSpans(
isCollapsible: true,
textSpan: GetTextSpan(node),
hintSpan: GetHintSpan(node),
type: type));
type: type,
autoCollapse: parentKind == SyntaxKind.LocalFunctionStatement && node.Parent.IsParentKind(SyntaxKind.GlobalStatement)));
}
}

Expand Down