Browse Source

Fixed IndentBlocks bug.

newNRvisualizers
mike 14 years ago
parent
commit
0ff96eaa4c
  1. 3
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  2. 36
      ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs

3
ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs

@ -873,7 +873,8 @@ namespace ICSharpCode.NRefactory.CSharp @@ -873,7 +873,8 @@ namespace ICSharpCode.NRefactory.CSharp
nextStatementIndent = " ";
}
}
if (!(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement ||
if (policy.IndentBlocks &&
!(policy.AlignEmbeddedIfStatements && node is IfElseStatement && node.Parent is IfElseStatement ||
policy.AlignEmbeddedUsingStatements && node is UsingStatement && node.Parent is UsingStatement))
curIndent.Level++;
object result = isBlock ? base.VisitBlockStatement ((BlockStatement)node, null) : node.AcceptVisitor (this, null);

36
ICSharpCode.NRefactory.Tests/FormattingTests/TestStatementIndentation.cs

@ -90,6 +90,42 @@ this.TestMethod (); @@ -90,6 +90,42 @@ this.TestMethod ();
}
}");
}
[Test()]
public void TestIndentBlocksCase2 ()
{
CSharpFormattingOptions policy = new CSharpFormattingOptions ();
policy.IndentBlocks = true;
var adapter = Test (policy,
@"class Test {
Test TestMethod ()
{
if (true) {
Something ();
}
}
}",
@"class Test
{
Test TestMethod ()
{
if (true) {
Something ();
}
}
}");
policy.IndentBlocks = false;
Continue (policy, adapter, @"class Test
{
Test TestMethod ()
{
if (true) {
Something ();
}
}
}");
}
[Test()]
public void TestBreakIndentation ()

Loading…
Cancel
Save