Commit 6bfe250e authored by hjk's avatar hjk Committed by Roberto Raggi
Browse files

improve undo/redo block behaviour

parent bbe5332f
...@@ -375,13 +375,15 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text) ...@@ -375,13 +375,15 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
m_tc.movePosition(EndOfLine, KeepAnchor); m_tc.movePosition(EndOfLine, KeepAnchor);
finishMovement(); finishMovement();
} else if (key == 'a') { } else if (key == 'a') {
m_mode = InsertMode;
m_lastInsertion.clear(); m_lastInsertion.clear();
m_tc.beginEditBlock();
m_tc.movePosition(Right, MoveAnchor, 1); m_tc.movePosition(Right, MoveAnchor, 1);
m_mode = InsertMode;
} else if (key == 'A') { } else if (key == 'A') {
m_mode = InsertMode;
m_tc.beginEditBlock();
m_tc.movePosition(EndOfLine, MoveAnchor); m_tc.movePosition(EndOfLine, MoveAnchor);
m_lastInsertion.clear(); m_lastInsertion.clear();
m_mode = InsertMode;
} else if (key == 'b') { } else if (key == 'b') {
moveToWordBoundary(false, false); moveToWordBoundary(false, false);
finishMovement(); finishMovement();
...@@ -390,8 +392,10 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text) ...@@ -390,8 +392,10 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
finishMovement(); finishMovement();
} else if (key == 'c') { } else if (key == 'c') {
m_submode = ChangeSubMode; m_submode = ChangeSubMode;
m_tc.beginEditBlock();
} else if (key == 'C') { } else if (key == 'C') {
m_submode = ChangeSubMode; m_submode = ChangeSubMode;
m_tc.beginEditBlock();
m_tc.movePosition(EndOfLine, KeepAnchor); m_tc.movePosition(EndOfLine, KeepAnchor);
finishMovement(); finishMovement();
} else if (key == 'd') { } else if (key == 'd') {
...@@ -434,8 +438,9 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text) ...@@ -434,8 +438,9 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
moveToFirstNonBlankOnLine(); moveToFirstNonBlankOnLine();
finishMovement(); finishMovement();
} else if (key == 'i') { } else if (key == 'i') {
m_lastInsertion.clear();
m_mode = InsertMode; m_mode = InsertMode;
m_tc.beginEditBlock();
m_lastInsertion.clear();
} else if (key == 'j' || key == Key_Down) { } else if (key == 'j' || key == Key_Down) {
m_tc.movePosition(Down, KeepAnchor, count()); m_tc.movePosition(Down, KeepAnchor, count());
finishMovement(); finishMovement();
...@@ -488,6 +493,11 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text) ...@@ -488,6 +493,11 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
} }
} else if (key == control('r')) { } else if (key == control('r')) {
EDITOR(redo()); EDITOR(redo());
} else if (key == 's') {
m_submode = ChangeSubMode;
m_tc.beginEditBlock();
m_tc.movePosition(Right, KeepAnchor, qMin(count(), rightDist()));
finishMovement();
} else if (key == 't' || key == 'T') { } else if (key == 't' || key == 'T') {
m_subsubmode = FtSubSubMode; m_subsubmode = FtSubSubMode;
m_subsubdata = key; m_subsubdata = key;
...@@ -542,10 +552,11 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text) ...@@ -542,10 +552,11 @@ void FakeVimHandler::Private::handleCommandMode(int key, const QString &text)
void FakeVimHandler::Private::handleInsertMode(int key, const QString &text) void FakeVimHandler::Private::handleInsertMode(int key, const QString &text)
{ {
if (key == Key_Escape) { if (key == Key_Escape) {
m_mode = CommandMode;
for (int i = 1; i < count(); ++i) for (int i = 1; i < count(); ++i)
m_tc.insertText(m_lastInsertion); m_tc.insertText(m_lastInsertion);
m_tc.movePosition(Left, MoveAnchor, qMin(1, leftDist())); m_tc.movePosition(Left, MoveAnchor, qMin(1, leftDist()));
m_mode = CommandMode;
m_tc.endEditBlock();
} else if (key == Key_Left) { } else if (key == Key_Left) {
m_tc.movePosition(Left, MoveAnchor, 1); m_tc.movePosition(Left, MoveAnchor, 1);
m_lastInsertion.clear(); m_lastInsertion.clear();
......
...@@ -62,7 +62,7 @@ public: ...@@ -62,7 +62,7 @@ public:
signals: signals:
void commandBufferChanged(const QString &msg); void commandBufferChanged(const QString &msg);
void quitRequested(QObject *); void quitRequested(QWidget *);
private: private:
bool eventFilter(QObject *ob, QEvent *ev); bool eventFilter(QObject *ob, QEvent *ev);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment