Commit 7a71ee11 authored by Martin Aumüller's avatar Martin Aumüller Committed by hjk
Browse files

fakevim: ctrl-d in insert mode should remove one level of indentation



Merge-request: 113
Reviewed-by: default avatarhjk <qtc-committer@nokia.com>
parent 115b3269
...@@ -2050,6 +2050,24 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int, ...@@ -2050,6 +2050,24 @@ EventResult FakeVimHandler::Private::handleInsertMode(int key, int,
m_lastInsertion.append(str); m_lastInsertion.append(str);
m_tc.insertText(str); m_tc.insertText(str);
setTargetColumn(); setTargetColumn();
} else if (key == control('d')) {
// remove one level of indentation from the current line
int shift = config(ConfigShiftWidth).toInt();
int tab = config(ConfigTabStop).toInt();
int line = cursorLineInDocument() + 1;
int pos = firstPositionInLine(line);
QString text = lineContents(line);
int amount = 0;
int i = 0;
for (; i < text.size() && amount < shift; ++i) {
if (text.at(i) == ' ')
++amount;
else if (text.at(i) == '\t')
amount += tab; // FIXME: take position into consideration
else
break;
}
removeText(Range(pos, pos+i));
} else if (key >= control('a') && key <= control('z')) { } else if (key >= control('a') && key <= control('z')) {
// ignore these // ignore these
} else if (!text.isEmpty()) { } else if (!text.isEmpty()) {
......
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