Browse Source

* 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
shortcuts
Mike Krüger 16 years ago
parent
commit
1489bafa98
  1. 12
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/AbstractOutputFormatter.cs
  2. 3
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/OutputFormatter.cs

12
src/Libraries/NRefactory/Project/Src/PrettyPrinter/AbstractOutputFormatter.cs

@ -138,15 +138,23 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -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 @@ -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;

3
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/OutputFormatter.cs

@ -154,7 +154,8 @@ namespace ICSharpCode.NRefactory.PrettyPrinter @@ -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;
}
}

Loading…
Cancel
Save