Commit 3dac5db1 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix support when we use FindBackward option

parent 1c9e0372
Pipeline #139583 passed with stages
in 5 minutes and 1 second
......@@ -51,8 +51,13 @@ bool FindUtils::find(QPlainTextEdit *view, const QString &searchText, QTextDocum
c = doc.find(FindUtils::normalize(searchText), c, searchOptions);
if (!c.isNull()) {
qDebug() << " c.selectionStart() " << c.selectionStart() << "c.selectionEnd() " << c.selectionEnd();
docCusor.setPosition(c.selectionStart());
docCusor.setPosition(c.selectionEnd(), QTextCursor::KeepAnchor);
if (searchOptions & QTextDocument::FindBackward) {
docCusor.setPosition(c.selectionEnd());
docCusor.setPosition(c.selectionStart(), QTextCursor::KeepAnchor);
} else {
docCusor.setPosition(c.selectionStart());
docCusor.setPosition(c.selectionEnd(), QTextCursor::KeepAnchor);
}
view->setTextCursor(docCusor);
view->ensureCursorVisible();
return true;
......@@ -71,8 +76,13 @@ bool FindUtils::find(QTextEdit *view, const QString &searchText, QTextDocument::
c = doc.find(FindUtils::normalize(searchText), c, searchOptions);
if (!c.isNull()) {
qDebug() << " c.selectionStart() " << c.selectionStart() << "c.selectionEnd() " << c.selectionEnd();
docCusor.setPosition(c.selectionStart());
docCusor.setPosition(c.selectionEnd(), QTextCursor::KeepAnchor);
if (searchOptions & QTextDocument::FindBackward) {
docCusor.setPosition(c.selectionEnd());
docCusor.setPosition(c.selectionStart(), QTextCursor::KeepAnchor);
} else {
docCusor.setPosition(c.selectionStart());
docCusor.setPosition(c.selectionEnd(), QTextCursor::KeepAnchor);
}
view->setTextCursor(docCusor);
view->ensureCursorVisible();
return true;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment