Browse Source

Fix line tracking when printing single-line comments.

pull/923/head
Daniel Grunwald 8 years ago
parent
commit
e34480527d
  1. 6
      ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterOutputFormatter.cs
  2. 9
      ILSpy/Languages/CSharpILMixedLanguage.cs

6
ICSharpCode.Decompiler/CSharp/OutputVisitor/TextWriterOutputFormatter.cs

@ -128,7 +128,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -128,7 +128,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
case CommentType.SingleLine:
textWriter.Write("//");
textWriter.WriteLine(content);
column += 2 + content.Length;
column = 1;
line++;
needsIndent = true;
isAtStartOfLine = true;
break;
@ -144,7 +145,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor @@ -144,7 +145,8 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
case CommentType.Documentation:
textWriter.Write("///");
textWriter.WriteLine(content);
column += 3 + content.Length;
column = 1;
line++;
needsIndent = true;
isAtStartOfLine = true;
break;

9
ILSpy/Languages/CSharpILMixedLanguage.cs

@ -1,6 +1,7 @@ @@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Threading;
@ -116,6 +117,14 @@ namespace ICSharpCode.ILSpy @@ -116,6 +117,14 @@ namespace ICSharpCode.ILSpy
void WriteHighlightedCommentLine(ISmartTextOutput output, string text, int startColumn, int endColumn, bool isSingleLine)
{
if (startColumn > text.Length) {
Debug.Fail("startColumn is invalid");
startColumn = text.Length;
}
if (endColumn > text.Length) {
Debug.Fail("endColumn is invalid");
endColumn = text.Length;
}
output.Write("// ");
output.BeginSpan(gray);
if (isSingleLine)

Loading…
Cancel
Save