FakeVim: make cursor navigation via arrow keys more like vim's

Change-Id: I2da45281e0f8d2e3a0460a8631241e09aa67b869
Reviewed-by: Lukas Holecek <hluk@email.cz>
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Daniel Langner
2016-09-30 19:58:55 +02:00
committed by hjk
parent b604b8fc2b
commit 920386220b

View File

@@ -3963,11 +3963,11 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
} }
} else if (input.is('b') || input.isShift(Key_Left)) { } else if (input.is('b') || input.isShift(Key_Left)) {
moveToNextWordStart(count, false, false); moveToNextWordStart(count, false, false);
} else if (input.is('B')) { } else if (input.is('B') || input.isControl(Key_Left)) {
moveToNextWordStart(count, true, false); moveToNextWordStart(count, true, false);
} else if (input.is('e') && g.gflag) { } else if (input.is('e') && g.gflag) {
moveToNextWordEnd(count, false, false); moveToNextWordEnd(count, false, false);
} else if (input.is('e') || input.isShift(Key_Right)) { } else if (input.is('e')) {
moveToNextWordEnd(count, false, true, false); moveToNextWordEnd(count, false, true, false);
} else if (input.is('E') && g.gflag) { } else if (input.is('E') && g.gflag) {
moveToNextWordEnd(count, true, false); moveToNextWordEnd(count, true, false);
@@ -4059,11 +4059,12 @@ bool FakeVimHandler::Private::handleMovement(const Input &input)
g.movetype = MoveExclusive; g.movetype = MoveExclusive;
g.subsubmode = FtSubSubMode; g.subsubmode = FtSubSubMode;
g.subsubdata = input; g.subsubdata = input;
} else if (input.is('w') || input.is('W')) { // tested } else if (input.is('w') || input.is('W')
|| input.isShift(Key_Right) || input.isControl(Key_Right)) { // tested
// Special case: "cw" and "cW" work the same as "ce" and "cE" if the // Special case: "cw" and "cW" work the same as "ce" and "cE" if the
// cursor is on a non-blank - except if the cursor is on the last // cursor is on a non-blank - except if the cursor is on the last
// character of a word: only the current word will be changed // character of a word: only the current word will be changed
bool simple = input.is('W'); bool simple = input.is('W') || input.isControl(Key_Right);
if (g.submode == ChangeSubMode && !characterAtCursor().isSpace()) { if (g.submode == ChangeSubMode && !characterAtCursor().isSpace()) {
moveToWordEnd(count, simple, true); moveToWordEnd(count, simple, true);
} else { } else {
@@ -4984,7 +4985,7 @@ void FakeVimHandler::Private::handleInsertMode(const Input &input)
g.mode = ReplaceMode; g.mode = ReplaceMode;
} else if (input.isKey(Key_Left)) { } else if (input.isKey(Key_Left)) {
moveLeft(); moveLeft();
} else if (input.isControl(Key_Left)) { } else if (input.isShift(Key_Left) || input.isControl(Key_Left)) {
moveToNextWordStart(1, false, false); moveToNextWordStart(1, false, false);
} else if (input.isKey(Key_Down)) { } else if (input.isKey(Key_Down)) {
g.submode = NoSubMode; g.submode = NoSubMode;
@@ -4994,9 +4995,8 @@ void FakeVimHandler::Private::handleInsertMode(const Input &input)
moveUp(); moveUp();
} else if (input.isKey(Key_Right)) { } else if (input.isKey(Key_Right)) {
moveRight(); moveRight();
} else if (input.isControl(Key_Right)) { } else if (input.isShift(Key_Right) || input.isControl(Key_Right)) {
moveToNextWordStart(1, false, true); moveToNextWordStart(1, false, true);
moveRight(); // we need one more move since we are in insert mode
} else if (input.isKey(Key_Home)) { } else if (input.isKey(Key_Home)) {
moveToStartOfLine(); moveToStartOfLine();
} else if (input.isKey(Key_End)) { } else if (input.isKey(Key_End)) {