Fixed out of range exception and text redraw when navigate backward (#320)

This commit is contained in:
BDisp
2020-02-29 16:44:16 +00:00
committed by GitHub
parent 13b3ec2ce7
commit 35591b8399

View File

@@ -807,7 +807,7 @@ namespace Terminal.Gui {
currentRow--;
if (currentRow < topRow) {
topRow--;
SetNeedsDisplay ();
}
currentLine = GetCurrentLine ();
currentColumn = currentLine.Count;
@@ -1149,18 +1149,19 @@ namespace Terminal.Gui {
SuperView.SetFocus (this);
var maxCursorPositionableLine = (model.Count - 1) - topRow;
if (ev.Y > maxCursorPositionableLine) {
currentRow = maxCursorPositionableLine;
} else {
currentRow = ev.Y + topRow;
if (model.Count > 0) {
var maxCursorPositionableLine = (model.Count - 1) - topRow;
if (ev.Y > maxCursorPositionableLine) {
currentRow = maxCursorPositionableLine;
} else {
currentRow = ev.Y + topRow;
}
var r = GetCurrentLine ();
if (ev.X - leftColumn >= r.Count)
currentColumn = r.Count - leftColumn;
else
currentColumn = ev.X - leftColumn;
}
var r = GetCurrentLine ();
if (ev.X - leftColumn >= r.Count)
currentColumn = r.Count - leftColumn;
else
currentColumn = ev.X - leftColumn;
PositionCursor ();
return true;
}