Browse Source

do snippet insertion in one UndoGroup

pull/1/head
Siegfried Pammer 15 years ago
parent
commit
fcea661299
  1. 2
      src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs
  2. 4
      src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs

2
src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideEqualsGetHashCodeMethodsRefactoring.cs

@ -46,6 +46,7 @@ namespace SharpRefactoring @@ -46,6 +46,7 @@ namespace SharpRefactoring
if (current == null)
return;
using (textEditor.Document.OpenUndoGroup()) {
ITextAnchor startAnchor = textEditor.Document.CreateAnchor(textEditor.Caret.Offset);
startAnchor.MovementType = AnchorMovementType.BeforeInsertion;
@ -74,6 +75,7 @@ namespace SharpRefactoring @@ -74,6 +75,7 @@ namespace SharpRefactoring
insertionContext.RegisterActiveElement(new InlineRefactorSnippetElement(cxt => null, ""), dialog);
insertionContext.RaiseInsertionCompleted(EventArgs.Empty);
}
}
public bool Handles(ICompletionItem item)
{

4
src/AddIns/Misc/SharpRefactoring/Project/Src/OverrideToStringMethodRefactoring.cs

@ -46,6 +46,7 @@ namespace SharpRefactoring @@ -46,6 +46,7 @@ namespace SharpRefactoring
if (current == null)
return;
using (textEditor.Document.OpenUndoGroup()) {
ITextAnchor endAnchor = textEditor.Document.CreateAnchor(textEditor.Caret.Offset);
endAnchor.MovementType = AnchorMovementType.AfterInsertion;
@ -66,7 +67,7 @@ namespace SharpRefactoring @@ -66,7 +67,7 @@ namespace SharpRefactoring
InsertionContext insertionContext = new InsertionContext(textEditor.GetService(typeof(TextArea)) as TextArea, startAnchor.Offset);
AbstractInlineRefactorDialog dialog = new OverrideToStringMethodDialog(insertionContext, textEditor, startAnchor, insertionPos, current.Fields);
AbstractInlineRefactorDialog dialog = new OverrideToStringMethodDialog(insertionContext, textEditor, startAnchor, insertionPos, current.Fields, codeForBaseCall.Trim());
dialog.Element = uiService.CreateInlineUIElement(insertionPos, dialog);
textEditor.Document.InsertNormalized(endAnchor.Offset, Environment.NewLine + code.Substring(marker + codeForBaseCall.Length));
@ -74,6 +75,7 @@ namespace SharpRefactoring @@ -74,6 +75,7 @@ namespace SharpRefactoring
insertionContext.RegisterActiveElement(new InlineRefactorSnippetElement(cxt => null, ""), dialog);
insertionContext.RaiseInsertionCompleted(EventArgs.Empty);
}
}
public bool Handles(ICompletionItem item)
{

Loading…
Cancel
Save