From 42dfb3ae1582a361954588a6c8ef04aded0961ba Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Sun, 16 Jul 2017 11:21:52 +0100 Subject: [PATCH 1/2] allow retrieval of snippet insertion context. --- src/AvaloniaEdit/Snippets/Snippet.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; } } } From 4439b0fb0f1f0c82122969b58eb89bb7b6a10636 Mon Sep 17 00:00:00 2001 From: danwalmsley Date: Sun, 16 Jul 2017 12:11:13 +0100 Subject: [PATCH 2/2] unsubscribe snippet text changed events. --- src/AvaloniaEdit/Snippets/SnippetBoundElement.cs | 1 + 1 file changed, 1 insertion(+) 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;