feature(key) vim: add ability to navigate to next and previous using w and b

This commit is contained in:
coderaiser 2020-08-14 19:04:49 +03:00
parent 750b7571f5
commit 291dc39c25
2 changed files with 55 additions and 2 deletions

View file

@ -47,7 +47,7 @@ module.exports = (key, operations) => {
return end();
}
if (key === 'j') {
if (key === 'j' || key === 'w') {
const {
count,
isDelete,
@ -63,7 +63,7 @@ module.exports = (key, operations) => {
return end();
}
if (key === 'k') {
if (key === 'k' || key === 'b') {
const {
count,
isDelete,

View file

@ -1,6 +1,8 @@
'use strict';
const test = require('supertape');
const stub = require('@cloudcmd/stub');
const vim = require('./vim');
test('vim: no operations', (t) => {
@ -10,3 +12,54 @@ test('vim: no operations', (t) => {
t.end();
});
test('vim: ^', (t) => {
const movePrevious = stub();
vim('^', {
movePrevious,
});
const expected = {
count: Infinity,
isVisual: false,
isDelete: false,
};
t.ok(movePrevious.calledWith(expected), 'should call movePrevious');
t.end();
});
test('vim: w', (t) => {
const moveNext = stub();
vim('w', {
moveNext,
});
const expected = {
count: 1,
isVisual: false,
isDelete: false,
};
t.ok(moveNext.calledWith(expected), 'should call moveNext');
t.end();
});
test('vim: b', (t) => {
const movePrevious = stub();
vim('b', {
movePrevious,
});
const expected = {
count: 1,
isVisual: false,
isDelete: false,
};
t.ok(movePrevious.calledWith(expected), 'should call movePrevious');
t.end();
});