Browse Source

Fix folding of local functions, if "Fold all braces" is disabled.

pull/3579/head
Siegfried Pammer 3 months ago
parent
commit
9b0e3a1605
  1. 6
      ICSharpCode.Decompiler/Output/TextTokenWriter.cs

6
ICSharpCode.Decompiler/Output/TextTokenWriter.cs

@ -22,12 +22,12 @@ using System.Linq;
using ICSharpCode.Decompiler.CSharp; using ICSharpCode.Decompiler.CSharp;
using ICSharpCode.Decompiler.CSharp.OutputVisitor; using ICSharpCode.Decompiler.CSharp.OutputVisitor;
using ICSharpCode.Decompiler.CSharp.Resolver;
using ICSharpCode.Decompiler.CSharp.Syntax; using ICSharpCode.Decompiler.CSharp.Syntax;
using ICSharpCode.Decompiler.IL; using ICSharpCode.Decompiler.IL;
using ICSharpCode.Decompiler.Semantics; using ICSharpCode.Decompiler.Semantics;
using ICSharpCode.Decompiler.TypeSystem; using ICSharpCode.Decompiler.TypeSystem;
using ICSharpCode.Decompiler.TypeSystem.Implementation; using ICSharpCode.Decompiler.TypeSystem.Implementation;
using ICSharpCode.Decompiler.Util;
namespace ICSharpCode.Decompiler namespace ICSharpCode.Decompiler
{ {
@ -255,7 +255,7 @@ namespace ICSharpCode.Decompiler
} }
if (braceLevelWithinType >= 0 || nodeStack.Peek() is TypeDeclaration) if (braceLevelWithinType >= 0 || nodeStack.Peek() is TypeDeclaration)
braceLevelWithinType++; braceLevelWithinType++;
if (nodeStack.OfType<BlockStatement>().Count() <= 1 || settings.FoldBraces) if (nodeStack.PeekOrDefault() is TypeDeclaration or BlockStatement { Parent: EntityDeclaration or LocalFunctionDeclarationStatement or AnonymousMethodExpression or LambdaExpression } || settings.FoldBraces)
{ {
output.MarkFoldStart(defaultCollapsed: !settings.ExpandMemberDefinitions && braceLevelWithinType == 1, isDefinition: braceLevelWithinType == 1); output.MarkFoldStart(defaultCollapsed: !settings.ExpandMemberDefinitions && braceLevelWithinType == 1, isDefinition: braceLevelWithinType == 1);
} }
@ -265,7 +265,7 @@ namespace ICSharpCode.Decompiler
output.Write('}'); output.Write('}');
if (role != Roles.RBrace) if (role != Roles.RBrace)
break; break;
if (nodeStack.OfType<BlockStatement>().Count() <= 1 || settings.FoldBraces) if (nodeStack.PeekOrDefault() is TypeDeclaration or BlockStatement { Parent: EntityDeclaration or LocalFunctionDeclarationStatement or AnonymousMethodExpression or LambdaExpression } || settings.FoldBraces)
output.MarkFoldEnd(); output.MarkFoldEnd();
if (braceLevelWithinType >= 0) if (braceLevelWithinType >= 0)
braceLevelWithinType--; braceLevelWithinType--;

Loading…
Cancel
Save