From ec443b811b8e1d86c6476317a2e8684fde8c60c8 Mon Sep 17 00:00:00 2001 From: Ari Vuollet Date: Sun, 22 May 2022 11:29:53 +0300 Subject: [PATCH] Fix error when double-clicking empty RichTextBox --- Source/Engine/UI/GUI/Common/RichTextBoxBase.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs index 96d055866..a3e05dc97 100644 --- a/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs +++ b/Source/Engine/UI/GUI/Common/RichTextBoxBase.cs @@ -1,5 +1,6 @@ // Copyright (c) 2012-2022 Wojciech Figat. All rights reserved. +using System; using System.Collections.Generic; namespace FlaxEngine.GUI @@ -211,7 +212,7 @@ namespace FlaxEngine.GUI var hitPos = CharIndexAtPoint(ref location); int spaceLoc = _text.LastIndexOfAny(Separators, hitPos - 2); var left = spaceLoc == -1 ? 0 : spaceLoc + 1; - spaceLoc = _text.IndexOfAny(Separators, hitPos + 1); + spaceLoc = _text.IndexOfAny(Separators, Math.Min(hitPos + 1, _text.Length)); var right = spaceLoc == -1 ? textLength : spaceLoc; SetSelection(left, right); }