From 289424be810bbba0cc7553e195e26631d211de69 Mon Sep 17 00:00:00 2001 From: IKoshelev Date: Tue, 25 Sep 2018 20:31:48 +0200 Subject: [PATCH] Fixing bug in TextView, clicking line below text causes IndexOutOfRangeException --- Terminal.Gui/Views/TextView.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs index 1ca435b7d..be3951802 100644 --- a/Terminal.Gui/Views/TextView.cs +++ b/Terminal.Gui/Views/TextView.cs @@ -1091,8 +1091,10 @@ namespace Terminal.Gui { if (!HasFocus) SuperView.SetFocus (this); - if (ev.Y + topRow >= model.Count) { - currentRow = model.Count - topRow; + + var maxCursorPositionableLine = (model.Count - 1) - topRow; + if (ev.Y > maxCursorPositionableLine) { + currentRow = maxCursorPositionableLine; } else { currentRow = ev.Y + topRow; }