forked from qt-creator/qt-creator
fakevim: fix 'ce'
This commit is contained in:
@@ -128,6 +128,12 @@ enum VisualMode
|
|||||||
VisualBlockMode,
|
VisualBlockMode,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum MoveType
|
||||||
|
{
|
||||||
|
MoveExclusive,
|
||||||
|
MoveInclusive,
|
||||||
|
};
|
||||||
|
|
||||||
struct EditOperation
|
struct EditOperation
|
||||||
{
|
{
|
||||||
EditOperation() : m_position(-1), m_itemCount(0) {}
|
EditOperation() : m_position(-1), m_itemCount(0) {}
|
||||||
@@ -264,6 +270,7 @@ public:
|
|||||||
int m_register;
|
int m_register;
|
||||||
QString m_mvcount;
|
QString m_mvcount;
|
||||||
QString m_opcount;
|
QString m_opcount;
|
||||||
|
MoveType m_moveType;
|
||||||
|
|
||||||
bool m_fakeEnd;
|
bool m_fakeEnd;
|
||||||
|
|
||||||
@@ -343,6 +350,7 @@ FakeVimHandler::Private::Private(FakeVimHandler *parent)
|
|||||||
m_plaintextedit = 0;
|
m_plaintextedit = 0;
|
||||||
m_visualMode = NoVisualMode;
|
m_visualMode = NoVisualMode;
|
||||||
m_desiredColumn = 0;
|
m_desiredColumn = 0;
|
||||||
|
m_moveType = MoveInclusive;
|
||||||
|
|
||||||
m_config[ConfigStartOfLine] = ConfigOn;
|
m_config[ConfigStartOfLine] = ConfigOn;
|
||||||
m_config[ConfigTabStop] = "8";
|
m_config[ConfigTabStop] = "8";
|
||||||
@@ -462,6 +470,8 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
m_tc.setPosition(startBlock.position());
|
m_tc.setPosition(startBlock.position());
|
||||||
moveToFirstNonBlankOnLine();
|
moveToFirstNonBlankOnLine();
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
|
} else if (m_moveType == MoveExclusive) {
|
||||||
|
moveLeft(); // correct
|
||||||
}
|
}
|
||||||
m_mvcount.clear();
|
m_mvcount.clear();
|
||||||
m_opcount.clear();
|
m_opcount.clear();
|
||||||
@@ -610,13 +620,13 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
setAnchor();
|
setAnchor();
|
||||||
moveDown(count());
|
moveDown(count());
|
||||||
moveLeft();
|
moveLeft();
|
||||||
QString text = recordRemoveSelectedText();
|
m_registers[m_register] = recordRemoveSelectedText();
|
||||||
m_registers[m_register] = text;
|
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
m_mode = InsertMode;
|
m_mode = InsertMode;
|
||||||
finishMovement("c");
|
finishMovement("c");
|
||||||
} else if (m_submode == DeleteSubMode && key == 'd') {
|
} else if (m_submode == DeleteSubMode && key == 'd') {
|
||||||
moveToStartOfLine();
|
moveToStartOfLine();
|
||||||
|
setAnchor();
|
||||||
moveDown(count());
|
moveDown(count());
|
||||||
m_registers[m_register] = recordRemoveSelectedText();
|
m_registers[m_register] = recordRemoveSelectedText();
|
||||||
finishMovement("d");
|
finishMovement("d");
|
||||||
@@ -790,6 +800,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'e') {
|
} else if (key == 'e') {
|
||||||
moveToWordBoundary(false, true);
|
moveToWordBoundary(false, true);
|
||||||
|
m_moveType = MoveExclusive;
|
||||||
finishMovement();
|
finishMovement();
|
||||||
} else if (key == 'E') {
|
} else if (key == 'E') {
|
||||||
moveToWordBoundary(true, true);
|
moveToWordBoundary(true, true);
|
||||||
@@ -956,6 +967,7 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
moveToWordBoundary(false, true);
|
moveToWordBoundary(false, true);
|
||||||
else
|
else
|
||||||
moveToNextWord(false);
|
moveToNextWord(false);
|
||||||
|
m_moveType = MoveExclusive;
|
||||||
finishMovement("w");
|
finishMovement("w");
|
||||||
} else if (key == 'W') {
|
} else if (key == 'W') {
|
||||||
moveToNextWord(true);
|
moveToNextWord(true);
|
||||||
@@ -1526,10 +1538,8 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
|
|||||||
int thisClass = charClass(c, simple);
|
int thisClass = charClass(c, simple);
|
||||||
if (thisClass != lastClass && lastClass != 0)
|
if (thisClass != lastClass && lastClass != 0)
|
||||||
--repeat;
|
--repeat;
|
||||||
if (repeat == -1) {
|
if (repeat == -1)
|
||||||
forward ? moveLeft() : moveRight();
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
lastClass = thisClass;
|
lastClass = thisClass;
|
||||||
if (m_tc.position() == n)
|
if (m_tc.position() == n)
|
||||||
break;
|
break;
|
||||||
@@ -1833,7 +1843,7 @@ void FakeVimHandler::Private::recordInsertText(const QString &data)
|
|||||||
|
|
||||||
void FakeVimHandler::Private::recordOperation(const EditOperation &op)
|
void FakeVimHandler::Private::recordOperation(const EditOperation &op)
|
||||||
{
|
{
|
||||||
qDebug() << "OP: " << op;
|
//qDebug() << "OP: " << op;
|
||||||
m_undoStack.push(op);
|
m_undoStack.push(op);
|
||||||
m_redoStack.clear();
|
m_redoStack.clear();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user