From 2d16d4c044ce108b8956d4b9fd708ee0150f5674 Mon Sep 17 00:00:00 2001 From: zneix Date: Fri, 15 Oct 2021 12:52:17 +0200 Subject: [PATCH 1/4] Fix the issue --- src/widgets/helper/ResizingTextEdit.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index 896efed6659..647b621e660 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -41,15 +41,7 @@ bool ResizingTextEdit::hasHeightForWidth() const bool ResizingTextEdit::isFirstWord() const { - QString plainText = this->toPlainText(); - for (int i = this->textCursor().position(); i >= 0; i--) - { - if (plainText[i] == ' ') - { - return false; - } - } - return true; + return !this->toPlainText().contains(' '); }; int ResizingTextEdit::heightForWidth(int) const From 45df950aa00216407ae0734dd496dd09e1488c08 Mon Sep 17 00:00:00 2001 From: zneix Date: Fri, 15 Oct 2021 12:57:23 +0200 Subject: [PATCH 2/4] just FYI this is quite silly solution --- src/widgets/helper/ResizingTextEdit.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index 647b621e660..64ee5775652 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -39,6 +39,7 @@ bool ResizingTextEdit::hasHeightForWidth() const return true; } +// XXX(zneix): This logic might be a bit stupid, see if it can be improved bool ResizingTextEdit::isFirstWord() const { return !this->toPlainText().contains(' '); From d0dc3cbd0877b30684965c32db7c42a880c353f1 Mon Sep 17 00:00:00 2001 From: zneix Date: Fri, 15 Oct 2021 13:04:47 +0200 Subject: [PATCH 3/4] Added changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 927e2863f5d..3a425bd67b2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - 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 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: Add benchmarks that can be compiled with the `BUILD_BENCHMARKS` CMake flag. Off by default. (#3038) From 32e8ce1e753c6faf8e6ab5256ced1ec28211fab4 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 16 Oct 2021 12:41:55 +0200 Subject: [PATCH 4/4] Keep simplified logic, but keep original functionality --- src/widgets/helper/ResizingTextEdit.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/widgets/helper/ResizingTextEdit.cpp b/src/widgets/helper/ResizingTextEdit.cpp index 64ee5775652..0182289b3a0 100644 --- a/src/widgets/helper/ResizingTextEdit.cpp +++ b/src/widgets/helper/ResizingTextEdit.cpp @@ -39,10 +39,11 @@ bool ResizingTextEdit::hasHeightForWidth() const return true; } -// XXX(zneix): This logic might be a bit stupid, see if it can be improved bool ResizingTextEdit::isFirstWord() const { - return !this->toPlainText().contains(' '); + QString plainText = this->toPlainText(); + QString portionBeforeCursor = plainText.left(this->textCursor().position()); + return !portionBeforeCursor.contains(' '); }; int ResizingTextEdit::heightForWidth(int) const