From 5a53174d223c40d29b3364f1fe0bdbb245a3a573 Mon Sep 17 00:00:00 2001 From: mike Date: Thu, 3 May 2012 17:11:39 +0200 Subject: [PATCH] [Formatting] Guard against empty changes. --- .../Formatter/AstFormattingVisitor.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs index 444185e240..c0015dfa96 100644 --- a/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs +++ b/ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs @@ -210,6 +210,8 @@ namespace ICSharpCode.NRefactory.CSharp removedChars += document.GetLineByNumber(loc.Line + foundBlankLines - blankLines).EndOffset - document.GetLineByNumber(loc.Line).EndOffset; } + if (removedChars == 0 && sb.Length == 0) + return; AddChange(start, removedChars, sb.ToString()); } @@ -228,6 +230,8 @@ namespace ICSharpCode.NRefactory.CSharp for (int i = 0; i < blankLines; i++) { sb.Append(this.options.EolMarker); } + if (end - start == 0 && sb.Length == 0) + return; AddChange(start, end - start, sb.ToString()); }