Fix new formatting mixing with emoji.

This commit is contained in:
John Preston 2021-06-24 17:01:03 +04:00
parent 98ba824bde
commit e73e1a6c0f

View file

@ -3281,8 +3281,8 @@ void InputField::addMarkdownTag(
int till, int till,
const QString &tag) { const QString &tag) {
const auto current = getTextWithTagsPart(from, till); const auto current = getTextWithTagsPart(from, till);
const auto currentLength = current.text.size();
const auto tagRef = tag.midRef(0); const auto tagRef = tag.midRef(0);
auto markdownTagApplies = std::vector<MarkdownTag>();
// #TODO Trim inserted tag, so that all newlines are left outside. // #TODO Trim inserted tag, so that all newlines are left outside.
auto tags = TagList(); auto tags = TagList();
@ -3293,19 +3293,11 @@ void InputField::addMarkdownTag(
filled = std::clamp( filled = std::clamp(
existing.offset + existing.length, existing.offset + existing.length,
filled, filled,
till - from); currentLength);
markdownTagApplies.push_back({
from + existing.offset,
from + filled,
-1,
-1,
false,
id,
});
}; };
if (!TextUtilities::IsSeparateTag(tag)) { if (!TextUtilities::IsSeparateTag(tag)) {
for (const auto &existing : current.tags) { for (const auto &existing : current.tags) {
if (existing.offset >= till) { if (existing.offset >= currentLength) {
break; break;
} else if (existing.offset > filled) { } else if (existing.offset > filled) {
add({ filled, existing.offset - filled, tag }); add({ filled, existing.offset - filled, tag });
@ -3313,16 +3305,14 @@ void InputField::addMarkdownTag(
add(existing); add(existing);
} }
} }
if (filled < till - from) { if (filled < currentLength) {
add({ filled, till - from - filled, tag }); add({ filled, currentLength - filled, tag });
} }
finishMarkdownTagChange(from, till, { current.text, tags }); finishMarkdownTagChange(from, till, { current.text, tags });
// Fire the tags to the spellchecker. // Fire the tag to the spellchecker.
for (auto &apply : markdownTagApplies) { _markdownTagApplies.fire({ from, till, -1, -1, false, tag });
_markdownTagApplies.fire(std::move(apply));
}
} }
void InputField::removeMarkdownTag( void InputField::removeMarkdownTag(