diff --git a/Telegram/SourceFiles/lang/lang_instance.cpp b/Telegram/SourceFiles/lang/lang_instance.cpp index 88d943c1c..2f328ac8b 100644 --- a/Telegram/SourceFiles/lang/lang_instance.cpp +++ b/Telegram/SourceFiles/lang/lang_instance.cpp @@ -12,6 +12,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/localstorage.h" #include "ui/boxes/confirm_box.h" #include "lang/lang_file_parser.h" +#include "lang/lang_tag.h" // kTextCommandLangTag. #include "base/platform/base_platform_info.h" #include "base/qthelp_regex.h" @@ -134,7 +135,7 @@ bool ValueParser::readTag() { if (_currentTagReplacer.isEmpty()) { _currentTagReplacer = QString(4, TextCommand); - _currentTagReplacer[1] = TextCommandLangTag; + _currentTagReplacer[1] = kTextCommandLangTag; } _currentTagReplacer[2] = QChar(0x0020 + _currentTagIndex); diff --git a/Telegram/SourceFiles/lang/lang_tag.cpp b/Telegram/SourceFiles/lang/lang_tag.cpp index 63aef91ed..a8910a0f0 100644 --- a/Telegram/SourceFiles/lang/lang_tag.cpp +++ b/Telegram/SourceFiles/lang/lang_tag.cpp @@ -869,19 +869,14 @@ auto ChoosePlural = ChoosePluralDefault; int FindTagReplacementPosition(const QString &original, ushort tag) { for (auto s = original.constData(), ch = s, e = ch + original.size(); ch != e;) { if (*ch == TextCommand) { - if (ch + kTagReplacementSize <= e && (ch + 1)->unicode() == TextCommandLangTag && *(ch + 3) == TextCommand) { + if (ch + kTagReplacementSize <= e && (ch + 1)->unicode() == kTextCommandLangTag && *(ch + 3) == TextCommand) { if ((ch + 2)->unicode() == 0x0020 + tag) { return ch - s; } else { ch += kTagReplacementSize; } } else { - auto next = textSkipCommand(ch, e); - if (next == ch) { - ++ch; - } else { - ch = next; - } + ++ch; } } else { ++ch; diff --git a/Telegram/SourceFiles/lang/lang_tag.h b/Telegram/SourceFiles/lang/lang_tag.h index 8ce6d6758..03368b73b 100644 --- a/Telegram/SourceFiles/lang/lang_tag.h +++ b/Telegram/SourceFiles/lang/lang_tag.h @@ -11,6 +11,7 @@ enum lngtag_count : int; namespace Lang { +inline constexpr auto kTextCommandLangTag = 0x20; constexpr auto kTagReplacementSize = 4; int FindTagReplacementPosition(const QString &original, ushort tag);