Commit 787787ed authored by hjk's avatar hjk
Browse files

fakevim: fix shift left in visual mode

parent eb60cf1d
...@@ -2669,19 +2669,17 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat) ...@@ -2669,19 +2669,17 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
int endLine = lineForPosition(position()); int endLine = lineForPosition(position());
if (beginLine > endLine) if (beginLine > endLine)
qSwap(beginLine, endLine); qSwap(beginLine, endLine);
int shift = config(ConfigShiftWidth).toInt() * repeat; const int shift = config(ConfigShiftWidth).toInt() * repeat;
int tab = config(ConfigTabStop).toInt(); const int tab = config(ConfigTabStop).toInt();
int firstPos = firstPositionInLine(beginLine); const int firstPos = firstPositionInLine(beginLine);
beginEditBlock(firstPos); beginEditBlock(firstPos);
for (int line = beginLine; line <= endLine; ++line) { for (int line = endLine; line >= beginLine; --line) {
int pos = firstPositionInLine(line); int pos = firstPositionInLine(line);
setPosition(pos); const QString text = lineContents(line);
setAnchor(pos);
QString text = m_tc.block().text();
int amount = 0; int amount = 0;
int i = 0; int i = 0;
for (; i < text.size() && amount <= shift; ++i) { for (; i < text.size() && amount < shift; ++i) {
if (text.at(i) == ' ') if (text.at(i) == ' ')
amount++; amount++;
else if (text.at(i) == '\t') else if (text.at(i) == '\t')
...@@ -2689,9 +2687,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat) ...@@ -2689,9 +2687,7 @@ void FakeVimHandler::Private::shiftRegionLeft(int repeat)
else else
break; break;
} }
setPosition(pos + i); removeText(Range(pos, pos + i));
text = selectedText();
removeSelectedText();
setPosition(pos); setPosition(pos);
} }
endEditBlock(); endEditBlock();
......
Markdown is supported
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