Commit aa6c5526 authored by hjk's avatar hjk
Browse files

fakevim: better cursor poistioning after indenting

parent ed853ee4
...@@ -698,8 +698,10 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand) ...@@ -698,8 +698,10 @@ void FakeVimHandler::Private::finishMovement(const QString &dotCommand)
} else if (m_submode == ReplaceSubMode) { } else if (m_submode == ReplaceSubMode) {
m_submode = NoSubMode; m_submode = NoSubMode;
} else if (m_submode == IndentSubMode) { } else if (m_submode == IndentSubMode) {
recordJump();
indentRegion(); indentRegion();
m_submode = NoSubMode; m_submode = NoSubMode;
updateMiniBuffer();
} else if (m_submode == ShiftRightSubMode) { } else if (m_submode == ShiftRightSubMode) {
recordJump(); recordJump();
shiftRegionRight(1); shiftRegionRight(1);
...@@ -2057,8 +2059,13 @@ void FakeVimHandler::Private::indentRegion(QChar typedChar) ...@@ -2057,8 +2059,13 @@ void FakeVimHandler::Private::indentRegion(QChar typedChar)
int endLine = lineForPosition(position()); int endLine = lineForPosition(position());
if (beginLine > endLine) if (beginLine > endLine)
qSwap(beginLine, endLine); qSwap(beginLine, endLine);
int amount = 0; int amount = 0;
emit q->indentRegion(&amount, beginLine, endLine, typedChar); emit q->indentRegion(&amount, beginLine, endLine, typedChar);
setPosition(firstPositionInLine(beginLine));
moveToFirstNonBlankOnLine();
setTargetColumn();
setDotCommand("%1==", endLine - beginLine + 1); setDotCommand("%1==", endLine - beginLine + 1);
} }
...@@ -2072,8 +2079,6 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat) ...@@ -2072,8 +2079,6 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
QString indent(len, ' '); QString indent(len, ' ');
int firstPos = firstPositionInLine(beginLine); int firstPos = firstPositionInLine(beginLine);
//setPosition(firstPos);
for (int line = beginLine; line <= endLine; ++line) { for (int line = beginLine; line <= endLine; ++line) {
setPosition(firstPositionInLine(line)); setPosition(firstPositionInLine(line));
m_tc.insertText(indent); m_tc.insertText(indent);
...@@ -2081,6 +2086,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat) ...@@ -2081,6 +2086,7 @@ void FakeVimHandler::Private::shiftRegionRight(int repeat)
setPosition(firstPos); setPosition(firstPos);
moveToFirstNonBlankOnLine(); moveToFirstNonBlankOnLine();
setTargetColumn();
setDotCommand("%1>>", endLine - beginLine + 1); setDotCommand("%1>>", endLine - beginLine + 1);
} }
...@@ -2094,8 +2100,6 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat) ...@@ -2094,8 +2100,6 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
int tab = config(ConfigTabStop).toInt(); int tab = config(ConfigTabStop).toInt();
int firstPos = firstPositionInLine(beginLine); int firstPos = firstPositionInLine(beginLine);
//setPosition(firstPos);
for (int line = beginLine; line <= endLine; ++line) { for (int line = beginLine; line <= endLine; ++line) {
int pos = firstPositionInLine(line); int pos = firstPositionInLine(line);
setPosition(pos); setPosition(pos);
...@@ -2118,6 +2122,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat) ...@@ -2118,6 +2122,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
setPosition(firstPos); setPosition(firstPos);
moveToFirstNonBlankOnLine(); moveToFirstNonBlankOnLine();
setTargetColumn();
setDotCommand("%1<<", endLine - beginLine + 1); setDotCommand("%1<<", endLine - beginLine + 1);
} }
......
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