mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
fix(getFilesRange) avoid selecting of ".."
This commit is contained in:
parent
02e4ca294f
commit
32076acbad
1 changed files with 18 additions and 5 deletions
|
|
@ -25,6 +25,15 @@ module.exports.init = () => {
|
|||
|
||||
CloudCmd.Listeners = module.exports;
|
||||
|
||||
const getIndex = currify((array, item) =>{
|
||||
const index = array.indexOf(item);
|
||||
|
||||
if (!~index)
|
||||
return 0;
|
||||
|
||||
return index;
|
||||
});
|
||||
|
||||
const unselect = (event) => {
|
||||
const isMac = /Mac/.test(window.navigator.platform);
|
||||
const {
|
||||
|
|
@ -361,20 +370,24 @@ function setCurrentFileByEvent(event) {
|
|||
}
|
||||
|
||||
function getFilesRange(from, to) {
|
||||
const files = [...DOM.getFiles()];
|
||||
const files = [...DOM.getFiles()].slice(1);
|
||||
const names = DOM.getFilenames(files);
|
||||
const getNameIndex = getIndex(names);
|
||||
|
||||
const indexFrom = names.indexOf(from) + 1;
|
||||
const indexTo = names.indexOf(to) + 1;
|
||||
const indexFrom = getNameIndex(from);
|
||||
const indexTo = getNameIndex(to);
|
||||
|
||||
return getRange(indexFrom, indexTo, files);
|
||||
}
|
||||
|
||||
function getRange(indexFrom, indexTo, files) {
|
||||
if (indexFrom < indexTo)
|
||||
return files.slice(indexFrom, indexTo + 1);
|
||||
|
||||
if (indexFrom > indexTo)
|
||||
return files.slice(indexTo, indexFrom + 1);
|
||||
|
||||
const file = DOM.getCurrentByName(to);
|
||||
return [file];
|
||||
return files[indexFrom];
|
||||
}
|
||||
|
||||
function contextMenu() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue