From 1489bafa98957435d3b1ad6bf5146dce7c5fb411 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Fri, 17 Jul 2009 17:07:13 +0000 Subject: [PATCH] * Src/PrettyPrinter/CSharp/OutputFormatter.cs: * Src/PrettyPrinter/AbstractOutputFormatter.cs: Comments that start line are no longer indented when outputting them. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@4474 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Src/PrettyPrinter/AbstractOutputFormatter.cs | 12 ++++++++++-- .../Src/PrettyPrinter/CSharp/OutputFormatter.cs | 3 ++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/AbstractOutputFormatter.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/AbstractOutputFormatter.cs index e0eb97a5e8..f2ab4a4597 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/AbstractOutputFormatter.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/AbstractOutputFormatter.cs @@ -138,15 +138,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter { WriteInPreviousLine(txt + Environment.NewLine, forceWriteInPreviousBlock); } + protected void WriteLineInPreviousLine(string txt, bool forceWriteInPreviousBlock, bool indent) + { + WriteInPreviousLine(txt + Environment.NewLine, forceWriteInPreviousBlock, indent); + } protected void WriteInPreviousLine(string txt, bool forceWriteInPreviousBlock) + { + WriteInPreviousLine(txt, forceWriteInPreviousBlock, true); + } + protected void WriteInPreviousLine(string txt, bool forceWriteInPreviousBlock, bool indent) { if (txt.Length == 0) return; bool lastCharacterWasNewLine = LastCharacterIsNewLine; if (lastCharacterWasNewLine) { if (forceWriteInPreviousBlock == false) { - if (txt != Environment.NewLine) Indent(); + if (indent && txt != Environment.NewLine) Indent(); text.Append(txt); lineBeforeLastStart = lastLineStart; lastLineStart = text.Length; @@ -156,7 +164,7 @@ namespace ICSharpCode.NRefactory.PrettyPrinter } string lastLine = text.ToString(lastLineStart, text.Length - lastLineStart); text.Remove(lastLineStart, text.Length - lastLineStart); - if (txt != Environment.NewLine) { + if (indent && txt != Environment.NewLine) { if (forceWriteInPreviousBlock) ++indentationLevel; Indent(); if (forceWriteInPreviousBlock) --indentationLevel; diff --git a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/OutputFormatter.cs b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/OutputFormatter.cs index 38994a9f33..8f6676d469 100644 --- a/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/OutputFormatter.cs +++ b/src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/OutputFormatter.cs @@ -154,7 +154,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter WriteLineInPreviousLine("///" + comment.CommentText, forceWriteInPreviousBlock); break; default: - WriteLineInPreviousLine("//" + comment.CommentText, forceWriteInPreviousBlock); + // 3 because startposition is start of the text (after the tag) + WriteLineInPreviousLine("//" + comment.CommentText, forceWriteInPreviousBlock, comment.StartPosition.Column != 3); break; } }