@lvce-editor/explorer-view 2.41.0 → 2.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/explorerViewWorkerMain.js +220 -148
- package/package.json +1 -1
|
@@ -761,7 +761,7 @@ const send = (transport, method, ...params) => {
|
|
|
761
761
|
const message = create$4(method, params);
|
|
762
762
|
transport.send(message);
|
|
763
763
|
};
|
|
764
|
-
const invoke$
|
|
764
|
+
const invoke$3 = (ipc, method, ...params) => {
|
|
765
765
|
return invokeHelper(ipc, method, params, false);
|
|
766
766
|
};
|
|
767
767
|
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
@@ -794,7 +794,7 @@ const createRpc = ipc => {
|
|
|
794
794
|
send(ipc, method, ...params);
|
|
795
795
|
},
|
|
796
796
|
invoke(method, ...params) {
|
|
797
|
-
return invoke$
|
|
797
|
+
return invoke$3(ipc, method, ...params);
|
|
798
798
|
},
|
|
799
799
|
invokeAndTransfer(method, ...params) {
|
|
800
800
|
return invokeAndTransfer(ipc, method, ...params);
|
|
@@ -891,10 +891,14 @@ const RendererWorker = {
|
|
|
891
891
|
};
|
|
892
892
|
|
|
893
893
|
const {
|
|
894
|
-
invoke,
|
|
894
|
+
invoke: invoke$1,
|
|
895
895
|
set: set$1
|
|
896
896
|
} = RendererWorker;
|
|
897
897
|
|
|
898
|
+
const invoke = async (method, ...params) => {
|
|
899
|
+
return invoke$1(method, ...params);
|
|
900
|
+
};
|
|
901
|
+
|
|
898
902
|
const remove = async dirent => {
|
|
899
903
|
return invoke('FileSystem.remove', dirent);
|
|
900
904
|
};
|
|
@@ -1001,92 +1005,6 @@ const CreateFile = 1;
|
|
|
1001
1005
|
const CreateFolder = 2;
|
|
1002
1006
|
const Rename$1 = 3;
|
|
1003
1007
|
|
|
1004
|
-
const emptyObject = {};
|
|
1005
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1006
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1007
|
-
if (placeholders === emptyObject) {
|
|
1008
|
-
return key;
|
|
1009
|
-
}
|
|
1010
|
-
const replacer = (match, rest) => {
|
|
1011
|
-
return placeholders[rest];
|
|
1012
|
-
};
|
|
1013
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
|
-
const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
|
|
1017
|
-
const Copy$1 = 'Copy';
|
|
1018
|
-
const CopyPath = 'Copy Path';
|
|
1019
|
-
const CopyRelativePath = 'Copy Relative Path';
|
|
1020
|
-
const Cut$1 = 'Cut';
|
|
1021
|
-
const Delete$1 = 'Delete';
|
|
1022
|
-
const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
|
|
1023
|
-
const FilesExplorer = 'Files Explorer';
|
|
1024
|
-
const NewFile$1 = 'New File...';
|
|
1025
|
-
const NewFolder$1 = 'New Folder...';
|
|
1026
|
-
const OpenContainingFolder = 'Open Containing Folder';
|
|
1027
|
-
const OpenFolder = 'Open folder';
|
|
1028
|
-
const OpenInIntegratedTerminal = 'Open in integrated Terminal';
|
|
1029
|
-
const Paste = 'Paste';
|
|
1030
|
-
const RefreshExplorer = 'Refresh Explorer';
|
|
1031
|
-
const Rename = 'Rename';
|
|
1032
|
-
const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
|
|
1033
|
-
const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
|
|
1034
|
-
|
|
1035
|
-
const newFile$1 = () => {
|
|
1036
|
-
return i18nString(NewFile$1);
|
|
1037
|
-
};
|
|
1038
|
-
const newFolder$1 = () => {
|
|
1039
|
-
return i18nString(NewFolder$1);
|
|
1040
|
-
};
|
|
1041
|
-
const openContainingFolder$1 = () => {
|
|
1042
|
-
return i18nString(OpenContainingFolder);
|
|
1043
|
-
};
|
|
1044
|
-
const openInIntegratedTerminal = () => {
|
|
1045
|
-
return i18nString(OpenInIntegratedTerminal);
|
|
1046
|
-
};
|
|
1047
|
-
const cut = () => {
|
|
1048
|
-
return i18nString(Cut$1);
|
|
1049
|
-
};
|
|
1050
|
-
const copy = () => {
|
|
1051
|
-
return i18nString(Copy$1);
|
|
1052
|
-
};
|
|
1053
|
-
const paste = () => {
|
|
1054
|
-
return i18nString(Paste);
|
|
1055
|
-
};
|
|
1056
|
-
const copyPath$1 = () => {
|
|
1057
|
-
return i18nString(CopyPath);
|
|
1058
|
-
};
|
|
1059
|
-
const copyRelativePath$1 = () => {
|
|
1060
|
-
return i18nString(CopyRelativePath);
|
|
1061
|
-
};
|
|
1062
|
-
const rename = () => {
|
|
1063
|
-
return i18nString(Rename);
|
|
1064
|
-
};
|
|
1065
|
-
const deleteItem = () => {
|
|
1066
|
-
return i18nString(Delete$1);
|
|
1067
|
-
};
|
|
1068
|
-
const refresh$1 = () => {
|
|
1069
|
-
return i18nString(RefreshExplorer);
|
|
1070
|
-
};
|
|
1071
|
-
const collapseAll$1 = () => {
|
|
1072
|
-
return i18nString(CollapseAllFoldersInExplorer);
|
|
1073
|
-
};
|
|
1074
|
-
const filesExplorer = () => {
|
|
1075
|
-
return i18nString(FilesExplorer);
|
|
1076
|
-
};
|
|
1077
|
-
const youHaveNotYetOpenedAFolder = () => {
|
|
1078
|
-
return i18nString(YouHaveNotYetOpenedAFolder);
|
|
1079
|
-
};
|
|
1080
|
-
const openFolder$1 = () => {
|
|
1081
|
-
return i18nString(OpenFolder);
|
|
1082
|
-
};
|
|
1083
|
-
const fileOrFolderNameMustBeProvided = () => {
|
|
1084
|
-
return i18nString(FileOrFolderNameMustBeProvider);
|
|
1085
|
-
};
|
|
1086
|
-
const typeAFileName = () => {
|
|
1087
|
-
return i18nString(TypeAFileName);
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
1008
|
const List = 1;
|
|
1091
1009
|
const Input$1 = 2;
|
|
1092
1010
|
|
|
@@ -1163,7 +1081,7 @@ const requestFileIcons = async requests => {
|
|
|
1163
1081
|
return [];
|
|
1164
1082
|
}
|
|
1165
1083
|
const simpleRequests = requests.map(toSimpleIconRequest);
|
|
1166
|
-
const icons = await invoke('IconTheme.getIcons', simpleRequests);
|
|
1084
|
+
const icons = await invoke$1('IconTheme.getIcons', simpleRequests);
|
|
1167
1085
|
return icons;
|
|
1168
1086
|
};
|
|
1169
1087
|
|
|
@@ -1447,6 +1365,100 @@ const treeToArray = (map, root) => {
|
|
|
1447
1365
|
return items;
|
|
1448
1366
|
};
|
|
1449
1367
|
|
|
1368
|
+
const emptyObject = {};
|
|
1369
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1370
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
1371
|
+
if (placeholders === emptyObject) {
|
|
1372
|
+
return key;
|
|
1373
|
+
}
|
|
1374
|
+
const replacer = (match, rest) => {
|
|
1375
|
+
return placeholders[rest];
|
|
1376
|
+
};
|
|
1377
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1378
|
+
};
|
|
1379
|
+
|
|
1380
|
+
const CollapseAllFoldersInExplorer = 'Collapse All Folders in Explorer';
|
|
1381
|
+
const Copy$1 = 'Copy';
|
|
1382
|
+
const CopyPath = 'Copy Path';
|
|
1383
|
+
const CopyRelativePath = 'Copy Relative Path';
|
|
1384
|
+
const Cut$1 = 'Cut';
|
|
1385
|
+
const Delete$1 = 'Delete';
|
|
1386
|
+
const FileOrFolderNameMustBeProvider = 'A file or folder name must be provided.';
|
|
1387
|
+
const FilesExplorer = 'Files Explorer';
|
|
1388
|
+
const NewFile$1 = 'New File...';
|
|
1389
|
+
const NewFolder$1 = 'New Folder...';
|
|
1390
|
+
const OpenContainingFolder = 'Open Containing Folder';
|
|
1391
|
+
const OpenFolder = 'Open folder';
|
|
1392
|
+
const OpenInIntegratedTerminal = 'Open in integrated Terminal';
|
|
1393
|
+
const Paste = 'Paste';
|
|
1394
|
+
const RefreshExplorer = 'Refresh Explorer';
|
|
1395
|
+
const Rename = 'Rename';
|
|
1396
|
+
const TypeAFileName = 'Type file name. Press Enter to confirm or Escape to cancel.'; // TODO use keybinding
|
|
1397
|
+
const YouHaveNotYetOpenedAFolder = 'You have not yet opened a folder';
|
|
1398
|
+
|
|
1399
|
+
const newFile$1 = () => {
|
|
1400
|
+
return i18nString(NewFile$1);
|
|
1401
|
+
};
|
|
1402
|
+
const newFolder$1 = () => {
|
|
1403
|
+
return i18nString(NewFolder$1);
|
|
1404
|
+
};
|
|
1405
|
+
const openContainingFolder$1 = () => {
|
|
1406
|
+
return i18nString(OpenContainingFolder);
|
|
1407
|
+
};
|
|
1408
|
+
const openInIntegratedTerminal = () => {
|
|
1409
|
+
return i18nString(OpenInIntegratedTerminal);
|
|
1410
|
+
};
|
|
1411
|
+
const cut = () => {
|
|
1412
|
+
return i18nString(Cut$1);
|
|
1413
|
+
};
|
|
1414
|
+
const copy = () => {
|
|
1415
|
+
return i18nString(Copy$1);
|
|
1416
|
+
};
|
|
1417
|
+
const paste = () => {
|
|
1418
|
+
return i18nString(Paste);
|
|
1419
|
+
};
|
|
1420
|
+
const copyPath$1 = () => {
|
|
1421
|
+
return i18nString(CopyPath);
|
|
1422
|
+
};
|
|
1423
|
+
const copyRelativePath$1 = () => {
|
|
1424
|
+
return i18nString(CopyRelativePath);
|
|
1425
|
+
};
|
|
1426
|
+
const rename = () => {
|
|
1427
|
+
return i18nString(Rename);
|
|
1428
|
+
};
|
|
1429
|
+
const deleteItem = () => {
|
|
1430
|
+
return i18nString(Delete$1);
|
|
1431
|
+
};
|
|
1432
|
+
const refresh$1 = () => {
|
|
1433
|
+
return i18nString(RefreshExplorer);
|
|
1434
|
+
};
|
|
1435
|
+
const collapseAll$1 = () => {
|
|
1436
|
+
return i18nString(CollapseAllFoldersInExplorer);
|
|
1437
|
+
};
|
|
1438
|
+
const filesExplorer = () => {
|
|
1439
|
+
return i18nString(FilesExplorer);
|
|
1440
|
+
};
|
|
1441
|
+
const youHaveNotYetOpenedAFolder = () => {
|
|
1442
|
+
return i18nString(YouHaveNotYetOpenedAFolder);
|
|
1443
|
+
};
|
|
1444
|
+
const openFolder$1 = () => {
|
|
1445
|
+
return i18nString(OpenFolder);
|
|
1446
|
+
};
|
|
1447
|
+
const fileOrFolderNameMustBeProvided = () => {
|
|
1448
|
+
return i18nString(FileOrFolderNameMustBeProvider);
|
|
1449
|
+
};
|
|
1450
|
+
const typeAFileName = () => {
|
|
1451
|
+
return i18nString(TypeAFileName);
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
const validateFileName2 = name => {
|
|
1455
|
+
if (!name) {
|
|
1456
|
+
const editingErrorMessage = fileOrFolderNameMustBeProvided();
|
|
1457
|
+
return editingErrorMessage;
|
|
1458
|
+
}
|
|
1459
|
+
return '';
|
|
1460
|
+
};
|
|
1461
|
+
|
|
1450
1462
|
const acceptCreate = async (state, newDirentType, createFn) => {
|
|
1451
1463
|
const {
|
|
1452
1464
|
editingValue,
|
|
@@ -1460,11 +1472,8 @@ const acceptCreate = async (state, newDirentType, createFn) => {
|
|
|
1460
1472
|
items
|
|
1461
1473
|
} = state;
|
|
1462
1474
|
const newFileName = editingValue;
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
// below input box
|
|
1466
|
-
// await ErrorHandling.showErrorDialog(new Error('file name must not be empty'))
|
|
1467
|
-
const editingErrorMessage = fileOrFolderNameMustBeProvided();
|
|
1475
|
+
const editingErrorMessage = validateFileName2(newFileName);
|
|
1476
|
+
if (editingErrorMessage) {
|
|
1468
1477
|
return {
|
|
1469
1478
|
...state,
|
|
1470
1479
|
editingErrorMessage
|
|
@@ -1511,12 +1520,22 @@ const acceptCreateFolder = async state => {
|
|
|
1511
1520
|
return acceptCreate(state, Directory, mkdir);
|
|
1512
1521
|
};
|
|
1513
1522
|
|
|
1514
|
-
const computeExplorerRenamedDirentUpdate =
|
|
1515
|
-
const
|
|
1516
|
-
const relativeDirname = parentPath.slice(
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1523
|
+
const computeExplorerRenamedDirentUpdate = (root, parentPath, oldUri, children, tree, newUri) => {
|
|
1524
|
+
const rootLength = root.length;
|
|
1525
|
+
const relativeDirname = parentPath.slice(rootLength);
|
|
1526
|
+
const relativeOldPath = oldUri.slice(rootLength);
|
|
1527
|
+
const relativeNewUri = newUri.slice(rootLength);
|
|
1528
|
+
const update = Object.create(null);
|
|
1529
|
+
update[relativeDirname] = children;
|
|
1530
|
+
const oldItems = tree[relativeOldPath] || [];
|
|
1531
|
+
update[relativeNewUri] = oldItems;
|
|
1532
|
+
for (const [key, value] of Object.entries(tree)) {
|
|
1533
|
+
if (key.startsWith(`${relativeOldPath}/`)) {
|
|
1534
|
+
const newKey = `${relativeNewUri}` + key.slice(relativeOldPath.length);
|
|
1535
|
+
update[newKey] = value;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
return update;
|
|
1520
1539
|
};
|
|
1521
1540
|
|
|
1522
1541
|
const createNewDirentsRename = async (renamedDirent, editingValue, pathSeparator) => {
|
|
@@ -1552,15 +1571,24 @@ const acceptRename = async state => {
|
|
|
1552
1571
|
itemHeight,
|
|
1553
1572
|
fileIconCache
|
|
1554
1573
|
} = state;
|
|
1574
|
+
const editingErrorMessage = validateFileName2(editingValue);
|
|
1575
|
+
if (editingErrorMessage) {
|
|
1576
|
+
return {
|
|
1577
|
+
...state,
|
|
1578
|
+
editingErrorMessage
|
|
1579
|
+
};
|
|
1580
|
+
}
|
|
1555
1581
|
const renamedDirent = items[editingIndex];
|
|
1556
1582
|
const successful = await createNewDirentsRename(renamedDirent, editingValue);
|
|
1557
1583
|
if (!successful) {
|
|
1558
1584
|
return state;
|
|
1559
1585
|
}
|
|
1560
|
-
const
|
|
1586
|
+
const oldUri = renamedDirent.path;
|
|
1587
|
+
const dirname = dirname2(oldUri);
|
|
1561
1588
|
const newUri = join2(dirname, editingValue);
|
|
1562
|
-
const
|
|
1589
|
+
const children = await getChildDirents('/', dirname, renamedDirent.depth - 1, []);
|
|
1563
1590
|
const tree = createTree(items, root);
|
|
1591
|
+
const update = computeExplorerRenamedDirentUpdate(root, dirname, oldUri, children, tree, newUri);
|
|
1564
1592
|
const newTree = updateTree2(tree, update);
|
|
1565
1593
|
const newDirents = treeToArray(newTree, root);
|
|
1566
1594
|
const newFocusedIndex = getIndex(newDirents, newUri);
|
|
@@ -1581,7 +1609,9 @@ const acceptRename = async state => {
|
|
|
1581
1609
|
focus: List,
|
|
1582
1610
|
items: newDirents,
|
|
1583
1611
|
icons,
|
|
1584
|
-
fileIconCache: newFileIconCache
|
|
1612
|
+
fileIconCache: newFileIconCache,
|
|
1613
|
+
editingSelectionEnd: 0,
|
|
1614
|
+
editingSelectionStart: 0
|
|
1585
1615
|
};
|
|
1586
1616
|
};
|
|
1587
1617
|
|
|
@@ -1656,7 +1686,9 @@ const cancelEditRename = (state, keepFocus) => {
|
|
|
1656
1686
|
editingValue: '',
|
|
1657
1687
|
editingType: None$5,
|
|
1658
1688
|
editingErrorMessage: '',
|
|
1659
|
-
focus: List
|
|
1689
|
+
focus: List,
|
|
1690
|
+
editingSelectionStart: 0,
|
|
1691
|
+
editingSelectionEnd: 0
|
|
1660
1692
|
};
|
|
1661
1693
|
};
|
|
1662
1694
|
|
|
@@ -1691,14 +1723,27 @@ const toCollapsedDirent = dirent => {
|
|
|
1691
1723
|
return dirent;
|
|
1692
1724
|
};
|
|
1693
1725
|
|
|
1694
|
-
const collapseAll = state => {
|
|
1726
|
+
const collapseAll = async state => {
|
|
1695
1727
|
const {
|
|
1728
|
+
minLineY,
|
|
1729
|
+
height,
|
|
1730
|
+
itemHeight,
|
|
1731
|
+
fileIconCache,
|
|
1696
1732
|
items
|
|
1697
1733
|
} = state;
|
|
1698
1734
|
const newDirents = items.filter(isTopLevel).map(toCollapsedDirent);
|
|
1735
|
+
const dirents = newDirents;
|
|
1736
|
+
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, dirents.length);
|
|
1737
|
+
const visible = dirents.slice(minLineY, maxLineY);
|
|
1738
|
+
const {
|
|
1739
|
+
icons,
|
|
1740
|
+
newFileIconCache
|
|
1741
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
1699
1742
|
return {
|
|
1700
1743
|
...state,
|
|
1701
|
-
items: newDirents
|
|
1744
|
+
items: newDirents,
|
|
1745
|
+
icons,
|
|
1746
|
+
fileIconCache: newFileIconCache
|
|
1702
1747
|
};
|
|
1703
1748
|
};
|
|
1704
1749
|
|
|
@@ -1722,13 +1767,13 @@ const copyPath = async state => {
|
|
|
1722
1767
|
};
|
|
1723
1768
|
|
|
1724
1769
|
const writeText = async text => {
|
|
1725
|
-
await invoke('ClipBoard.writeText', /* text */text);
|
|
1770
|
+
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1726
1771
|
};
|
|
1727
1772
|
const readNativeFiles = async () => {
|
|
1728
|
-
return invoke('ClipBoard.readNativeFiles');
|
|
1773
|
+
return invoke$1('ClipBoard.readNativeFiles');
|
|
1729
1774
|
};
|
|
1730
1775
|
const writeNativeFiles = async (type, files) => {
|
|
1731
|
-
return invoke('ClipBoard.writeNativeFiles', type, files);
|
|
1776
|
+
return invoke$1('ClipBoard.writeNativeFiles', type, files);
|
|
1732
1777
|
};
|
|
1733
1778
|
|
|
1734
1779
|
const copyRelativePath = async state => {
|
|
@@ -1844,10 +1889,8 @@ const create2 = (uid, uri, x, y, width, height, args, parentUid, platform = 0) =
|
|
|
1844
1889
|
focus: 0,
|
|
1845
1890
|
editingErrorMessage: '',
|
|
1846
1891
|
inputSource: 0,
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
end: 0
|
|
1850
|
-
},
|
|
1892
|
+
editingSelectionEnd: 0,
|
|
1893
|
+
editingSelectionStart: 0,
|
|
1851
1894
|
focusWord: '',
|
|
1852
1895
|
focusWordTimeout: 800,
|
|
1853
1896
|
finalDeltaY: 0,
|
|
@@ -1891,10 +1934,8 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0) =>
|
|
|
1891
1934
|
focus: 0,
|
|
1892
1935
|
editingErrorMessage: '',
|
|
1893
1936
|
inputSource: 0,
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
end: 0
|
|
1897
|
-
},
|
|
1937
|
+
editingSelectionStart: 0,
|
|
1938
|
+
editingSelectionEnd: 0,
|
|
1898
1939
|
focusWord: '',
|
|
1899
1940
|
focusWordTimeout: 800,
|
|
1900
1941
|
finalDeltaY: 0,
|
|
@@ -1924,7 +1965,7 @@ const isEqual$3 = (oldState, newState) => {
|
|
|
1924
1965
|
|
|
1925
1966
|
const diffType$1 = RenderSelection;
|
|
1926
1967
|
const isEqual$2 = (oldState, newState) => {
|
|
1927
|
-
return oldState.
|
|
1968
|
+
return oldState.editingSelectionStart === newState.editingSelectionStart && oldState.editingSelectionEnd === newState.editingSelectionEnd;
|
|
1928
1969
|
};
|
|
1929
1970
|
|
|
1930
1971
|
const diffType = RenderValue;
|
|
@@ -2615,7 +2656,7 @@ const handleArrowRightDirectoryExpanded = (state, dirent) => {
|
|
|
2615
2656
|
};
|
|
2616
2657
|
|
|
2617
2658
|
const setFocus = key => {
|
|
2618
|
-
return invoke('Focus.setFocus', key);
|
|
2659
|
+
return invoke$1('Focus.setFocus', key);
|
|
2619
2660
|
};
|
|
2620
2661
|
|
|
2621
2662
|
const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
@@ -2664,7 +2705,7 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
2664
2705
|
};
|
|
2665
2706
|
|
|
2666
2707
|
const openUri = async (uri, focus) => {
|
|
2667
|
-
await invoke(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
|
|
2708
|
+
await invoke$1(/* Main.openAbsolutePath */'Main.openUri', /* absolutePath */uri, /* focus */focus);
|
|
2668
2709
|
};
|
|
2669
2710
|
|
|
2670
2711
|
const handleClickFile = async (state, dirent, index, keepFocus = false) => {
|
|
@@ -2925,7 +2966,7 @@ const handleClickOpenFolder = async state => {
|
|
|
2925
2966
|
};
|
|
2926
2967
|
|
|
2927
2968
|
const show = async (x, y, id, ...args) => {
|
|
2928
|
-
return invoke('ContextMenu.show', x, y, id, ...args);
|
|
2969
|
+
return invoke$1('ContextMenu.show', x, y, id, ...args);
|
|
2929
2970
|
};
|
|
2930
2971
|
|
|
2931
2972
|
const Explorer$1 = 4;
|
|
@@ -3074,8 +3115,12 @@ const getExpandedDirents = items => {
|
|
|
3074
3115
|
const getPathDirentsMap = async allPaths => {
|
|
3075
3116
|
const pathToDirents = Object.create(null);
|
|
3076
3117
|
await Promise.all(allPaths.map(async path => {
|
|
3077
|
-
|
|
3078
|
-
|
|
3118
|
+
try {
|
|
3119
|
+
const dirents = await readDirWithFileTypes(path);
|
|
3120
|
+
pathToDirents[path] = dirents;
|
|
3121
|
+
} catch {
|
|
3122
|
+
// ignore
|
|
3123
|
+
}
|
|
3079
3124
|
}));
|
|
3080
3125
|
return pathToDirents;
|
|
3081
3126
|
};
|
|
@@ -3431,12 +3476,12 @@ const getFileArray = fileList => {
|
|
|
3431
3476
|
};
|
|
3432
3477
|
|
|
3433
3478
|
const getFileHandles = async fileIds => {
|
|
3434
|
-
const files = await invoke('FileSystemHandle.getFileHandles', fileIds);
|
|
3479
|
+
const files = await invoke$1('FileSystemHandle.getFileHandles', fileIds);
|
|
3435
3480
|
return files;
|
|
3436
3481
|
};
|
|
3437
3482
|
|
|
3438
3483
|
const getFilePathElectron = async file => {
|
|
3439
|
-
return invoke('FileSystemHandle.getFilePathElectron', file);
|
|
3484
|
+
return invoke$1('FileSystemHandle.getFilePathElectron', file);
|
|
3440
3485
|
};
|
|
3441
3486
|
|
|
3442
3487
|
const getFilepath = async file => {
|
|
@@ -3563,7 +3608,7 @@ const handleKeyDown = (state, key) => {
|
|
|
3563
3608
|
// @ts-ignore
|
|
3564
3609
|
// eslint-disable-next-line @typescript-eslint/no-misused-promises
|
|
3565
3610
|
timeout = setTimeout(async () => {
|
|
3566
|
-
await invoke('Explorer.cancelTypeAhead');
|
|
3611
|
+
await invoke$1('Explorer.cancelTypeAhead');
|
|
3567
3612
|
}, focusWordTimeout);
|
|
3568
3613
|
if (matchingIndex === -1) {
|
|
3569
3614
|
return {
|
|
@@ -3758,11 +3803,11 @@ const handleWheel = (state, deltaMode, deltaY) => {
|
|
|
3758
3803
|
};
|
|
3759
3804
|
|
|
3760
3805
|
const getWorkspacePath = () => {
|
|
3761
|
-
return invoke('Workspace.getPath');
|
|
3806
|
+
return invoke$1('Workspace.getPath');
|
|
3762
3807
|
};
|
|
3763
3808
|
|
|
3764
3809
|
const getSettings = async () => {
|
|
3765
|
-
const useChevronsRaw = await invoke('Preferences.get', 'explorer.useChevrons');
|
|
3810
|
+
const useChevronsRaw = await invoke$1('Preferences.get', 'explorer.useChevrons');
|
|
3766
3811
|
const useChevrons = useChevronsRaw === false ? false : true;
|
|
3767
3812
|
return {
|
|
3768
3813
|
useChevrons
|
|
@@ -4083,7 +4128,7 @@ const getContainingFolder = (root, dirents, focusedIndex, pathSeparator) => {
|
|
|
4083
4128
|
};
|
|
4084
4129
|
|
|
4085
4130
|
const openNativeFolder = async path => {
|
|
4086
|
-
await invoke('OpenNativeFolder.openNativeFolder', /* path */path);
|
|
4131
|
+
await invoke$1('OpenNativeFolder.openNativeFolder', /* path */path);
|
|
4087
4132
|
};
|
|
4088
4133
|
|
|
4089
4134
|
const openContainingFolder = async state => {
|
|
@@ -4127,10 +4172,18 @@ const removeDirent = async state => {
|
|
|
4127
4172
|
return newState;
|
|
4128
4173
|
};
|
|
4129
4174
|
|
|
4175
|
+
const getEditingType = direntType => {
|
|
4176
|
+
if (direntType < DELTA_EDITING) {
|
|
4177
|
+
return direntType + DELTA_EDITING;
|
|
4178
|
+
}
|
|
4179
|
+
return direntType;
|
|
4180
|
+
};
|
|
4181
|
+
|
|
4130
4182
|
const getNewDirentsForRename = (items, focusedIndex) => {
|
|
4131
4183
|
const item = items[focusedIndex];
|
|
4132
4184
|
const newItems = [...items];
|
|
4133
|
-
const editingType = item.type
|
|
4185
|
+
const editingType = getEditingType(item.type);
|
|
4186
|
+
// TODO avoid mutation
|
|
4134
4187
|
newItems[focusedIndex] = {
|
|
4135
4188
|
...item,
|
|
4136
4189
|
type: editingType
|
|
@@ -4138,6 +4191,20 @@ const getNewDirentsForRename = (items, focusedIndex) => {
|
|
|
4138
4191
|
return newItems;
|
|
4139
4192
|
};
|
|
4140
4193
|
|
|
4194
|
+
const getRenameSelectionRange = name => {
|
|
4195
|
+
const dotIndex = name.lastIndexOf('.');
|
|
4196
|
+
if (dotIndex === -1) {
|
|
4197
|
+
return {
|
|
4198
|
+
start: 0,
|
|
4199
|
+
end: name.length
|
|
4200
|
+
};
|
|
4201
|
+
}
|
|
4202
|
+
return {
|
|
4203
|
+
start: 0,
|
|
4204
|
+
end: dotIndex
|
|
4205
|
+
};
|
|
4206
|
+
};
|
|
4207
|
+
|
|
4141
4208
|
const User = 1;
|
|
4142
4209
|
const Script = 2;
|
|
4143
4210
|
|
|
@@ -4153,6 +4220,10 @@ const renameDirent = state => {
|
|
|
4153
4220
|
}
|
|
4154
4221
|
const item = items[focusedIndex];
|
|
4155
4222
|
const newItems = getNewDirentsForRename(items, focusedIndex);
|
|
4223
|
+
const {
|
|
4224
|
+
start,
|
|
4225
|
+
end
|
|
4226
|
+
} = getRenameSelectionRange(item.name);
|
|
4156
4227
|
return {
|
|
4157
4228
|
...state,
|
|
4158
4229
|
items: newItems,
|
|
@@ -4160,21 +4231,24 @@ const renameDirent = state => {
|
|
|
4160
4231
|
editingType: Rename$1,
|
|
4161
4232
|
editingValue: item.name,
|
|
4162
4233
|
editingIcon: icons[focusedIndex - minLineY],
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
end: item.name.length
|
|
4166
|
-
},
|
|
4234
|
+
editingSelectionStart: start,
|
|
4235
|
+
editingSelectionEnd: end,
|
|
4167
4236
|
focus: Input$1,
|
|
4168
4237
|
inputSource: Script
|
|
4169
4238
|
};
|
|
4170
4239
|
};
|
|
4171
4240
|
|
|
4241
|
+
const ExplorerInput = 'ExplorerInput';
|
|
4242
|
+
|
|
4172
4243
|
const renderEditingSelection = (oldState, newState) => {
|
|
4173
|
-
|
|
4244
|
+
const {
|
|
4245
|
+
editingSelectionStart,
|
|
4246
|
+
editingSelectionEnd,
|
|
4247
|
+
uid
|
|
4248
|
+
} = newState;
|
|
4249
|
+
return ['Viewlet.setSelectionByName', uid, ExplorerInput, editingSelectionStart, editingSelectionEnd];
|
|
4174
4250
|
};
|
|
4175
4251
|
|
|
4176
|
-
const ExplorerInput = 'ExplorerInput';
|
|
4177
|
-
|
|
4178
4252
|
const renderFocus$1 = (oldState, newState) => {
|
|
4179
4253
|
if (newState.inputSource === User) {
|
|
4180
4254
|
return [];
|
|
@@ -4682,10 +4756,6 @@ const getRenderer = diffType => {
|
|
|
4682
4756
|
const applyRender = (oldState, newState, diffResult) => {
|
|
4683
4757
|
const commands = [];
|
|
4684
4758
|
for (const item of diffResult) {
|
|
4685
|
-
if (item === RenderSelection) {
|
|
4686
|
-
// TODO support this in the future
|
|
4687
|
-
continue;
|
|
4688
|
-
}
|
|
4689
4759
|
const fn = getRenderer(item);
|
|
4690
4760
|
const result = fn(oldState, newState);
|
|
4691
4761
|
if (result.length > 0) {
|
|
@@ -5114,24 +5184,24 @@ const terminate = () => {
|
|
|
5114
5184
|
|
|
5115
5185
|
const getEditingIcon = async (editingType, value, direntType) => {
|
|
5116
5186
|
if (editingType === CreateFile) {
|
|
5117
|
-
return invoke('IconTheme.getFileIcon', {
|
|
5187
|
+
return invoke$1('IconTheme.getFileIcon', {
|
|
5118
5188
|
name: value
|
|
5119
5189
|
});
|
|
5120
5190
|
}
|
|
5121
5191
|
if (editingType === Rename$1) {
|
|
5122
5192
|
if (direntType === File || direntType === EditingFile) {
|
|
5123
|
-
return invoke('IconTheme.getFileIcon', {
|
|
5193
|
+
return invoke$1('IconTheme.getFileIcon', {
|
|
5124
5194
|
name: value
|
|
5125
5195
|
});
|
|
5126
5196
|
}
|
|
5127
|
-
if (direntType === Directory || direntType === EditingFolder) {
|
|
5128
|
-
return invoke('IconTheme.getFolderIcon', {
|
|
5197
|
+
if (direntType === Directory || direntType === EditingFolder || direntType === EditingDirectoryExpanded) {
|
|
5198
|
+
return invoke$1('IconTheme.getFolderIcon', {
|
|
5129
5199
|
name: value
|
|
5130
5200
|
});
|
|
5131
5201
|
}
|
|
5132
5202
|
}
|
|
5133
5203
|
if (editingType === CreateFolder) {
|
|
5134
|
-
return invoke('IconTheme.getFolderIcon', {
|
|
5204
|
+
return invoke$1('IconTheme.getFolderIcon', {
|
|
5135
5205
|
name: value
|
|
5136
5206
|
});
|
|
5137
5207
|
}
|
|
@@ -5145,10 +5215,12 @@ const updateEditingValue = async (state, value, inputSource = User) => {
|
|
|
5145
5215
|
editingIndex
|
|
5146
5216
|
} = state;
|
|
5147
5217
|
const editingIcon = await getEditingIcon(editingType, value, items[editingIndex]?.type);
|
|
5218
|
+
const editingErrorMessage = validateFileName2(value);
|
|
5148
5219
|
return {
|
|
5149
5220
|
...state,
|
|
5150
5221
|
editingValue: value,
|
|
5151
|
-
editingIcon
|
|
5222
|
+
editingIcon,
|
|
5223
|
+
editingErrorMessage
|
|
5152
5224
|
};
|
|
5153
5225
|
};
|
|
5154
5226
|
|