diff options
author | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@xamarin.com> | 2015-04-20 19:07:51 +0300 |
commit | 95408b1a41b31b645f3a8c3323ab7d3ca4bff26b (patch) | |
tree | f8f137cddcb9a40499d303be95722fd2c6081bce /main/src/addins/ChangeLogAddIn/ChangeLogAddIn.cs | |
parent | b70e4e04b4e41b8ec28d7e4b220b401ecf467e7a (diff) | |
parent | de043d330a8bf5855d4d983c804cd36727cb2406 (diff) |
Merge remote-tracking branch 'origin/roslyn' into new-project-model
Diffstat (limited to 'main/src/addins/ChangeLogAddIn/ChangeLogAddIn.cs')
-rw-r--r-- | main/src/addins/ChangeLogAddIn/ChangeLogAddIn.cs | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.cs b/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.cs index af7840f2b4..5bfcd63773 100644 --- a/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.cs +++ b/main/src/addins/ChangeLogAddIn/ChangeLogAddIn.cs @@ -35,6 +35,7 @@ using MonoDevelop.Ide.Gui; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.Gui.Pads.ProjectPad; using MonoDevelop.Ide; +using MonoDevelop.Ide.Editor; namespace MonoDevelop.ChangeLogAddIn { @@ -80,7 +81,7 @@ namespace MonoDevelop.ChangeLogAddIn static void InsertEntry(Document document) { - IEditableTextBuffer textBuffer = document.GetContent<IEditableTextBuffer>(); + var textBuffer = document.GetContent<TextEditor>(); if (textBuffer == null) return; string changeLogFileName = document.FileName; @@ -98,16 +99,16 @@ namespace MonoDevelop.ChangeLogAddIn textBuffer.InsertText (insertPos, text); insertPos += text.Length; - textBuffer.Select (insertPos, insertPos); - textBuffer.CursorPosition = insertPos; - + textBuffer.CaretOffset = insertPos; + textBuffer.SetSelection (insertPos, insertPos); + document.Select (); } } static bool InsertHeader (Document document) { - IEditableTextBuffer textBuffer = document.GetContent<IEditableTextBuffer>(); + var textBuffer = document.Editor; if (textBuffer == null) return false; AuthorInformation userInfo = document.Project != null ? document.Project.AuthorInformation : AuthorInformation.Default; @@ -126,19 +127,19 @@ namespace MonoDevelop.ChangeLogAddIn // Read the first line and compare it with the header: if they are // the same don't insert a new header. int pos = GetHeaderEndPosition(document); - if (pos < 0 || (pos + 2 > textBuffer.Length) || textBuffer.GetText (0, pos + 2) != text) + if (pos < 0 || (pos + 2 > textBuffer.Length) || textBuffer.GetTextAt (0, pos + 2) != text) textBuffer.InsertText (0, text); return true; } static int GetHeaderEndPosition(Document document) { - IEditableTextBuffer textBuffer = document.GetContent<IEditableTextBuffer>(); + var textBuffer = document.Editor; if (textBuffer == null) return 0; // This is less than optimal, we simply read 1024 chars hoping to // find a newline there: if we don't find it we just return 0. - string text = textBuffer.GetText (0, Math.Min (textBuffer.Length, 1023)); + string text = textBuffer.GetTextAt (0, Math.Min (textBuffer.Length, 1023)); string eol = document.Editor != null ? document.Editor.EolMarker : Environment.NewLine; return text.IndexOf (eol + eol, StringComparison.Ordinal); |