Permalink
Browse files

fixed insertion of documentation end tags

  • Loading branch information...
1 parent 9b2ae0a commit 424e9f0dbcb074b1e0a39e366a56b641ddb4e921 @siegfriedpammer siegfriedpammer committed Nov 25, 2010
@@ -134,7 +134,7 @@ void FormatLineInternal(ITextEditor editor, int lineNr, int cursorOffset, char c
IDocumentLine currentLine = editor.Document.GetLine(lineNr);
IDocumentLine lineAbove = lineNr > 1 ? editor.Document.GetLine(lineNr - 1) : null;
- string curLineText = editor.Document.Text;
+ string curLineText = currentLine == null ? "" : currentLine.Text;
string lineAboveText = lineAbove == null ? "" : lineAbove.Text;
if (ch == '\'') {
@@ -186,14 +186,16 @@ void FormatLineInternal(ITextEditor editor, int lineNr, int cursorOffset, char c
if (index > 0) {
StringBuilder commentBuilder = new StringBuilder("");
for (int i = index; i < curLineText.Length && i < column && !Char.IsWhiteSpace(curLineText[i]); ++i) {
- commentBuilder.Append(curLineText[ i]);
+ commentBuilder.Append(curLineText[i]);
}
string tag = commentBuilder.ToString().Trim();
if (!tag.EndsWith(">", StringComparison.OrdinalIgnoreCase)) {
tag += ">";
}
if (!tag.StartsWith("/", StringComparison.OrdinalIgnoreCase)) {
- editor.Document.Insert(editor.Caret.Offset, "</" + tag.Substring(1));
+ string endTag = "</" + tag.Substring(1);
+ editor.Document.Insert(editor.Caret.Offset, endTag);
+ editor.Caret.Offset -= endTag.Length;
}
}
}

0 comments on commit 424e9f0

Please sign in to comment.