From 82f94872cbaf4caae4a4e463c5b0bcf965cab012 Mon Sep 17 00:00:00 2001 From: Marisa the Magician Date: Wed, 31 Jan 2024 20:50:51 +0100 Subject: [PATCH] Fix excess spacing when beautifying class names with underscores. --- language.version | 4 ++-- zscript/utility/swwm_utility_string.zsc | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/language.version b/language.version index 47c46f7ad..e76b8f5d2 100644 --- a/language.version +++ b/language.version @@ -1,3 +1,3 @@ [default] -SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1100 \cu(Wed 31 Jan 10:13:38 CET 2024)\c-"; -SWWM_SHORTVER="\cw1.3pre r1100 \cu(2024-01-31 10:13:38)\c-"; +SWWM_MODVER="\cyDEMOLITIONIST \cw1.3pre r1101 \cu(Wed 31 Jan 20:50:51 CET 2024)\c-"; +SWWM_SHORTVER="\cw1.3pre r1101 \cu(2024-01-31 20:50:51)\c-"; diff --git a/zscript/utility/swwm_utility_string.zsc b/zscript/utility/swwm_utility_string.zsc index ffb213cd9..efa90aedf 100644 --- a/zscript/utility/swwm_utility_string.zsc +++ b/zscript/utility/swwm_utility_string.zsc @@ -125,9 +125,11 @@ extend Class SWWMUtility int cp1; [cp1, pos] = workstr.GetNextCodePoint(pos); str.AppendCharacter(cp1); + if ( cp1 == 0x20 ) continue; // already spaced if ( i < len-1 ) { let [cp2, pos2] = workstr.GetNextCodePoint(pos); + if ( cp2 == 0x20 ) continue; // already spaced // this looks awkward, but I have to also account for non-letter characters // uppercase after lowercase if ( (String.CharUpper(cp1) != cp1) && (String.CharLower(cp2) != cp2) ) @@ -144,6 +146,7 @@ extend Class SWWMUtility if ( i < len-2 ) { let [cp3, pos3] = workstr.GetNextCodePoint(pos2); + if ( cp3 == 0x20 ) continue; // already spaced // uppercase before uppercase before lowercase if ( (String.CharLower(cp1) != cp1) && (String.CharLower(cp2) != cp2) && (String.CharUpper(cp3) != cp3) ) str.AppendCharacter(0x20);