forked from qt-creator/qt-creator
fakevim: better cursor poistioning after indenting
This commit is contained in:
@@ -698,8 +698,10 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
|
||||
} else if (m_submode == ReplaceSubMode) {
|
||||
m_submode = NoSubMode;
|
||||
} else if (m_submode == IndentSubMode) {
|
||||
recordJump();
|
||||
indentRegion();
|
||||
m_submode = NoSubMode;
|
||||
updateMiniBuffer();
|
||||
} else if (m_submode == ShiftRightSubMode) {
|
||||
recordJump();
|
||||
shiftRegionRight(1);
|
||||
@@ -2057,8 +2059,13 @@ void FakeVimHandler::Private::indentRegion(QChar typedChar)
|
||||
int endLine = lineForPosition(position());
|
||||
if (beginLine > endLine)
|
||||
qSwap(beginLine, endLine);
|
||||
|
||||
int amount = 0;
|
||||
emit q->indentRegion(&amount, beginLine, endLine, typedChar);
|
||||
|
||||
setPosition(firstPositionInLine(beginLine));
|
||||
moveToFirstNonBlankOnLine();
|
||||
setTargetColumn();
|
||||
setDotCommand("%1==", endLine - beginLine + 1);
|
||||
}
|
||||
|
||||
@@ -2072,8 +2079,6 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
|
||||
QString indent(len, ' ');
|
||||
int firstPos = firstPositionInLine(beginLine);
|
||||
|
||||
//setPosition(firstPos);
|
||||
|
||||
for (int line = beginLine; line <= endLine; ++line) {
|
||||
setPosition(firstPositionInLine(line));
|
||||
m_tc.insertText(indent);
|
||||
@@ -2081,6 +2086,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
|
||||
|
||||
setPosition(firstPos);
|
||||
moveToFirstNonBlankOnLine();
|
||||
setTargetColumn();
|
||||
setDotCommand("%1>>", endLine - beginLine + 1);
|
||||
}
|
||||
|
||||
@@ -2094,8 +2100,6 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
|
||||
int tab = config(ConfigTabStop).toInt();
|
||||
int firstPos = firstPositionInLine(beginLine);
|
||||
|
||||
//setPosition(firstPos);
|
||||
|
||||
for (int line = beginLine; line <= endLine; ++line) {
|
||||
int pos = firstPositionInLine(line);
|
||||
setPosition(pos);
|
||||
@@ -2118,6 +2122,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
|
||||
|
||||
setPosition(firstPos);
|
||||
moveToFirstNonBlankOnLine();
|
||||
setTargetColumn();
|
||||
setDotCommand("%1<<", endLine - beginLine + 1);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user