From 62a7a898349c795439a7901f21e456236d3764be Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Mon, 17 Jul 2023 15:56:25 +0200 Subject: [PATCH] additional text input fixes for emoji --- MLEM/Font/CodePointSource.cs | 2 +- MLEM/Input/TextInput.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MLEM/Font/CodePointSource.cs b/MLEM/Font/CodePointSource.cs index cae77b2..9133e81 100644 --- a/MLEM/Font/CodePointSource.cs +++ b/MLEM/Font/CodePointSource.cs @@ -71,7 +71,7 @@ namespace MLEM.Font { /// An index close to , but not between surrogates. public int EnsureSurrogateBoundary(int index, bool increase) { if (index < this.Length && char.IsLowSurrogate(this[index])) - return increase && index < this.Length - 1 || index <= 0 ? index + 1 : index - 1; + return increase || index <= 0 ? index + 1 : index - 1; return index; } diff --git a/MLEM/Input/TextInput.cs b/MLEM/Input/TextInput.cs index 2061b05..45ce6fb 100644 --- a/MLEM/Input/TextInput.cs +++ b/MLEM/Input/TextInput.cs @@ -419,7 +419,7 @@ namespace MLEM.Input { this.CaretPos = destStart + destAccum.Length; return true; } - destAccum += this.text[destStart + destAccum.Length]; + destAccum += CodePointSource.ToString(new CodePointSource(this.text).GetCodePoint(destStart + destAccum.Length).CodePoint); } // if we don't find a proper position, just move to the end of the destination line this.CaretPos = destEnd;