From 8c555650d94ec621e75886c4d7ed25fb4fc1181c Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 31 May 2013 18:51:29 +0200 Subject: [PATCH] Don't show the context action popup when the caret is outside the editor boundaries --- .../Src/ContextActions/ContextActionsRenderer.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsRenderer.cs b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsRenderer.cs index 4b3a32abb8..81f6bbb2b9 100644 --- a/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsRenderer.cs +++ b/src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/ContextActions/ContextActionsRenderer.cs @@ -7,6 +7,7 @@ using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; using System.Threading; +using System.Windows; using System.Windows.Input; using System.Windows.Threading; @@ -120,6 +121,13 @@ namespace ICSharpCode.AvalonEdit.AddIn.ContextActions return; ClosePopup(); + // Don't show the context action popup when the caret is outside the editor boundaries + var textView = this.editorView.TextArea.TextView; + Rect editorRect = new Rect((Point)textView.ScrollOffset, textView.RenderSize); + Rect caretRect = this.editorView.TextArea.Caret.CalculateCaretRectangle(); + if (!editorRect.Contains(caretRect)) + return; + ContextActionsBulbViewModel popupVM = BuildPopupViewModel(); this.cancellationTokenSourceForPopupBeingOpened = new CancellationTokenSource(); var cancellationToken = cancellationTokenSourceForPopupBeingOpened.Token;