Browse Source

Text widget: Clamp cursor index to a valid range

Michael Ragazzon 3 years ago
parent
commit
68b3f9730b
1 changed files with 2 additions and 1 deletions
  1. 2 1
      Source/Core/Elements/WidgetTextInput.cpp

+ 2 - 1
Source/Core/Elements/WidgetTextInput.cpp

@@ -670,8 +670,9 @@ void WidgetTextInput::MoveCursorHorizontal(CursorMovement movement, bool select)
 		break;
 		break;
 	}
 	}
 
 
-	MoveCursorToCharacterBoundaries(seek_forward);
+	absolute_cursor_index = Math::Clamp(absolute_cursor_index, 0, (int)GetValue().size());
 
 
+	MoveCursorToCharacterBoundaries(seek_forward);
 	UpdateCursorPosition(true);
 	UpdateCursorPosition(true);
 
 
 	UpdateSelection(select);
 	UpdateSelection(select);