diff options
author | Mike Krüger <mkrueger@novell.com> | 2010-04-28 16:45:17 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@novell.com> | 2010-04-28 16:45:17 +0400 |
commit | df6b8d04edb85b6712a5936f35f3fad664f6f8c0 (patch) | |
tree | 6ff6ef9d7add0f077b09b3cdd4ba52e613be0f85 /main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates | |
parent | d5173dee43744c8741ec5d958a5abff9250ae595 (diff) |
* MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs: Fixed 'Bug 599684 -
Wrong text link in the 2,3,etc lines of the template'.
svn path=/trunk/monodevelop/; revision=156310
Diffstat (limited to 'main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates')
-rw-r--r-- | main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs index 10109cf004..8552d78465 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.CodeTemplates/CodeTemplate.cs @@ -274,13 +274,23 @@ namespace MonoDevelop.Ide.CodeTemplates } - public string IndentCode (string code, string indent) + public string IndentCode (string code, string eol, string indent) { StringBuilder result = new StringBuilder (); for (int i = 0; i < code.Length; i++) { - result.Append (code[i]); - if (code[i] == '\n') + switch (code[i]) { + case '\r': + if (i + 1 < code.Length && code[i + 1] == '\n') + i++; + goto case '\n'; + case '\n': + result.Append (eol); result.Append (indent); + break; + default: + result.Append (code[i]); + break; + } } return result.ToString (); } @@ -364,7 +374,7 @@ namespace MonoDevelop.Ide.CodeTemplates ParsedDocument = doc, InsertPosition = new DomLocation (line, col), LineIndent = GetIndent (editor, line, 0), - TemplateCode = IndentCode (Code, GetIndent (editor, line, 0)) + TemplateCode = IndentCode (Code, document.TextEditorData.EolMarker, GetIndent (editor, line, 0)) }; if (data.IsSomethingSelected) { @@ -388,12 +398,12 @@ namespace MonoDevelop.Ide.CodeTemplates TemplateResult template = FillVariables (context); template.InsertPosition = offset; - editor.InsertText (offset, template.Code); + document.TextEditorData.Insert (offset, template.Code); if (template.CaretEndOffset >= 0) { - editor.CursorPosition = offset + template.CaretEndOffset; + document.TextEditorData.Caret.Offset = offset + template.CaretEndOffset; } else { - editor.CursorPosition = offset + template.Code.Length; + document.TextEditorData.Caret.Offset= offset + template.Code.Length; } return template; } |