Skip to content

Commit 9b0e3a1

Browse files
Fix folding of local functions, if "Fold all braces" is disabled.
1 parent 9c39e9b commit 9b0e3a1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

ICSharpCode.Decompiler/Output/TextTokenWriter.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@
2222

2323
using ICSharpCode.Decompiler.CSharp;
2424
using ICSharpCode.Decompiler.CSharp.OutputVisitor;
25-
using ICSharpCode.Decompiler.CSharp.Resolver;
2625
using ICSharpCode.Decompiler.CSharp.Syntax;
2726
using ICSharpCode.Decompiler.IL;
2827
using ICSharpCode.Decompiler.Semantics;
2928
using ICSharpCode.Decompiler.TypeSystem;
3029
using ICSharpCode.Decompiler.TypeSystem.Implementation;
30+
using ICSharpCode.Decompiler.Util;
3131

3232
namespace ICSharpCode.Decompiler
3333
{
@@ -255,7 +255,7 @@ public override void WriteToken(Role role, string token)
255255
}
256256
if (braceLevelWithinType >= 0 || nodeStack.Peek() is TypeDeclaration)
257257
braceLevelWithinType++;
258-
if (nodeStack.OfType<BlockStatement>().Count() <= 1 || settings.FoldBraces)
258+
if (nodeStack.PeekOrDefault() is TypeDeclaration or BlockStatement { Parent: EntityDeclaration or LocalFunctionDeclarationStatement or AnonymousMethodExpression or LambdaExpression } || settings.FoldBraces)
259259
{
260260
output.MarkFoldStart(defaultCollapsed: !settings.ExpandMemberDefinitions && braceLevelWithinType == 1, isDefinition: braceLevelWithinType == 1);
261261
}
@@ -265,7 +265,7 @@ public override void WriteToken(Role role, string token)
265265
output.Write('}');
266266
if (role != Roles.RBrace)
267267
break;
268-
if (nodeStack.OfType<BlockStatement>().Count() <= 1 || settings.FoldBraces)
268+
if (nodeStack.PeekOrDefault() is TypeDeclaration or BlockStatement { Parent: EntityDeclaration or LocalFunctionDeclarationStatement or AnonymousMethodExpression or LambdaExpression } || settings.FoldBraces)
269269
output.MarkFoldEnd();
270270
if (braceLevelWithinType >= 0)
271271
braceLevelWithinType--;

0 commit comments

Comments
 (0)