Skip to content

Commit

Permalink
Prevents WordBackward or WordForward throw null exception. (gui-cs#2529)
Browse files Browse the repository at this point in the history
  • Loading branch information
BDisp authored Apr 14, 2023
1 parent 5ae8e98 commit 9aaf84f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Terminal.Gui/Views/TextField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1058,13 +1058,15 @@ public override bool MouseEvent (MouseEvent ev)
|| (x > 0 && (char)text [x] == ' ')) {

var newPosBw = GetModel ().WordBackward (x, 0);
if (newPosBw == null) return true;
sbw = newPosBw.Value.col;
}
if (sbw != -1) {
x = sbw;
PositionCursor (x);
}
var newPosFw = GetModel ().WordForward (x, 0);
if (newPosFw == null) return true;
ClearAllSelection ();
if (newPosFw.Value.col != -1 && sbw != -1) {
point = newPosFw.Value.col;
Expand Down

0 comments on commit 9aaf84f

Please sign in to comment.