indentText(range, typedChar);
setPosition(firstPositionInLine(beginLine));
- moveToTargetColumn();
handleStartOfLine();
setTargetColumn();
setDotCommand("%1==", endLine - beginLine + 1);
void FakeVimHandler::Private::shiftRegionRight(int repeat)
{
- setTargetColumn();
int beginLine = lineForPosition(anchor());
int endLine = lineForPosition(position());
- if (beginLine > endLine)
+ int targetPos = anchor();
+ if (beginLine > endLine) {
qSwap(beginLine, endLine);
+ targetPos = position();
+ }
+ if (hasConfig(ConfigStartOfLine))
+ targetPos = firstPositionInLine(beginLine);
+
int len = config(ConfigShiftWidth).toInt() * repeat;
QString indent(len, ' ');
- int firstPos = firstPositionInLine(beginLine);
- beginEditBlock(firstPos);
+ beginEditBlock(targetPos);
for (int line = beginLine; line <= endLine; ++line) {
setPosition(firstPositionInLine(line));
m_tc.insertText(indent);
}
endEditBlock();
- setPosition(firstPos);
- moveToTargetColumn();
+ setPosition(targetPos);
handleStartOfLine();
setTargetColumn();
setDotCommand("%1>>", endLine - beginLine + 1);
void FakeVimHandler::Private::shiftRegionLeft(int repeat)
{
- setTargetColumn();
int beginLine = lineForPosition(anchor());
int endLine = lineForPosition(position());
- if (beginLine > endLine)
+ int targetPos = anchor();
+ if (beginLine > endLine) {
qSwap(beginLine, endLine);
+ targetPos = position();
+ }
const int shift = config(ConfigShiftWidth).toInt() * repeat;
const int tab = config(ConfigTabStop).toInt();
- const int firstPos = firstPositionInLine(beginLine);
+ if (hasConfig(ConfigStartOfLine))
+ targetPos = firstPositionInLine(beginLine);
- beginEditBlock(firstPos);
+ beginEditBlock(targetPos);
for (int line = endLine; line >= beginLine; --line) {
int pos = firstPositionInLine(line);
const QString text = lineContents(line);
}
endEditBlock();
- setPosition(firstPos);
- moveToTargetColumn();
+ setPosition(targetPos);
handleStartOfLine();
setTargetColumn();
setDotCommand("%1<<", endLine - beginLine + 1);