forked from qt-creator/qt-creator
get search right for qplaintextedit
This commit is contained in:
@@ -254,8 +254,8 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
|
|||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (m_submode == ZSubMode) {
|
} else if (m_submode == ZSubMode) {
|
||||||
if (key == Key_Return) {
|
if (key == Key_Return) {
|
||||||
// cursor line to top of window, cursor on first non-blank
|
// cursor line to top of window, cursor on first non-blank
|
||||||
QRect rect = m_editor->cursorRect();
|
QRect rect = m_editor->cursorRect();
|
||||||
int blocksUp = rect.y() / rect.height();
|
int blocksUp = rect.y() / rect.height();
|
||||||
int blockNumber = m_tc.block().blockNumber();
|
int blockNumber = m_tc.block().blockNumber();
|
||||||
QScrollBar *scrollBar = m_editor->verticalScrollBar();
|
QScrollBar *scrollBar = m_editor->verticalScrollBar();
|
||||||
@@ -265,7 +265,7 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
|
|||||||
}
|
}
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "Ignored z + " << key << text;
|
qDebug() << "Ignored z + " << key << text;
|
||||||
}
|
}
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
@@ -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