diff --git a/HELP.md b/HELP.md index ce1e7af5..59277787 100644 --- a/HELP.md +++ b/HELP.md @@ -158,7 +158,6 @@ Then, start the server again with `cloudcmd` and reload the page. | `F3` | view, change directory | `Shift + F3` | view raw file, change directory | `F4` | edit -| `Shift + F4` | edit in "vim" mode | `F5` | copy | `Alt` + `F5` | pack | `F6` | rename/move @@ -182,7 +181,6 @@ Then, start the server again with `cloudcmd` and reload the page. | `Ctrl + D` | clear local storage | `Ctrl + A` | select all files in a panel | `Ctrl + M` | [rename selected files](https://github.com/coderaiser/cloudcmd/releases/tag/v12.1.0) in editor -| `Shift + Ctrl + M` | rename selected files in vim mode of editor | `Ctrl + U` | swap panels | `Ctrl + F3` | sort by name | `Ctrl + F5` | sort by date @@ -201,7 +199,7 @@ Then, start the server again with `cloudcmd` and reload the page. | `Insert` | select current file (and move to next) | `F9` | context menu | `~` | console -| `Esc` | toggle vim hot keys +| `Esc` | toggle vim hotkeys (`file manager`, `editor`) ### Vim diff --git a/client/key/index.js b/client/key/index.js index b8d2c333..79f58552 100644 --- a/client/key/index.js +++ b/client/key/index.js @@ -1,10 +1,9 @@ -/* global CloudCmd, DOM */ - 'use strict'; +/* global CloudCmd, DOM */ + const Info = DOM.CurrentInfo; -const exec = require('execon'); const clipboard = require('@cloudcmd/clipboard'); const Buffer = require('../dom/buffer'); @@ -130,7 +129,11 @@ async function switchKey(event) { isDir, } = Info; - const {Operation, loadDir} = CloudCmd; + const { + Operation, + loadDir, + config, + } = CloudCmd; const {keyCode} = event; const alt = event.altKey; @@ -209,7 +212,7 @@ async function switchKey(event) { break; case KEY.F4: - if (shift) + if (config('vim')) CloudCmd.EditFileVim.show(); else CloudCmd.EditFile.show(); @@ -429,7 +432,7 @@ async function switchKey(event) { case KEY.M: if (ctrlMeta) { - if (shift) + if (config('vim')) CloudCmd.EditNamesVim.show(); else CloudCmd.EditNames.show(); diff --git a/client/key/index.spec.js b/client/key/index.spec.js index aec4bfe3..ae554564 100644 --- a/client/key/index.spec.js +++ b/client/key/index.spec.js @@ -13,12 +13,19 @@ const { getCloudCmd, } = require('./vim/globals.fixture'); -global.DOM = getDOM(); -global.CloudCmd = getCloudCmd(); +const DOM = getDOM(); +const CloudCmd = getCloudCmd(); + +global.DOM = DOM; +global.CloudCmd = CloudCmd; test('cloudcmd: client: key: enable vim', async (t) => { const vim = stub(); + const configStub = stub().returns(true); + const {CloudCmd} = global; + const {config} = CloudCmd; + CloudCmd.config = configStub; mockRequire('./vim', vim); const {_listener, setBind} = reRequire('.'); @@ -31,6 +38,7 @@ test('cloudcmd: client: key: enable vim', async (t) => { setBind(); await _listener(event); + CloudCmd.config = config; stopAll(); t.calledWith(vim, ['Escape', event]); diff --git a/client/key/vim/globals.fixture.js b/client/key/vim/globals.fixture.js index b2134843..ec1fbbcf 100644 --- a/client/key/vim/globals.fixture.js +++ b/client/key/vim/globals.fixture.js @@ -1,5 +1,7 @@ 'use strict'; +const noop = () => {}; + module.exports.getDOM = () => { const prompt = Promise.resolve.bind(Promise); const CurrentInfo = { @@ -7,7 +9,6 @@ module.exports.getDOM = () => { files: [], }; - const noop = () => {}; const Buffer = { copy: noop, paste: noop, @@ -38,6 +39,9 @@ module.exports.getCloudCmd = () => { Operation: { show, }, + + config: noop, + _config: noop, }; }; diff --git a/client/modules/view/view.spec.js b/client/modules/view/index.spec.js similarity index 92% rename from client/modules/view/view.spec.js rename to client/modules/view/index.spec.js index 51f8a998..36df5ee6 100644 --- a/client/modules/view/view.spec.js +++ b/client/modules/view/index.spec.js @@ -17,7 +17,7 @@ test('cloudcmd: client: view: initConfig', (t) => { global.CloudCmd = {}; global.DOM = {}; - const {_initConfig} = reRequire('./view'); + const {_initConfig} = reRequire('.'); const afterClose = () => ++i; const options = { @@ -43,7 +43,7 @@ test('cloudcmd: client: view: initConfig: no options', (t) => { global.CloudCmd = {}; global.DOM = {}; - const {_initConfig} = reRequire('./view'); + const {_initConfig} = reRequire('.'); const config = _initConfig(); global.CloudCmd = CloudCmd; @@ -68,7 +68,7 @@ test('cloudcmd: client: view: html', (t) => { _viewHtml, _createIframe, _Config, - } = reRequire('./view'); + } = reRequire('.'); const src = '/hello.html'; _viewHtml(src);