2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-01 23:25:15 +00:00

Fix emoji suggestions in monospace.

This commit is contained in:
John Preston
2019-01-21 11:02:20 +04:00
parent 805e4d01e7
commit 6066265717
2 changed files with 30 additions and 17 deletions

View File

@@ -2895,14 +2895,22 @@ void InputField::applyInstantReplace(
} else if (position < length) {
return;
}
commitInstantReplacement(position - length, position, with, what);
commitInstantReplacement(position - length, position, with, what, true);
}
void InputField::commitInstantReplacement(
int from,
int till,
const QString &with) {
commitInstantReplacement(from, till, with, std::nullopt, false);
}
void InputField::commitInstantReplacement(
int from,
int till,
const QString &with,
std::optional<QString> checkOriginal) {
std::optional<QString> checkOriginal,
bool checkIfInMonospace) {
const auto original = getTextWithTagsPart(from, till).text;
if (checkOriginal
&& checkOriginal->compare(original, Qt::CaseInsensitive) != 0) {
@@ -2910,9 +2918,11 @@ void InputField::commitInstantReplacement(
}
auto cursor = textCursor();
const auto currentTag = cursor.charFormat().property(kTagProperty);
if (currentTag == kTagPre || currentTag == kTagCode) {
return;
if (checkIfInMonospace) {
const auto currentTag = cursor.charFormat().property(kTagProperty);
if (currentTag == kTagPre || currentTag == kTagCode) {
return;
}
}
cursor.setPosition(from);
cursor.setPosition(till, QTextCursor::KeepAnchor);