mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(key) vim: add ability to navigate using to first and last file using ^ and $
This commit is contained in:
parent
87f4022759
commit
750b7571f5
3 changed files with 49 additions and 6 deletions
4
HELP.md
4
HELP.md
|
|
@ -216,8 +216,8 @@ When the `--vim` option is provided, or the configuration parameter `vim` is set
|
|||
| `j` | navigate to next file
|
||||
| `k` | navigate to previous file
|
||||
| `dd` | remove current file
|
||||
| `G` | navigate to bottom file
|
||||
| `gg` | navigate to top file
|
||||
| `G` or `$` | navigate to bottom file
|
||||
| `gg` or `^` | navigate to top file
|
||||
| `v` | visual mode
|
||||
| `y` | copy (selected in visual mode files)
|
||||
| `p` | paste files
|
||||
|
|
|
|||
|
|
@ -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 = {
|
||||
};
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue