From 54e76c0b71dc8717a629f0374eef8aba2fc5c1c7 Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Wed, 8 Sep 2021 14:16:47 +0300 Subject: [PATCH] Removed extra space from end of country patterns. --- Telegram/SourceFiles/countries/countries_instance.cpp | 7 ++++--- Telegram/SourceFiles/ui/special_fields.cpp | 11 +++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/Telegram/SourceFiles/countries/countries_instance.cpp b/Telegram/SourceFiles/countries/countries_instance.cpp index 69deb65b1..166e270f2 100644 --- a/Telegram/SourceFiles/countries/countries_instance.cpp +++ b/Telegram/SourceFiles/countries/countries_instance.cpp @@ -397,9 +397,10 @@ FormatResult CountriesInstance::format(FormatArgs args) { } currentPatternPos++; } - if (!args.onlyGroups && (currentPatternPos == pattern.size())) { - result += ' '; - } + // Don't add an extra space to the end. + // if (!args.onlyGroups && (currentPatternPos == pattern.size())) { + // result += ' '; + // } if ((currentPatternPos >= pattern.size()) || (pattern[currentPatternPos] == 'X')) { currentPatternPos++; diff --git a/Telegram/SourceFiles/ui/special_fields.cpp b/Telegram/SourceFiles/ui/special_fields.cpp index 6681be1c9..551577a15 100644 --- a/Telegram/SourceFiles/ui/special_fields.cpp +++ b/Telegram/SourceFiles/ui/special_fields.cpp @@ -158,9 +158,13 @@ void PhonePartInput::correctValue( if (leftInPart) { --leftInPart; } else { - newText += ' '; ++curPart; inPart = curPart < _pattern.size(); + // Don't add an extra space to the end. + if (inPart) { + newText += ' '; + } + leftInPart = inPart ? (_pattern.at(curPart) - 1) : 0; ++oldPos; @@ -389,9 +393,12 @@ void PhoneInput::correctValue( if (leftInPart) { --leftInPart; } else { - newText += ' '; ++curPart; inPart = curPart < _pattern.size(); + // Don't add an extra space to the end. + if (inPart) { + newText += ' '; + } leftInPart = inPart ? (_pattern.at(curPart) - 1) : 0; ++oldPos;