Fixed comma appended to username completion when not at the beginning of the message (#3060)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -39,6 +39,19 @@ bool ResizingTextEdit::hasHeightForWidth() const
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ResizingTextEdit::isFirstWord() const
|
||||
{
|
||||
QString plainText = this->toPlainText();
|
||||
for (int i = this->textCursor().position(); i >= 0; i--)
|
||||
{
|
||||
if (plainText[i] == ' ')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
int ResizingTextEdit::heightForWidth(int) const
|
||||
{
|
||||
auto margins = this->contentsMargins();
|
||||
@@ -108,17 +121,6 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
}
|
||||
|
||||
QString currentCompletionPrefix = this->textUnderCursor();
|
||||
bool isFirstWord = [&] {
|
||||
QString plainText = this->toPlainText();
|
||||
for (int i = this->textCursor().position(); i >= 0; i--)
|
||||
{
|
||||
if (plainText[i] == ' ')
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}();
|
||||
|
||||
// check if there is something to complete
|
||||
if (currentCompletionPrefix.size() <= 1)
|
||||
@@ -134,7 +136,8 @@ void ResizingTextEdit::keyPressEvent(QKeyEvent *event)
|
||||
// First type pressing tab after modifying a message, we refresh our
|
||||
// completion model
|
||||
this->completer_->setModel(completionModel);
|
||||
completionModel->refresh(currentCompletionPrefix, isFirstWord);
|
||||
completionModel->refresh(currentCompletionPrefix,
|
||||
this->isFirstWord());
|
||||
this->completionInProgress_ = true;
|
||||
this->completer_->setCompletionPrefix(currentCompletionPrefix);
|
||||
this->completer_->complete();
|
||||
|
||||
Reference in New Issue
Block a user