forked from qt-creator/qt-creator
FakeVim: Break edit block only after a change
Change-Id: Ice885d3a51d0c5516ddabe8a8bdb9b1ce5ab7a06 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -4368,44 +4368,49 @@ EventResult FakeVimHandler::Private::handleInsertMode(const Input &input)
|
|||||||
if (input.isEscape()) {
|
if (input.isEscape()) {
|
||||||
// Repeat insertion [count] times.
|
// Repeat insertion [count] times.
|
||||||
// One instance was already physically inserted while typing.
|
// One instance was already physically inserted while typing.
|
||||||
const QString text = m_lastInsertion;
|
if (!m_lastInsertion.isEmpty()) {
|
||||||
const int repeat = count();
|
const QString text = m_lastInsertion;
|
||||||
m_lastInsertion.clear();
|
const int repeat = count();
|
||||||
joinPreviousEditBlock();
|
m_lastInsertion.clear();
|
||||||
replay(text.repeated(repeat - 1));
|
joinPreviousEditBlock();
|
||||||
|
replay(text.repeated(repeat - 1));
|
||||||
|
|
||||||
if (m_visualBlockInsert && !text.contains(QLatin1Char('\n'))) {
|
if (m_visualBlockInsert && !text.contains(QLatin1Char('\n'))) {
|
||||||
const CursorPosition lastAnchor = mark(QLatin1Char('<')).position;
|
const CursorPosition lastAnchor = mark(QLatin1Char('<')).position;
|
||||||
const CursorPosition lastPosition = mark(QLatin1Char('>')).position;
|
const CursorPosition lastPosition = mark(QLatin1Char('>')).position;
|
||||||
CursorPosition startPos(lastAnchor.line, qMin(lastPosition.column, lastAnchor.column));
|
CursorPosition startPos(lastAnchor.line,
|
||||||
CursorPosition pos = startPos;
|
qMin(lastPosition.column, lastAnchor.column));
|
||||||
if (g.dotCommand.endsWith(QLatin1Char('A')))
|
CursorPosition pos = startPos;
|
||||||
pos.column = qMax(lastPosition.column, lastAnchor.column) + 1;
|
if (g.dotCommand.endsWith(QLatin1Char('A')))
|
||||||
while (pos.line < lastPosition.line) {
|
pos.column = qMax(lastPosition.column, lastAnchor.column) + 1;
|
||||||
++pos.line;
|
while (pos.line < lastPosition.line) {
|
||||||
QTextCursor tc = m_cursor;
|
++pos.line;
|
||||||
setCursorPosition(&tc, pos);
|
QTextCursor tc = m_cursor;
|
||||||
if (pos.line != tc.blockNumber())
|
setCursorPosition(&tc, pos);
|
||||||
break;
|
if (pos.line != tc.blockNumber())
|
||||||
m_cursor = tc;
|
break;
|
||||||
if (tc.positionInBlock() == pos.column)
|
m_cursor = tc;
|
||||||
replay(text.repeated(repeat));
|
if (tc.positionInBlock() == pos.column)
|
||||||
|
replay(text.repeated(repeat));
|
||||||
|
}
|
||||||
|
|
||||||
|
setCursorPosition(startPos);
|
||||||
|
} else {
|
||||||
|
moveLeft(qMin(1, leftDist()));
|
||||||
}
|
}
|
||||||
|
|
||||||
setCursorPosition(startPos);
|
endEditBlock();
|
||||||
|
breakEditBlock();
|
||||||
|
|
||||||
|
m_lastInsertion = text;
|
||||||
|
|
||||||
|
// If command is 'o' or 'O' don't include the first line feed in dot command.
|
||||||
|
if (g.dotCommand.endsWith(QLatin1Char('o'), Qt::CaseInsensitive))
|
||||||
|
m_lastInsertion.remove(0, 1);
|
||||||
|
g.dotCommand += m_lastInsertion + _("<ESC>");
|
||||||
} else {
|
} else {
|
||||||
moveLeft(qMin(1, leftDist()));
|
moveLeft(qMin(1, leftDist()));
|
||||||
leaveVisualMode(); // TODO: Remove! Should not be requiered here!
|
|
||||||
}
|
}
|
||||||
|
|
||||||
endEditBlock();
|
|
||||||
breakEditBlock();
|
|
||||||
|
|
||||||
m_lastInsertion = text;
|
|
||||||
// If command is 'o' or 'O' don't include the first line feed in dot command.
|
|
||||||
if (g.dotCommand.endsWith(QLatin1Char('o'), Qt::CaseInsensitive))
|
|
||||||
m_lastInsertion.remove(0, 1);
|
|
||||||
g.dotCommand += m_lastInsertion + _("<ESC>");
|
|
||||||
enterCommandMode();
|
enterCommandMode();
|
||||||
setTargetColumn();
|
setTargetColumn();
|
||||||
m_ctrlVActive = false;
|
m_ctrlVActive = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user