feature(key) vim: add ability to navigate using to first and last file using ^ and $

This commit is contained in:
coderaiser 2020-08-14 18:35:46 +03:00
parent 87f4022759
commit 750b7571f5
3 changed files with 49 additions and 6 deletions

View file

@ -270,7 +270,7 @@ test('cloudcmd: client: key: selectFile', (t) => {
t.end();
});
test('cloudcmd: client: key: set last file current', (t) => {
test('cloudcmd: client: key: set last file current: shift + g', (t) => {
const last = 'last';
const nextSibling = {
nextSibling: last,
@ -291,7 +291,28 @@ test('cloudcmd: client: key: set last file current', (t) => {
t.end();
});
test('cloudcmd: client: key: set first file current', (t) => {
test('cloudcmd: client: key: set last file current: $', (t) => {
const last = 'last';
const nextSibling = {
nextSibling: last,
};
const element = {
nextSibling,
};
const setCurrentFile = stub();
global.DOM.CurrentInfo.element = element;
global.DOM.setCurrentFile = setCurrentFile;
vim('$', {});
t.ok(setCurrentFile.calledWith(last), 'should set last file');
t.end();
});
test('cloudcmd: client: key: set first file current: gg', (t) => {
const first = 'first';
const previousSibling = {
previousSibling: first,
@ -314,6 +335,28 @@ test('cloudcmd: client: key: set first file current', (t) => {
t.end();
});
test('cloudcmd: client: key: set first file current: ^', (t) => {
const first = 'first';
const previousSibling = {
previousSibling: first,
};
const element = {
previousSibling,
};
const setCurrentFile = stub();
global.DOM.CurrentInfo.element = element;
global.DOM.setCurrentFile = setCurrentFile;
vim('^', {});
t.ok(setCurrentFile.calledWith(first), 'should set first file');
t.end();
});
test('cloudcmd: client: key: visual', (t) => {
const element = {
};

View file

@ -79,7 +79,7 @@ module.exports = (key, operations) => {
return end();
}
if (/^gg$/.test(value)) {
if (value === 'gg' || key === '^') {
const {
isDelete,
isVisual,
@ -100,7 +100,7 @@ module.exports = (key, operations) => {
return end();
}
if (key === 'G') {
if (key === 'G' || key === '$') {
moveNext({
count: Infinity,
isVisual,