forked from qt-creator/qt-creator
get search right for qplaintextedit
This commit is contained in:
@@ -454,16 +454,18 @@ void FakeVimHandler::Private::handleExMode(int key, const QString &text)
|
|||||||
void FakeVimHandler::Private::search(const QString &needle, bool backwards)
|
void FakeVimHandler::Private::search(const QString &needle, bool backwards)
|
||||||
{
|
{
|
||||||
//qDebug() << "NEEDLE " << needle << "BACKWARDS" << backwards;
|
//qDebug() << "NEEDLE " << needle << "BACKWARDS" << backwards;
|
||||||
//int startPos = m_tc.position();
|
QTextCursor orig = m_tc;
|
||||||
QTextDocument::FindFlags flags;
|
QTextDocument::FindFlags flags;
|
||||||
if (backwards)
|
if (backwards)
|
||||||
flags = QTextDocument::FindBackward;
|
flags = QTextDocument::FindBackward;
|
||||||
|
|
||||||
m_tc.movePosition(backwards? Left : Right, MoveAnchor, 1);
|
if (!backwards)
|
||||||
|
m_tc.movePosition(Right, MoveAnchor, 1);
|
||||||
|
|
||||||
m_editor->setTextCursor(m_tc);
|
m_editor->setTextCursor(m_tc);
|
||||||
if (m_editor->find(needle, flags)) {
|
if (m_editor->find(needle, flags)) {
|
||||||
m_tc = m_editor->textCursor();
|
m_tc = m_editor->textCursor();
|
||||||
m_tc.movePosition(Left, MoveAnchor, needle.size());
|
m_tc.movePosition(Left, MoveAnchor, needle.size() - 1);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -476,7 +478,7 @@ void FakeVimHandler::Private::search(const QString &needle, bool backwards)
|
|||||||
m_editor->setTextCursor(m_tc);
|
m_editor->setTextCursor(m_tc);
|
||||||
if (m_editor->find(needle, flags)) {
|
if (m_editor->find(needle, flags)) {
|
||||||
m_tc = m_editor->textCursor();
|
m_tc = m_editor->textCursor();
|
||||||
m_tc.movePosition(Left, MoveAnchor, needle.size());
|
m_tc.movePosition(Left, MoveAnchor, needle.size() - 1);
|
||||||
if (backwards)
|
if (backwards)
|
||||||
showMessage("search hit TOP, continuing at BOTTOM");
|
showMessage("search hit TOP, continuing at BOTTOM");
|
||||||
else
|
else
|
||||||
@@ -484,7 +486,7 @@ void FakeVimHandler::Private::search(const QString &needle, bool backwards)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tc.movePosition(backwards ? Right : Left, MoveAnchor, 1);
|
m_tc = orig;
|
||||||
}
|
}
|
||||||
|
|
||||||
void FakeVimHandler::Private::moveToFirstNonBlankOnLine()
|
void FakeVimHandler::Private::moveToFirstNonBlankOnLine()
|
||||||
|
|||||||
Reference in New Issue
Block a user