diff options
| author | hjk <qtc-committer@nokia.com> | 2009-04-16 11:52:58 +0200 |
|---|---|---|
| committer | hjk <qtc-committer@nokia.com> | 2009-04-16 11:52:58 +0200 |
| commit | 5076be59e340a232142d9ac951518ee57797c0f6 (patch) | |
| tree | 53a4999375c7ef38362ddf2f63682ae059a22709 | |
| parent | c172e9b1a44507dd39955bd5a9b5334115905176 (diff) | |
| download | qt-creator-5076be59e340a232142d9ac951518ee57797c0f6.tar.gz | |
fakevim: fix cursor position for <n>j or <n>k and end or begin of document
| -rw-r--r-- | src/plugins/fakevim/fakevimhandler.cpp | 5 | ||||
| -rw-r--r-- | tests/auto/fakevim/main.cpp | 1 |
2 files changed, 4 insertions, 2 deletions
diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index ce04adfa6a..e18599d707 100644 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -620,8 +620,9 @@ void FakeVimHandler::Private::moveDown(int n) m_tc.movePosition(Down, MoveAnchor, n); #else const int col = m_tc.position() - m_tc.block().position(); - const int line = m_tc.block().blockNumber(); - const QTextBlock &block = m_tc.document()->findBlockByNumber(line + n); + const int lastLine = m_tc.document()->lastBlock().blockNumber(); + const int targetLine = qMax(0, qMin(lastLine, m_tc.block().blockNumber() + n)); + const QTextBlock &block = m_tc.document()->findBlockByNumber(targetLine); const int pos = block.position(); setPosition(pos + qMin(block.length() - 1, col)); moveToTargetColumn(); diff --git a/tests/auto/fakevim/main.cpp b/tests/auto/fakevim/main.cpp index df4b6d691a..fd5b06f093 100644 --- a/tests/auto/fakevim/main.cpp +++ b/tests/auto/fakevim/main.cpp @@ -302,6 +302,7 @@ void tst_FakeVim::command_e() move("e", "int main(int argc, char *arg@v[])"); move("e", "int main(int argc, char *argv[]@)"); move("e", "@{"); + move("10k","@\n"); // home. } void tst_FakeVim::command_i() |
