diff --git a/src/plugins/fakevim/fakevimhandler.cpp b/src/plugins/fakevim/fakevimhandler.cpp index 5527cdb8bc7f35fcfd0c5d4035b4aea2f3109884..efcb6d1ab54e901cf1bbf7c951ed88b6bcde2935 100755 --- a/src/plugins/fakevim/fakevimhandler.cpp +++ b/src/plugins/fakevim/fakevimhandler.cpp @@ -2418,7 +2418,8 @@ void FakeVimHandler::Private::indentRegion(QChar typedChar) qSwap(beginLine, endLine); int amount = 0; - emit q->indentRegion(&amount, beginLine, endLine, typedChar); + // lineForPosition has returned 1-based line numbers + emit q->indentRegion(&amount, beginLine-1, endLine-1, typedChar); setPosition(firstPositionInLine(beginLine)); moveToFirstNonBlankOnLine(); diff --git a/src/plugins/fakevim/fakevimplugin.cpp b/src/plugins/fakevim/fakevimplugin.cpp index 87200860d5943cff4b6d528915fcf1e835ec2992..8926bca6ed05aa7819a91a63cc15e4c0e7bc161f 100644 --- a/src/plugins/fakevim/fakevimplugin.cpp +++ b/src/plugins/fakevim/fakevimplugin.cpp @@ -634,28 +634,24 @@ void FakeVimPluginPrivate::indentRegion(int *amount, int beginLine, int endLine, indenter.setTabSize(tabSettings.m_tabSize); const QTextDocument *doc = bt->document(); - QTextBlock begin = doc->findBlockByNumber(beginLine); - QTextBlock end = doc->findBlockByNumber(endLine); const TextEditor::TextBlockIterator docStart(doc->begin()); - QTextBlock cur = begin; - do { + QTextBlock cur = doc->findBlockByNumber(beginLine); + for(int i = beginLine; i<= endLine; ++i) + { if (typedChar == 0 && cur.text().simplified().isEmpty()) { + // clear empty lines *amount = 0; - if (cur != end) { - QTextCursor cursor(cur); - while (!cursor.atBlockEnd()) - cursor.deleteChar(); - } + QTextCursor cursor(cur); + while (!cursor.atBlockEnd()) + cursor.deleteChar(); } else { const TextEditor::TextBlockIterator current(cur); const TextEditor::TextBlockIterator next(cur.next()); *amount = indenter.indentForBottomLine(current, docStart, next, typedChar); - if (cur != end) - tabSettings.indentLine(cur, *amount); + tabSettings.indentLine(cur, *amount); } - if (cur != end) - cur = cur.next(); - } while (cur != end); + cur = cur.next(); + } } void FakeVimPluginPrivate::quitFakeVim()