From bc10e9c923ffb01859183267186bc829128111a9 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Fri, 9 Feb 2018 18:41:48 -0200 Subject: [PATCH] Fix #1064: Do not resolve mouse position after the EOL to reference segment at the EOL. --- ILSpy/TextView/DecompilerTextView.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/ILSpy/TextView/DecompilerTextView.cs b/ILSpy/TextView/DecompilerTextView.cs index b8fea2606..1fcb8452d 100644 --- a/ILSpy/TextView/DecompilerTextView.cs +++ b/ILSpy/TextView/DecompilerTextView.cs @@ -176,7 +176,7 @@ namespace ICSharpCode.ILSpy.TextView void TextViewMouseHover(object sender, MouseEventArgs e) { - TextViewPosition? position = textEditor.TextArea.TextView.GetPosition(e.GetPosition(textEditor.TextArea.TextView) + textEditor.TextArea.TextView.ScrollOffset); + TextViewPosition? position = GetPositionFromMousePosition(); if (position == null) return; int offset = textEditor.Document.GetOffset(position.Value.Location); @@ -757,7 +757,13 @@ namespace ICSharpCode.ILSpy.TextView internal TextViewPosition? GetPositionFromMousePosition() { - return textEditor.TextArea.TextView.GetPosition(Mouse.GetPosition(textEditor.TextArea.TextView) + textEditor.TextArea.TextView.ScrollOffset); + var position = textEditor.TextArea.TextView.GetPosition(Mouse.GetPosition(textEditor.TextArea.TextView) + textEditor.TextArea.TextView.ScrollOffset); + if (position == null) + return null; + var lineLength = textEditor.Document.GetLineByNumber(position.Value.Line).Length + 1; + if (position.Value.Column == lineLength) + return null; + return position; } public DecompilerTextViewState GetState()