mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-17 16:38:18 +00:00
feature: client: vim: rr for rename file
This commit is contained in:
parent
acfa27cf74
commit
d82d0335b2
4 changed files with 52 additions and 25 deletions
41
HELP.md
41
HELP.md
|
|
@ -214,26 +214,27 @@ Then, start the server again with `cloudcmd` and reload the page.
|
|||
|
||||
When the `--vim` option is provided, or the configuration parameter `vim` is set, the following hotkeys become available:
|
||||
|
||||
|Key |Operation
|
||||
|:----------------------|:--------------------------------------------
|
||||
| `j` | navigate to next file
|
||||
| `k` | navigate to previous file
|
||||
| `dd` | remove current 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
|
||||
| `Esc` | unselect all
|
||||
| `/` | find file in current directory
|
||||
| `n` | navigate to next found file
|
||||
| `N` | navigate to previous found file
|
||||
| `md` | make directory
|
||||
| `mf` | make file
|
||||
| `tt` | show terminal
|
||||
| `e` | edit file
|
||||
| `cc` | copy
|
||||
| `mm` | move
|
||||
| Key |Operation
|
||||
|:------------|:--------------------------------------------
|
||||
| `j` | navigate to next file
|
||||
| `k` | navigate to previous file
|
||||
| `dd` | remove current 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
|
||||
| `Esc` | unselect all
|
||||
| `/` | find file in current directory
|
||||
| `n` | navigate to next found file
|
||||
| `N` | navigate to previous found file
|
||||
| `md` | make directory
|
||||
| `mf` | make file
|
||||
| `tt` | show terminal
|
||||
| `e` | edit file
|
||||
| `cc` | copy
|
||||
| `mm` | move
|
||||
| `rr` | rename file
|
||||
|
||||
Commands can be joined, for example:
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
/* global CloudCmd */
|
||||
/* global DOM */
|
||||
import vim from './vim.js';
|
||||
import * as finder from './find.js';
|
||||
import {
|
||||
|
|
@ -35,12 +33,13 @@ const getOperations = (event, deps) => {
|
|||
prompt = globalThis.DOM.Dialog.prompt,
|
||||
preventDefault = event?.preventDefault?.bind(event),
|
||||
stopImmediatePropagation = event?.preventDefault?.bind(event),
|
||||
promptNewFile = DOM.promptNewFile,
|
||||
promptNewFile = globalThis.DOM.promptNewFile,
|
||||
toggleSelectedFile,
|
||||
Buffer = {},
|
||||
createFindNext = _createFindNext,
|
||||
createFindPrevious = _createFindPrevious,
|
||||
createMakeFile = _createMakeFile,
|
||||
renameCurrent,
|
||||
} = deps;
|
||||
|
||||
return {
|
||||
|
|
@ -56,7 +55,10 @@ const getOperations = (event, deps) => {
|
|||
setCurrentByName,
|
||||
}),
|
||||
escape: unselectFiles,
|
||||
|
||||
rename: () => {
|
||||
event.preventDefault();
|
||||
renameCurrent();
|
||||
},
|
||||
remove: () => {
|
||||
Operation.show('delete');
|
||||
},
|
||||
|
|
@ -72,7 +74,7 @@ const getOperations = (event, deps) => {
|
|||
makeDirectory: () => {
|
||||
event.stopImmediatePropagation();
|
||||
event.preventDefault();
|
||||
DOM.promptNewDir();
|
||||
globalThis.DOM.promptNewDir();
|
||||
},
|
||||
|
||||
terminal: () => {
|
||||
|
|
|
|||
|
|
@ -657,3 +657,21 @@ test('cloudcmd: client: vim: edit', async (t) => {
|
|||
t.calledWithNoArgs(CloudCmd.EditFileVim.show);
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('cloudcmd: client: vim: rename', async (t) => {
|
||||
const DOM = getDOM();
|
||||
const renameCurrent = stub();
|
||||
|
||||
assign(DOM, {
|
||||
renameCurrent,
|
||||
});
|
||||
|
||||
const event = {
|
||||
preventDefault: stub(),
|
||||
};
|
||||
|
||||
await vim('rr', event, DOM);
|
||||
|
||||
t.calledWithNoArgs(renameCurrent);
|
||||
t.end();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ export default (key, operations = {}) => {
|
|||
edit = noop,
|
||||
operationCopy = noop,
|
||||
operationMove = noop,
|
||||
rename = noop,
|
||||
} = operations;
|
||||
|
||||
if (key === 'Enter')
|
||||
|
|
@ -128,6 +129,11 @@ export default (key, operations = {}) => {
|
|||
return end();
|
||||
}
|
||||
|
||||
if (value === 'rr') {
|
||||
rename();
|
||||
return end();
|
||||
}
|
||||
|
||||
if (key === 'd' && (visual() || prevStore === 'd')) {
|
||||
stopVisual();
|
||||
remove();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue