diff --git a/src/AvaloniaEdit/Snippets/Snippet.cs b/src/AvaloniaEdit/Snippets/Snippet.cs index 3823c761..31c6af2d 100644 --- a/src/AvaloniaEdit/Snippets/Snippet.cs +++ b/src/AvaloniaEdit/Snippets/Snippet.cs @@ -30,7 +30,7 @@ public class Snippet : SnippetContainerElement /// /// Inserts the snippet into the text area. /// - public void Insert(TextArea textArea) + public InsertionContext Insert(TextArea textArea) { if (textArea == null) throw new ArgumentNullException(nameof(textArea)); @@ -53,6 +53,8 @@ public void Insert(TextArea textArea) Insert(context); context.RaiseInsertionCompleted(EventArgs.Empty); } + + return context; } } } diff --git a/src/AvaloniaEdit/Snippets/SnippetBoundElement.cs b/src/AvaloniaEdit/Snippets/SnippetBoundElement.cs index 694917cf..6812a8b4 100644 --- a/src/AvaloniaEdit/Snippets/SnippetBoundElement.cs +++ b/src/AvaloniaEdit/Snippets/SnippetBoundElement.cs @@ -123,6 +123,7 @@ private void targetElement_TextChanged(object sender, EventArgs e) public void Deactivate(SnippetEventArgs e) { + TargetElement.TextChanged -= targetElement_TextChanged; } public bool IsEditable => false;