Browse Source

Prevents WordBackward or WordForward throw null exception. (#2529)

BDisp 2 years ago
parent
commit
9aaf84f96e
1 changed files with 2 additions and 0 deletions
  1. 2 0
      Terminal.Gui/Views/TextField.cs

+ 2 - 0
Terminal.Gui/Views/TextField.cs

@@ -1058,6 +1058,7 @@ namespace Terminal.Gui {
 					|| (x > 0 && (char)text [x] == ' ')) {
 					|| (x > 0 && (char)text [x] == ' ')) {
 
 
 					var newPosBw = GetModel ().WordBackward (x, 0);
 					var newPosBw = GetModel ().WordBackward (x, 0);
+					if (newPosBw == null) return true;
 					sbw = newPosBw.Value.col;
 					sbw = newPosBw.Value.col;
 				}
 				}
 				if (sbw != -1) {
 				if (sbw != -1) {
@@ -1065,6 +1066,7 @@ namespace Terminal.Gui {
 					PositionCursor (x);
 					PositionCursor (x);
 				}
 				}
 				var newPosFw = GetModel ().WordForward (x, 0);
 				var newPosFw = GetModel ().WordForward (x, 0);
+				if (newPosFw == null) return true;
 				ClearAllSelection ();
 				ClearAllSelection ();
 				if (newPosFw.Value.col != -1 && sbw != -1) {
 				if (newPosFw.Value.col != -1 && sbw != -1) {
 					point = newPosFw.Value.col;
 					point = newPosFw.Value.col;