fakevim: fix indenting

- the indented region has been off by one line as lineForPosition returns 1-based line numbers but QTextDocument::findBlockByNumber expects base 0
- all lines (including first and last line) have to be indented
- if text is collapsed, then findBlockByNumber has to be used instead of findBlockByLineNumber for getting the block containing a line

Merge-request: 96
Reviewed-by: hjk <qtc-committer@nokia.com>
This commit is contained in:
Martin Aumüller
2010-01-05 18:42:26 +01:00
committed by hjk
parent a088b01713
commit 7ccdbc5e97
2 changed files with 12 additions and 15 deletions

View File

@@ -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();