Add check to prevent warning: QTextCursor::setPosition: Position '%d' out of range.

This commit is contained in:
Roman Telezhynskyi 2024-07-30 17:15:35 +03:00
parent dc7f0fc74f
commit ded74a25e3

View file

@ -205,6 +205,12 @@ auto VPlainTextEdit::MatchRightParenthesis(QTextBlock currentBlock, int i, int n
//---------------------------------------------------------------------------------------------------------------------
void VPlainTextEdit::CreateParenthesisSelection(int pos, bool match)
{
if (pos < 0 || pos >= toPlainText().length())
{
qDebug() << "String:" << toPlainText() << "Position '" << pos << "' out of range";
return;
}
QList<QTextEdit::ExtraSelection> selections = extraSelections();
QTextEdit::ExtraSelection selection;