feat(spellchecking): ignore commands for spellchecking (#6731)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user