fakevim: more vim-ish cursor positioning after undo/redo

Change-Id: Ie689a719b023ed1e3756470bd144e22b1099bb07
Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
hjk
2011-12-26 16:38:31 +01:00
parent 4443532d14
commit 29223bc117

View File

@@ -1485,7 +1485,6 @@ void FakeVimHandler::Private::stopIncrementalFind()
void FakeVimHandler::Private::setUndoPosition(int pos) void FakeVimHandler::Private::setUndoPosition(int pos)
{ {
//qDebug() << " CURSOR POS: " << m_undoCursorPosition;
m_undoCursorPosition[document()->availableUndoSteps()] = pos; m_undoCursorPosition[document()->availableUndoSteps()] = pos;
} }
@@ -2893,6 +2892,7 @@ EventResult FakeVimHandler::Private::handleInsertMode(const Input &input)
moveLeft(qMin(1, leftDist())); moveLeft(qMin(1, leftDist()));
setTargetColumn(); setTargetColumn();
leaveVisualMode(); leaveVisualMode();
breakEditBlock();
} }
g.dotCommand += m_lastInsertion; g.dotCommand += m_lastInsertion;
g.dotCommand += QChar(27); g.dotCommand += QChar(27);
@@ -2955,11 +2955,13 @@ EventResult FakeVimHandler::Private::handleInsertMode(const Input &input)
setTargetColumn(); setTargetColumn();
m_lastInsertion.clear(); m_lastInsertion.clear();
} else if (input.isReturn()) { } else if (input.isReturn()) {
joinPreviousEditBlock();
m_submode = NoSubMode; m_submode = NoSubMode;
insertText(QString("\n")); insertText(QString("\n"));
m_lastInsertion += '\n'; m_lastInsertion += '\n';
insertAutomaticIndentation(true); insertAutomaticIndentation(true);
setTargetColumn(); setTargetColumn();
endEditBlock();
} else if (input.isBackspace()) { } else if (input.isBackspace()) {
joinPreviousEditBlock(); joinPreviousEditBlock();
m_justAutoIndented = 0; m_justAutoIndented = 0;
@@ -4835,7 +4837,6 @@ QWidget *FakeVimHandler::Private::editor() const
void FakeVimHandler::Private::undo() void FakeVimHandler::Private::undo()
{ {
//qDebug() << " CURSOR POS: " << m_undoCursorPosition;
// FIXME: That's only an approximaxtion. The real solution might // FIXME: That's only an approximaxtion. The real solution might
// be to store marks and old userData with QTextBlock setUserData // be to store marks and old userData with QTextBlock setUserData
// and retrieve them afterward. // and retrieve them afterward.