diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-10-26 11:57:11 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-10-26 11:57:50 +0400 |
commit | d11c606e5b8568c4fd3366d6f6d32a1ec556b8f9 (patch) | |
tree | 702a36198bc5a991fbaa3fd7f37d391091db56b3 /main/src/addins/AspNet | |
parent | e7127cbcf3aebc3638f1ed5215480b4ce65eee18 (diff) |
[Undo] Removed begin/end atomic undo action functions & replaced them
with an IDispoable pattern.
Diffstat (limited to 'main/src/addins/AspNet')
3 files changed, 25 insertions, 26 deletions
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs index 155cd08c05..4ef9af8749 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/DocumentReferenceManager.cs @@ -369,14 +369,14 @@ namespace MonoDevelop.AspNet.Parser if (pos < 0) return; - editor.Document.BeginAtomicUndo (); - var oldCaret = editor.Caret.Offset; - - var inserted = editor.Insert (pos, editor.EolMarker + directive.ToString ()); - if (preserveCaretPosition) { - editor.Caret.Offset = (pos < oldCaret)? oldCaret + inserted : oldCaret; + using (var undo = editor.OpenUndoGroup ()) { + var oldCaret = editor.Caret.Offset; + + var inserted = editor.Insert (pos, editor.EolMarker + directive.ToString ()); + if (preserveCaretPosition) { + editor.Caret.Offset = (pos < oldCaret)? oldCaret + inserted : oldCaret; + } } - editor.Document.EndAtomicUndo (); } DirectiveNode GetRegisterInsertionPointNode () diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/SuggestedHandlerCompletionData.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/SuggestedHandlerCompletionData.cs index 279c2b21e7..a4a42b19f0 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/SuggestedHandlerCompletionData.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet.Parser/SuggestedHandlerCompletionData.cs @@ -77,11 +77,11 @@ namespace MonoDevelop.AspNet.Parser { //insert the method name MonoDevelop.Ide.Gui.Content.IEditableTextBuffer buf = window.CompletionWidget as MonoDevelop.Ide.Gui.Content.IEditableTextBuffer; - if (buf != null) {
- buf.BeginAtomicUndo ();
- buf.DeleteText (window.CodeCompletionContext.TriggerOffset, buf.CursorPosition - window.CodeCompletionContext.TriggerOffset); - buf.InsertText (buf.CursorPosition, methodInfo.Name);
- buf.EndAtomicUndo ();
+ if (buf != null) { + using (var undo = buf.OpenUndoGroup ()) {
+ buf.DeleteText (window.CodeCompletionContext.TriggerOffset, buf.CursorPosition - window.CodeCompletionContext.TriggerOffset); + buf.InsertText (buf.CursorPosition, methodInfo.Name); + }
} //generate the codebehind method diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.Html/DocTypeCompletionData.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.Html/DocTypeCompletionData.cs index 47017a2e87..4464342cc6 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.Html/DocTypeCompletionData.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.Html/DocTypeCompletionData.cs @@ -72,21 +72,20 @@ namespace MonoDevelop.Html { MonoDevelop.Ide.Gui.Content.IEditableTextBuffer buf = window.CompletionWidget as MonoDevelop.Ide.Gui.Content.IEditableTextBuffer; if (buf != null) {
- buf.BeginAtomicUndo (); - - int deleteStartOffset = window.CodeCompletionContext.TriggerOffset; - if (text.StartsWith (docTypeStart)) { - int start = window.CodeCompletionContext.TriggerOffset - docTypeStart.Length; - if (start >= 0) { - string readback = buf.GetText (start, window.CodeCompletionContext.TriggerOffset); - if (string.Compare (readback, docTypeStart, StringComparison.OrdinalIgnoreCase) == 0) - deleteStartOffset -= docTypeStart.Length; + using (var undo = buf.OpenUndoGroup ()) { + int deleteStartOffset = window.CodeCompletionContext.TriggerOffset; + if (text.StartsWith (docTypeStart)) { + int start = window.CodeCompletionContext.TriggerOffset - docTypeStart.Length; + if (start >= 0) { + string readback = buf.GetText (start, window.CodeCompletionContext.TriggerOffset); + if (string.Compare (readback, docTypeStart, StringComparison.OrdinalIgnoreCase) == 0) + deleteStartOffset -= docTypeStart.Length; + } } - } -
- buf.DeleteText (deleteStartOffset, buf.CursorPosition - deleteStartOffset); - buf.InsertText (buf.CursorPosition, text);
- buf.EndAtomicUndo ();
+
+ buf.DeleteText (deleteStartOffset, buf.CursorPosition - deleteStartOffset); + buf.InsertText (buf.CursorPosition, text); + }
} } } |