From 23103613cddeaf151f211640e9e5d1e69f99d627 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sun, 17 Mar 2024 21:54:06 +0100 Subject: [PATCH] Allow formatting codes applied later to override settings of earlier ones --- CHANGELOG.md | 1 + MLEM/Formatting/Token.cs | 3 +++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5be01fda..a8aa02d5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ Improvements - Stopped the text formatter throwing if a color can't be parsed - Improved text formatter tokenization performance - Allow using control and arrow keys to move the visible area of a text input +- Allow formatting codes applied later to override settings of earlier ones Fixes - Fixed TextInput not working correctly when using surrogate pairs diff --git a/MLEM/Formatting/Token.cs b/MLEM/Formatting/Token.cs index 6280351a..518f4665 100644 --- a/MLEM/Formatting/Token.cs +++ b/MLEM/Formatting/Token.cs @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using System.Linq; using Microsoft.Xna.Framework; @@ -14,6 +15,7 @@ public class Token : GenericDataHolder { /// /// The formatting codes that are applied on this token. + /// Codes are stored application order, with the first entry in the array being the code that was most recently applied. /// public readonly Code[] AppliedCodes; /// @@ -45,6 +47,7 @@ public class Token : GenericDataHolder { internal float[] InnerOffsets; internal Token(Code[] appliedCodes, int index, int rawIndex, string substring, string rawSubstring) { + Array.Reverse(appliedCodes); this.AppliedCodes = appliedCodes; this.Index = index; this.RawIndex = rawIndex;