fakevim: 'dG' at the end of the document should delete the last line

make sure that when deleting line-wise, a complete line is deleted,
even at the end of the document

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 c71c338e72
commit a04137f39a

View File

@@ -817,6 +817,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
if (m_movetype == MoveLineWise) if (m_movetype == MoveLineWise)
m_registers[m_register].rangemode = RangeLineMode; m_registers[m_register].rangemode = RangeLineMode;
removeSelectedText(); removeSelectedText();
if (m_movetype == MoveLineWise)
handleStartOfLine();
m_submode = NoSubMode; m_submode = NoSubMode;
if (atEndOfLine()) if (atEndOfLine())
moveLeft(); moveLeft();
@@ -2769,7 +2771,21 @@ void FakeVimHandler::Private::removeText(const Range &range)
tc.movePosition(StartOfLine, MoveAnchor); tc.movePosition(StartOfLine, MoveAnchor);
tc.setPosition(range.endPos, KeepAnchor); tc.setPosition(range.endPos, KeepAnchor);
tc.movePosition(EndOfLine, KeepAnchor); tc.movePosition(EndOfLine, KeepAnchor);
tc.movePosition(Right, KeepAnchor, 1); // make sure that complete lines are removed
// - also at the beginning and at the end of the document
if (tc.atEnd()) {
tc.setPosition(range.beginPos, MoveAnchor);
tc.movePosition(StartOfLine, MoveAnchor);
if (!tc.atStart()) {
// also remove first line if it is the only one
tc.movePosition(Left, MoveAnchor, 1);
tc.movePosition(EndOfLine, MoveAnchor, 1);
}
tc.setPosition(range.endPos, KeepAnchor);
tc.movePosition(EndOfLine, KeepAnchor);
} else {
tc.movePosition(Right, KeepAnchor, 1);
}
fixMarks(range.beginPos, tc.selectionStart() - tc.selectionEnd()); fixMarks(range.beginPos, tc.selectionStart() - tc.selectionEnd());
tc.removeSelectedText(); tc.removeSelectedText();
return; return;