feat(spellchecking): ignore commands for spellchecking (#6731)

This commit is contained in:
Arne
2026-01-11 13:00:40 +01:00
committed by GitHub
parent b817054947
commit a8ac28425f
4 changed files with 50 additions and 3 deletions
+10 -2
View File
@@ -8,6 +8,7 @@
#include "common/Aliases.hpp"
#include "common/LinkParser.hpp"
#include "controllers/accounts/AccountController.hpp"
#include "controllers/commands/CommandController.hpp"
#include "controllers/spellcheck/SpellChecker.hpp"
#include "messages/Emote.hpp"
#include "providers/bttv/BttvEmotes.hpp"
@@ -96,19 +97,26 @@ void InputHighlighter::highlightBlock(const QString &text)
auto *channel = this->channel.lock().get();
QStringView textView = text;
// skip leading command trigger
auto cmdTriggerLen = getApp()->getCommands()->commandTriggerLen(textView);
textView = textView.sliced(cmdTriggerLen);
#if QT_VERSION >= QT_VERSION_CHECK(6, 5, 0)
auto it = this->wordRegex.globalMatchView(textView);
#else
auto it = this->wordRegex.globalMatch(textView);
#endif
while (it.hasNext())
{
auto match = it.next();
auto text = match.captured();
if (!isIgnoredWord(channel, text) && !this->spellChecker.check(text))
{
this->setFormat(static_cast<int>(match.capturedStart()),
static_cast<int>(text.size()), this->spellFmt);
this->setFormat(
static_cast<int>(match.capturedStart() + cmdTriggerLen),
static_cast<int>(text.size()), this->spellFmt);
}
}
}