feat(spellchecking): ignore commands for spellchecking (#6731)
This commit is contained in:
@@ -733,4 +733,36 @@ QStringList CommandController::getDefaultChatterinoCommandList()
|
||||
return this->defaultChatterinoCommandAutoCompletions_;
|
||||
}
|
||||
|
||||
qsizetype CommandController::commandTriggerLen(QStringView text)
|
||||
{
|
||||
auto words = text.split(' ');
|
||||
|
||||
qsizetype triggerLen = 0;
|
||||
qsizetype spaces = 0;
|
||||
QString commandName{};
|
||||
|
||||
for (qsizetype i = 0; i < words.length() && spaces <= this->maxSpaces_; ++i)
|
||||
{
|
||||
commandName += words[i];
|
||||
triggerLen += words[i].length();
|
||||
|
||||
if (this->commands_.contains(commandName) ||
|
||||
this->userCommands_.contains(commandName))
|
||||
{
|
||||
return triggerLen;
|
||||
}
|
||||
|
||||
// ignore consecutive spaces
|
||||
if (!words[i].isEmpty())
|
||||
{
|
||||
commandName += ' ';
|
||||
++spaces;
|
||||
}
|
||||
// account for the space between the current and next word
|
||||
++triggerLen;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -55,6 +55,13 @@ public:
|
||||
}
|
||||
#endif
|
||||
|
||||
/// Returns the length of the command trigger in `text`, including leading
|
||||
/// spaces. If `text` does not start with a command trigger, 0 is returned.
|
||||
/// Examples:
|
||||
/// - " /ban forsen" returns 5
|
||||
/// - "/non-existing-command" returns 0
|
||||
qsizetype commandTriggerLen(QStringView text);
|
||||
|
||||
private:
|
||||
void load(Paths &paths);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user