forked from qt-creator/qt-creator
fakevim: fix 'e' and 'E'
This commit is contained in:
@@ -433,6 +433,7 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
|||||||
if (!dotCommand.isEmpty())
|
if (!dotCommand.isEmpty())
|
||||||
m_dotCommand = "c" + dotCommand;
|
m_dotCommand = "c" + dotCommand;
|
||||||
QString text = recordRemoveSelectedText();
|
QString text = recordRemoveSelectedText();
|
||||||
|
qDebug() << "CHANGING TO INSERT MODE" << text;
|
||||||
m_registers[m_register] = text;
|
m_registers[m_register] = text;
|
||||||
m_mode = InsertMode;
|
m_mode = InsertMode;
|
||||||
m_submode = NoSubMode;
|
m_submode = NoSubMode;
|
||||||
@@ -949,7 +950,12 @@ bool FakeVimHandler::Private::handleCommandMode(int key, int unmodified,
|
|||||||
} else if (key == control('v')) {
|
} else if (key == control('v')) {
|
||||||
enterVisualMode(VisualBlockMode);
|
enterVisualMode(VisualBlockMode);
|
||||||
} else if (key == 'w') {
|
} else if (key == 'w') {
|
||||||
moveToNextWord(false);
|
// Special case: "cw" and "cW" work the same as "ce" and "cE" if the
|
||||||
|
// cursor is on a non-blank.
|
||||||
|
if (m_submode == ChangeSubMode)
|
||||||
|
moveToWordBoundary(false, true);
|
||||||
|
else
|
||||||
|
moveToNextWord(false);
|
||||||
finishMovement("w");
|
finishMovement("w");
|
||||||
} else if (key == 'W') {
|
} else if (key == 'W') {
|
||||||
moveToNextWord(true);
|
moveToNextWord(true);
|
||||||
@@ -1513,15 +1519,15 @@ void FakeVimHandler::Private::moveToWordBoundary(bool simple, bool forward)
|
|||||||
int repeat = count();
|
int repeat = count();
|
||||||
QTextDocument *doc = m_tc.document();
|
QTextDocument *doc = m_tc.document();
|
||||||
int n = forward ? lastPositionInDocument() - 1 : 0;
|
int n = forward ? lastPositionInDocument() - 1 : 0;
|
||||||
int lastClass = 0;
|
int lastClass = -1;
|
||||||
while (true) {
|
while (true) {
|
||||||
m_tc.movePosition(forward ? Right : Left, KeepAnchor, 1);
|
forward ? moveRight() : moveLeft();
|
||||||
QChar c = doc->characterAt(m_tc.position());
|
QChar c = doc->characterAt(m_tc.position());
|
||||||
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) {
|
||||||
m_tc.movePosition(forward ? Left : Right, KeepAnchor, 1);
|
forward ? moveLeft() : moveRight();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
lastClass = thisClass;
|
lastClass = thisClass;
|
||||||
@@ -1586,7 +1592,7 @@ void FakeVimHandler::Private::moveToNextWord(bool simple)
|
|||||||
if (repeat == 0)
|
if (repeat == 0)
|
||||||
break;
|
break;
|
||||||
lastClass = thisClass;
|
lastClass = thisClass;
|
||||||
m_tc.movePosition(Right, KeepAnchor, 1);
|
moveRight();
|
||||||
if (m_tc.position() == n)
|
if (m_tc.position() == n)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1799,11 +1805,13 @@ void FakeVimHandler::Private::recordEndGroup()
|
|||||||
QString FakeVimHandler::Private::recordRemoveSelectedText()
|
QString FakeVimHandler::Private::recordRemoveSelectedText()
|
||||||
{
|
{
|
||||||
EditOperation op;
|
EditOperation op;
|
||||||
|
//qDebug() << "1 POS: " << position() << " ANCHOR: " << anchor() << m_tc.anchor();
|
||||||
m_tc.setPosition(anchor(), KeepAnchor);
|
m_tc.setPosition(anchor(), KeepAnchor);
|
||||||
op.m_position = qMin(position(), anchor());
|
op.m_position = qMin(position(), anchor());
|
||||||
|
//qDebug() << "2 POS: " << position() << " ANCHOR: " << anchor() << m_tc.anchor();
|
||||||
op.m_from = m_tc.selection().toPlainText();
|
op.m_from = m_tc.selection().toPlainText();
|
||||||
recordOperation(op);
|
recordOperation(op);
|
||||||
m_tc.removeSelectedText();
|
m_tc.deleteChar();
|
||||||
return op.m_from;
|
return op.m_from;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user