Simplify ResizingTextEdit::isFirstWord to avoid invalid QString index warnings (#3285)

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
Paweł 2021-10-16 13:00:41 +02:00 committed by GitHub
parent 5a3a7281a1
commit 2bd05fd576
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 8 deletions

View file

@ -30,6 +30,7 @@
- Bugfix: Fixed some channels still not loading in rare cases. (#3219) - Bugfix: Fixed some channels still not loading in rare cases. (#3219)
- Bugfix: Fixed a bug with usernames or emotes completing from the wrong position. (#3229) - Bugfix: Fixed a bug with usernames or emotes completing from the wrong position. (#3229)
- Bugfix: Fixed second chatterino icon appearing in the dock when restarting on a crash in macOS. (#3268) - Bugfix: Fixed second chatterino icon appearing in the dock when restarting on a crash in macOS. (#3268)
- Bugfix: Fixed `QCharRef with an index pointing outside the valid range of a QString` warning that was emitted on every Tab press. (#3234)
- Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103) - Dev: Renamed CMake's build option `USE_SYSTEM_QT5KEYCHAIN` to `USE_SYSTEM_QTKEYCHAIN`. (#3103)
- Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) - Dev: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038)

View file

@ -42,14 +42,8 @@ bool ResizingTextEdit::hasHeightForWidth() const
bool ResizingTextEdit::isFirstWord() const bool ResizingTextEdit::isFirstWord() const
{ {
QString plainText = this->toPlainText(); QString plainText = this->toPlainText();
for (int i = this->textCursor().position(); i >= 0; i--) QString portionBeforeCursor = plainText.left(this->textCursor().position());
{ return !portionBeforeCursor.contains(' ');
if (plainText[i] == ' ')
{
return false;
}
}
return true;
}; };
int ResizingTextEdit::heightForWidth(int) const int ResizingTextEdit::heightForWidth(int) const