@lvce-editor/explorer-view 7.5.0 → 7.6.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 +157 -54
- package/package.json +1 -1
|
@@ -1671,6 +1671,85 @@ const getChildDirentsRaw = async uri => {
|
|
|
1671
1671
|
return rawDirents;
|
|
1672
1672
|
};
|
|
1673
1673
|
|
|
1674
|
+
const dotSlashRegex = /^\.\//;
|
|
1675
|
+
const leadingSlashRegex$1 = /^\//;
|
|
1676
|
+
const regexCharacterRegex = /[\\^$.*+?()[\]{}|]/;
|
|
1677
|
+
const trailingSlashRegex$1 = /\/$/;
|
|
1678
|
+
const escapeRegexCharacter = character => {
|
|
1679
|
+
return regexCharacterRegex.test(character) ? `\\${character}` : character;
|
|
1680
|
+
};
|
|
1681
|
+
const globToRegexSource = glob => {
|
|
1682
|
+
let source = '';
|
|
1683
|
+
for (let i = 0; i < glob.length; i++) {
|
|
1684
|
+
const character = glob[i];
|
|
1685
|
+
if (character === '*') {
|
|
1686
|
+
if (glob[i + 1] === '*') {
|
|
1687
|
+
i++;
|
|
1688
|
+
if (glob[i + 1] === '/') {
|
|
1689
|
+
i++;
|
|
1690
|
+
source += '(?:.*/)?';
|
|
1691
|
+
} else {
|
|
1692
|
+
source += '.*';
|
|
1693
|
+
}
|
|
1694
|
+
} else {
|
|
1695
|
+
source += '[^/]*';
|
|
1696
|
+
}
|
|
1697
|
+
continue;
|
|
1698
|
+
}
|
|
1699
|
+
if (character === '?') {
|
|
1700
|
+
source += '[^/]';
|
|
1701
|
+
continue;
|
|
1702
|
+
}
|
|
1703
|
+
source += escapeRegexCharacter(character);
|
|
1704
|
+
}
|
|
1705
|
+
return source;
|
|
1706
|
+
};
|
|
1707
|
+
const regexCache = new Map();
|
|
1708
|
+
const getRegex = glob => {
|
|
1709
|
+
const cached = regexCache.get(glob);
|
|
1710
|
+
if (cached) {
|
|
1711
|
+
return cached;
|
|
1712
|
+
}
|
|
1713
|
+
const regex = new RegExp(`^${globToRegexSource(glob)}$`);
|
|
1714
|
+
regexCache.set(glob, regex);
|
|
1715
|
+
return regex;
|
|
1716
|
+
};
|
|
1717
|
+
const matchesGlob = (glob, relativePath) => {
|
|
1718
|
+
const normalizedGlob = glob.replaceAll('\\', '/').replace(dotSlashRegex, '').replace(leadingSlashRegex$1, '').replace(trailingSlashRegex$1, '');
|
|
1719
|
+
if (!normalizedGlob) {
|
|
1720
|
+
return false;
|
|
1721
|
+
}
|
|
1722
|
+
const normalizedPath = relativePath.replaceAll('\\', '/').replace(dotSlashRegex, '').replace(leadingSlashRegex$1, '').replace(trailingSlashRegex$1, '');
|
|
1723
|
+
const candidate = normalizedGlob.includes('/') ? normalizedPath : normalizedPath.slice(normalizedPath.lastIndexOf('/') + 1);
|
|
1724
|
+
const regex = getRegex(normalizedGlob);
|
|
1725
|
+
return regex.test(candidate);
|
|
1726
|
+
};
|
|
1727
|
+
|
|
1728
|
+
const leadingSlashRegex = /^\//;
|
|
1729
|
+
const trailingSlashRegex = /\/$/;
|
|
1730
|
+
const getRelativePath$1 = (root, path) => {
|
|
1731
|
+
const normalizedRoot = root.replaceAll('\\', '/').replace(trailingSlashRegex, '');
|
|
1732
|
+
const normalizedPath = path.replaceAll('\\', '/');
|
|
1733
|
+
if (normalizedPath === normalizedRoot) {
|
|
1734
|
+
return '';
|
|
1735
|
+
}
|
|
1736
|
+
if (normalizedPath.startsWith(`${normalizedRoot}/`)) {
|
|
1737
|
+
return normalizedPath.slice(normalizedRoot.length + 1);
|
|
1738
|
+
}
|
|
1739
|
+
return normalizedPath.replace(leadingSlashRegex, '');
|
|
1740
|
+
};
|
|
1741
|
+
const isExcluded = (root, path, excluded) => {
|
|
1742
|
+
const relativePath = getRelativePath$1(root, path);
|
|
1743
|
+
const pathParts = relativePath.split('/');
|
|
1744
|
+
for (let i = 1; i <= pathParts.length; i++) {
|
|
1745
|
+
const candidate = pathParts.slice(0, i).join('/');
|
|
1746
|
+
if (excluded.some(pattern => matchesGlob(pattern, candidate))) {
|
|
1747
|
+
return true;
|
|
1748
|
+
}
|
|
1749
|
+
}
|
|
1750
|
+
return false;
|
|
1751
|
+
};
|
|
1752
|
+
|
|
1674
1753
|
const RE_CHARACTERS = /^[a-zA-Z.-]+$/;
|
|
1675
1754
|
const RE_LEADING_DIGITS = /^\d+/;
|
|
1676
1755
|
const RE_LEADING_ZEROES = /^0+/;
|
|
@@ -1740,10 +1819,10 @@ const toDisplayDirent = (parentPath, parentDepth, rawDirentType, rawDirentName,
|
|
|
1740
1819
|
};
|
|
1741
1820
|
};
|
|
1742
1821
|
|
|
1743
|
-
const toDisplayDirents = (pathSeparator, rawDirents, parentDirentPath, parentDirentDepth, excluded, expanded = false) => {
|
|
1822
|
+
const toDisplayDirents = (pathSeparator, rawDirents, parentDirentPath, parentDirentDepth, excluded, expanded = false, root = parentDirentPath) => {
|
|
1744
1823
|
rawDirents = sortExplorerItems(rawDirents);
|
|
1745
1824
|
const result = [];
|
|
1746
|
-
const visibleItems = rawDirents.filter(item => !
|
|
1825
|
+
const visibleItems = rawDirents.filter(item => !isExcluded(root, join2(parentDirentPath, item.name), excluded));
|
|
1747
1826
|
const count = visibleItems.length;
|
|
1748
1827
|
for (let i = 0; i < visibleItems.length; i++) {
|
|
1749
1828
|
const rawDirent = visibleItems[i];
|
|
@@ -1752,7 +1831,7 @@ const toDisplayDirents = (pathSeparator, rawDirents, parentDirentPath, parentDir
|
|
|
1752
1831
|
return result;
|
|
1753
1832
|
};
|
|
1754
1833
|
|
|
1755
|
-
const getChildDirents = async (pathSeparator, parentDirentPath, parentDirentDepth, excluded = []) => {
|
|
1834
|
+
const getChildDirents = async (pathSeparator, parentDirentPath, parentDirentDepth, excluded = [], root = parentDirentPath) => {
|
|
1756
1835
|
string(pathSeparator);
|
|
1757
1836
|
// TODO use event/actor based code instead, this is impossible to cancel right now
|
|
1758
1837
|
// also cancel updating when opening new folder
|
|
@@ -1761,7 +1840,7 @@ const getChildDirents = async (pathSeparator, parentDirentPath, parentDirentDept
|
|
|
1761
1840
|
// and more typesafe than Command.execute
|
|
1762
1841
|
// and more performant
|
|
1763
1842
|
const rawDirents = await getChildDirentsRaw(parentDirentPath);
|
|
1764
|
-
const displayDirents = toDisplayDirents(pathSeparator, rawDirents, parentDirentPath, parentDirentDepth, excluded);
|
|
1843
|
+
const displayDirents = toDisplayDirents(pathSeparator, rawDirents, parentDirentPath, parentDirentDepth, excluded, false, root);
|
|
1765
1844
|
return displayDirents;
|
|
1766
1845
|
};
|
|
1767
1846
|
|
|
@@ -1789,12 +1868,12 @@ const orderDirents = dirents => {
|
|
|
1789
1868
|
return ordered;
|
|
1790
1869
|
};
|
|
1791
1870
|
|
|
1792
|
-
const getPathPartChildren = async pathPart => {
|
|
1793
|
-
const children = await getChildDirents(pathPart.pathSeparator, pathPart.path, pathPart.depth);
|
|
1871
|
+
const getPathPartChildren = async (pathPart, excluded, root) => {
|
|
1872
|
+
const children = await getChildDirents(pathPart.pathSeparator, pathPart.path, pathPart.depth, excluded, root);
|
|
1794
1873
|
return children;
|
|
1795
1874
|
};
|
|
1796
|
-
const getPathPartsChildren = async pathparts => {
|
|
1797
|
-
const pathPartsChildren = await Promise.all(pathparts.map(getPathPartChildren));
|
|
1875
|
+
const getPathPartsChildren = async (pathparts, excluded = [], root = pathparts[0]?.path || '') => {
|
|
1876
|
+
const pathPartsChildren = await Promise.all(pathparts.map(pathPart => getPathPartChildren(pathPart, excluded, root)));
|
|
1798
1877
|
const pathPartsChildrenFlat = pathPartsChildren.flat();
|
|
1799
1878
|
const orderedPathParts = orderDirents(pathPartsChildrenFlat);
|
|
1800
1879
|
return orderedPathParts;
|
|
@@ -2023,6 +2102,7 @@ const validateFileName2 = (name, siblingFileNames = []) => {
|
|
|
2023
2102
|
const acceptCreate = async (state, newDirentType) => {
|
|
2024
2103
|
const {
|
|
2025
2104
|
editingValue,
|
|
2105
|
+
excluded,
|
|
2026
2106
|
focusedIndex,
|
|
2027
2107
|
items,
|
|
2028
2108
|
pathSeparator,
|
|
@@ -2048,7 +2128,7 @@ const acceptCreate = async (state, newDirentType) => {
|
|
|
2048
2128
|
};
|
|
2049
2129
|
}
|
|
2050
2130
|
const pathPaths = getPathParts(root, absolutePath, pathSeparator);
|
|
2051
|
-
const children = await getPathPartsChildren(pathPaths);
|
|
2131
|
+
const children = await getPathPartsChildren(pathPaths, excluded, root);
|
|
2052
2132
|
const tree = createTree(items, root);
|
|
2053
2133
|
const childTree = createTree(children, root);
|
|
2054
2134
|
const merged = mergeTrees(tree, childTree);
|
|
@@ -2138,7 +2218,9 @@ const acceptRename = async state => {
|
|
|
2138
2218
|
const {
|
|
2139
2219
|
editingIndex,
|
|
2140
2220
|
editingValue,
|
|
2221
|
+
excluded,
|
|
2141
2222
|
items,
|
|
2223
|
+
pathSeparator,
|
|
2142
2224
|
root
|
|
2143
2225
|
} = state;
|
|
2144
2226
|
const editingErrorMessage = validateFileName2(editingValue);
|
|
@@ -2160,7 +2242,7 @@ const acceptRename = async state => {
|
|
|
2160
2242
|
const oldUri = renamedDirent.path;
|
|
2161
2243
|
const dirname = dirname2(oldUri);
|
|
2162
2244
|
const newUri = join2(dirname, editingValue);
|
|
2163
|
-
const children = await getChildDirents(
|
|
2245
|
+
const children = await getChildDirents(pathSeparator, dirname, renamedDirent.depth - 1, excluded, root);
|
|
2164
2246
|
const tree = createTree(items, root);
|
|
2165
2247
|
const update = computeExplorerRenamedDirentUpdate(root, dirname, oldUri, children, tree, newUri);
|
|
2166
2248
|
const newTree = updateTree2(tree, update);
|
|
@@ -3169,9 +3251,11 @@ const diff2 = uid => {
|
|
|
3169
3251
|
|
|
3170
3252
|
const expandAll = async state => {
|
|
3171
3253
|
const {
|
|
3254
|
+
excluded,
|
|
3172
3255
|
focusedIndex,
|
|
3173
3256
|
items,
|
|
3174
|
-
pathSeparator
|
|
3257
|
+
pathSeparator,
|
|
3258
|
+
root
|
|
3175
3259
|
} = state;
|
|
3176
3260
|
if (focusedIndex === -1) {
|
|
3177
3261
|
return state;
|
|
@@ -3192,7 +3276,7 @@ const expandAll = async state => {
|
|
|
3192
3276
|
dirent.type = DirectoryExpanding;
|
|
3193
3277
|
// TODO handle error
|
|
3194
3278
|
// TODO race condition
|
|
3195
|
-
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
3279
|
+
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth, excluded, root);
|
|
3196
3280
|
const newIndex = newDirents.indexOf(dirent);
|
|
3197
3281
|
if (newIndex === -1) {
|
|
3198
3282
|
continue;
|
|
@@ -3220,15 +3304,15 @@ const makeExpanded = dirent => {
|
|
|
3220
3304
|
};
|
|
3221
3305
|
|
|
3222
3306
|
// TODO this is very inefficient
|
|
3223
|
-
const getChildDirentsRecursively = async (dirent, pathSeparator) => {
|
|
3307
|
+
const getChildDirentsRecursively = async (dirent, pathSeparator, excluded = [], root = dirent.path) => {
|
|
3224
3308
|
switch (dirent.type) {
|
|
3225
3309
|
case Directory:
|
|
3226
3310
|
case DirectoryExpanded:
|
|
3227
3311
|
case DirectoryExpanding:
|
|
3228
|
-
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
3312
|
+
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth, excluded, root);
|
|
3229
3313
|
const all = [makeExpanded(dirent)];
|
|
3230
3314
|
for (const childDirent of childDirents) {
|
|
3231
|
-
const childAll = await getChildDirentsRecursively(childDirent, pathSeparator);
|
|
3315
|
+
const childAll = await getChildDirentsRecursively(childDirent, pathSeparator, excluded, root);
|
|
3232
3316
|
all.push(...childAll);
|
|
3233
3317
|
}
|
|
3234
3318
|
return all;
|
|
@@ -3253,6 +3337,7 @@ const getParentEndIndex = (dirents, index) => {
|
|
|
3253
3337
|
|
|
3254
3338
|
const expandRecursively = async state => {
|
|
3255
3339
|
const {
|
|
3340
|
+
excluded,
|
|
3256
3341
|
focusedIndex,
|
|
3257
3342
|
items,
|
|
3258
3343
|
pathSeparator,
|
|
@@ -3270,7 +3355,7 @@ const expandRecursively = async state => {
|
|
|
3270
3355
|
// TODO race condition: what if folder is being deleted while it is recursively expanding?
|
|
3271
3356
|
// TODO race condition: what if a new file/folder is created while the folder is recursively expanding?
|
|
3272
3357
|
// @ts-ignore
|
|
3273
|
-
const childDirents = await getChildDirentsRecursively(dirent, pathSeparator);
|
|
3358
|
+
const childDirents = await getChildDirentsRecursively(dirent, pathSeparator, excluded, root);
|
|
3274
3359
|
const startIndex = focusedIndex;
|
|
3275
3360
|
if (focusedIndex >= 0) {
|
|
3276
3361
|
const endIndex = getParentEndIndex(items, focusedIndex);
|
|
@@ -3806,7 +3891,7 @@ const handleClickDirectory = async (state, dirent, index, keepFocus) => {
|
|
|
3806
3891
|
// @ts-ignore
|
|
3807
3892
|
dirent.type = DirectoryExpanding;
|
|
3808
3893
|
// TODO handle error
|
|
3809
|
-
const dirents = await getChildDirents(state.pathSeparator, dirent.path, dirent.depth);
|
|
3894
|
+
const dirents = await getChildDirents(state.pathSeparator, dirent.path, dirent.depth, state.excluded, state.root);
|
|
3810
3895
|
const state2 = state;
|
|
3811
3896
|
if (!state2) {
|
|
3812
3897
|
return state;
|
|
@@ -3919,19 +4004,20 @@ const getFittingIndex = (dirents, startIndex) => {
|
|
|
3919
4004
|
return -1;
|
|
3920
4005
|
};
|
|
3921
4006
|
|
|
3922
|
-
const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntType) => {
|
|
4007
|
+
const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntType, excluded = [], root = parentPath) => {
|
|
3923
4008
|
// Get existing children or query them if they don't exist
|
|
3924
4009
|
let existingChildren = items.filter(item => item.depth === depth && item.path.startsWith(parentPath));
|
|
3925
4010
|
if (existingChildren.length === 0) {
|
|
3926
4011
|
const childDirents = await readDirWithFileTypes(parentPath);
|
|
3927
|
-
|
|
4012
|
+
const visibleChildDirents = childDirents.filter(dirent => !isExcluded(root, join2(parentPath, dirent.name), excluded));
|
|
4013
|
+
existingChildren = visibleChildDirents.map((dirent, index) => ({
|
|
3928
4014
|
depth,
|
|
3929
4015
|
icon: '',
|
|
3930
4016
|
name: dirent.name,
|
|
3931
4017
|
path: join2(parentPath, dirent.name),
|
|
3932
4018
|
posInSet: index + 1,
|
|
3933
4019
|
selected: false,
|
|
3934
|
-
setSize:
|
|
4020
|
+
setSize: visibleChildDirents.length,
|
|
3935
4021
|
type: dirent.type
|
|
3936
4022
|
}));
|
|
3937
4023
|
}
|
|
@@ -3954,7 +4040,7 @@ const getNewChildDirentsForNewDirent = async (items, depth, parentPath, direntTy
|
|
|
3954
4040
|
return allChildDirents;
|
|
3955
4041
|
};
|
|
3956
4042
|
|
|
3957
|
-
const getNewDirentsForNewDirent = async (items, focusedIndex, type, root) => {
|
|
4043
|
+
const getNewDirentsForNewDirent = async (items, focusedIndex, type, root, excluded = []) => {
|
|
3958
4044
|
if (items.length === 0 || focusedIndex === -1) {
|
|
3959
4045
|
const newDirent = {
|
|
3960
4046
|
depth: 0,
|
|
@@ -3977,7 +4063,7 @@ const getNewDirentsForNewDirent = async (items, focusedIndex, type, root) => {
|
|
|
3977
4063
|
}
|
|
3978
4064
|
const parentPath = focusedItem.path;
|
|
3979
4065
|
const depth = focusedItem.depth + 1;
|
|
3980
|
-
const updatedChildren = await getNewChildDirentsForNewDirent(items, depth, parentPath, type);
|
|
4066
|
+
const updatedChildren = await getNewChildDirentsForNewDirent(items, depth, parentPath, type, excluded, root);
|
|
3981
4067
|
|
|
3982
4068
|
// Create new array with updated items
|
|
3983
4069
|
const parentIndex = focusedIndex;
|
|
@@ -4013,6 +4099,7 @@ const newDirent = async (state, editingType, editingIcon = '') => {
|
|
|
4013
4099
|
// TODO do it like vscode, select position between folders and files
|
|
4014
4100
|
const {
|
|
4015
4101
|
editingIndex,
|
|
4102
|
+
excluded,
|
|
4016
4103
|
focusedIndex,
|
|
4017
4104
|
items,
|
|
4018
4105
|
root
|
|
@@ -4022,7 +4109,7 @@ const newDirent = async (state, editingType, editingIcon = '') => {
|
|
|
4022
4109
|
}
|
|
4023
4110
|
const index = getFittingIndex(items, focusedIndex);
|
|
4024
4111
|
const direntType = getNewDirentType(editingType);
|
|
4025
|
-
const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root);
|
|
4112
|
+
const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root, excluded);
|
|
4026
4113
|
const newEditingIndex = newDirents.findIndex(item => item.type === EditingFile || item.type === EditingFolder);
|
|
4027
4114
|
return {
|
|
4028
4115
|
...state,
|
|
@@ -4111,11 +4198,11 @@ const restoreDirentType = (rawDirentType, path, expandedPaths) => {
|
|
|
4111
4198
|
return rawDirentType;
|
|
4112
4199
|
};
|
|
4113
4200
|
|
|
4114
|
-
const getProtoMapInternal = (root, pathToDirents, expandedPaths, depth) => {
|
|
4201
|
+
const getProtoMapInternal = (root, pathToDirents, expandedPaths, depth, excluded = [], workspaceRoot = root) => {
|
|
4115
4202
|
if (!(root in pathToDirents)) {
|
|
4116
4203
|
return [];
|
|
4117
4204
|
}
|
|
4118
|
-
const items = pathToDirents[root] || [];
|
|
4205
|
+
const items = (pathToDirents[root] || []).filter(item => !isExcluded(workspaceRoot, join2(root, item.name), excluded));
|
|
4119
4206
|
const protoMap = [];
|
|
4120
4207
|
for (let i = 0; i < items.length; i++) {
|
|
4121
4208
|
const item = items[i];
|
|
@@ -4130,14 +4217,14 @@ const getProtoMapInternal = (root, pathToDirents, expandedPaths, depth) => {
|
|
|
4130
4217
|
setSize: items.length,
|
|
4131
4218
|
type: restoreDirentType(item.type, path, expandedPaths)
|
|
4132
4219
|
};
|
|
4133
|
-
const children = getProtoMapInternal(path, pathToDirents, expandedPaths, depth + 1);
|
|
4220
|
+
const children = getProtoMapInternal(path, pathToDirents, expandedPaths, depth + 1, excluded, workspaceRoot);
|
|
4134
4221
|
protoMap.push(displayDirent, ...children);
|
|
4135
4222
|
}
|
|
4136
4223
|
return protoMap;
|
|
4137
4224
|
};
|
|
4138
4225
|
|
|
4139
|
-
const getProtoMap = (root, pathToDirents, expandedPaths) => {
|
|
4140
|
-
return getProtoMapInternal(root, pathToDirents, expandedPaths, 1);
|
|
4226
|
+
const getProtoMap = (root, pathToDirents, expandedPaths, excluded = []) => {
|
|
4227
|
+
return getProtoMapInternal(root, pathToDirents, expandedPaths, 1, excluded, root);
|
|
4141
4228
|
};
|
|
4142
4229
|
|
|
4143
4230
|
const sortPathDirentsMap = map => {
|
|
@@ -4151,6 +4238,7 @@ const sortPathDirentsMap = map => {
|
|
|
4151
4238
|
|
|
4152
4239
|
const refresh = async state => {
|
|
4153
4240
|
const {
|
|
4241
|
+
excluded,
|
|
4154
4242
|
focusedIndex,
|
|
4155
4243
|
items,
|
|
4156
4244
|
root
|
|
@@ -4160,7 +4248,7 @@ const refresh = async state => {
|
|
|
4160
4248
|
const allPaths = [root, ...expandedPaths];
|
|
4161
4249
|
const pathToDirents = await getPathDirentsMap(allPaths);
|
|
4162
4250
|
const sortedPathDirents = sortPathDirentsMap(pathToDirents);
|
|
4163
|
-
const newItems = getProtoMap(root, sortedPathDirents, expandedPaths);
|
|
4251
|
+
const newItems = getProtoMap(root, sortedPathDirents, expandedPaths, excluded);
|
|
4164
4252
|
let newFocusedIndex = focusedIndex;
|
|
4165
4253
|
if (focusedIndex >= newItems.length) {
|
|
4166
4254
|
newFocusedIndex = newItems.length - 1;
|
|
@@ -4652,17 +4740,6 @@ const getErrorMessage = error => {
|
|
|
4652
4740
|
return 'Unknown error';
|
|
4653
4741
|
};
|
|
4654
4742
|
|
|
4655
|
-
const getExcluded = () => {
|
|
4656
|
-
const excludedObject = {};
|
|
4657
|
-
const excluded = [];
|
|
4658
|
-
for (const [key, value] of Object.entries(excludedObject)) {
|
|
4659
|
-
if (value) {
|
|
4660
|
-
excluded.push(key);
|
|
4661
|
-
}
|
|
4662
|
-
}
|
|
4663
|
-
return excluded;
|
|
4664
|
-
};
|
|
4665
|
-
|
|
4666
4743
|
const isValid = decoration => {
|
|
4667
4744
|
return decoration && typeof decoration.decoration === 'string' && typeof decoration.uri === 'string';
|
|
4668
4745
|
};
|
|
@@ -4734,6 +4811,19 @@ const getScheme = uri => {
|
|
|
4734
4811
|
return match[0];
|
|
4735
4812
|
};
|
|
4736
4813
|
|
|
4814
|
+
const getExcluded = excludedObject => {
|
|
4815
|
+
if (!excludedObject || typeof excludedObject !== 'object' || Array.isArray(excludedObject)) {
|
|
4816
|
+
return [];
|
|
4817
|
+
}
|
|
4818
|
+
const excluded = [];
|
|
4819
|
+
for (const [key, value] of Object.entries(excludedObject)) {
|
|
4820
|
+
if (value === true) {
|
|
4821
|
+
excluded.push(key);
|
|
4822
|
+
}
|
|
4823
|
+
}
|
|
4824
|
+
return excluded;
|
|
4825
|
+
};
|
|
4826
|
+
|
|
4737
4827
|
const getSettings = async () => {
|
|
4738
4828
|
// TODO don't return false always
|
|
4739
4829
|
// TODO get all settings at once
|
|
@@ -4743,11 +4833,14 @@ const getSettings = async () => {
|
|
|
4743
4833
|
const confirmDelete = confirmDeleteRaw === false ? false : false;
|
|
4744
4834
|
const confirmPasteRaw = await invoke$2('Preferences.get', 'explorer.confirmpaste');
|
|
4745
4835
|
const confirmPaste = confirmPasteRaw === false ? false : false;
|
|
4836
|
+
const excludedRaw = await invoke$2('Preferences.get', 'files.exclude');
|
|
4837
|
+
const excluded = getExcluded(excludedRaw);
|
|
4746
4838
|
const sourceControlDecorationsRaw = await invoke$2('Preferences.get', 'explorer.sourceControlDecorations');
|
|
4747
4839
|
const sourceControlDecorations = sourceControlDecorationsRaw === false ? false : true;
|
|
4748
4840
|
return {
|
|
4749
4841
|
confirmDelete,
|
|
4750
4842
|
confirmPaste,
|
|
4843
|
+
excluded,
|
|
4751
4844
|
sourceControlDecorations,
|
|
4752
4845
|
useChevrons
|
|
4753
4846
|
};
|
|
@@ -4757,7 +4850,7 @@ const getWorkspacePath = () => {
|
|
|
4757
4850
|
return invoke$2('Workspace.getPath');
|
|
4758
4851
|
};
|
|
4759
4852
|
|
|
4760
|
-
const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
|
|
4853
|
+
const getSavedChildDirents = (map, path, depth, excluded, pathSeparator, root = path) => {
|
|
4761
4854
|
let children = map[path];
|
|
4762
4855
|
if (!children) {
|
|
4763
4856
|
return [];
|
|
@@ -4767,7 +4860,8 @@ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
|
|
|
4767
4860
|
const visible = [];
|
|
4768
4861
|
const displayRoot = path.endsWith(pathSeparator) ? path : path + pathSeparator;
|
|
4769
4862
|
for (const child of children) {
|
|
4770
|
-
|
|
4863
|
+
const childPath = displayRoot + child.name;
|
|
4864
|
+
if (isExcluded(root, childPath, excluded)) {
|
|
4771
4865
|
continue;
|
|
4772
4866
|
}
|
|
4773
4867
|
visible.push(child);
|
|
@@ -4790,7 +4884,7 @@ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
|
|
|
4790
4884
|
setSize: visibleLength,
|
|
4791
4885
|
type: DirectoryExpanded
|
|
4792
4886
|
});
|
|
4793
|
-
dirents.push(...getSavedChildDirents(map, childPath, depth + 1, excluded, pathSeparator));
|
|
4887
|
+
dirents.push(...getSavedChildDirents(map, childPath, depth + 1, excluded, pathSeparator, root));
|
|
4794
4888
|
} else {
|
|
4795
4889
|
dirents.push({
|
|
4796
4890
|
depth,
|
|
@@ -4819,7 +4913,7 @@ const createDirents = (root, expandedDirentPaths, expandedDirentChildren, exclud
|
|
|
4819
4913
|
map[path] = children.value;
|
|
4820
4914
|
}
|
|
4821
4915
|
}
|
|
4822
|
-
dirents.push(...getSavedChildDirents(map, root, 1, excluded, pathSeparator));
|
|
4916
|
+
dirents.push(...getSavedChildDirents(map, root, 1, excluded, pathSeparator, root));
|
|
4823
4917
|
return dirents;
|
|
4824
4918
|
};
|
|
4825
4919
|
const getSavedExpandedPaths = (savedState, root) => {
|
|
@@ -4859,6 +4953,7 @@ const loadContent = async (state, savedState) => {
|
|
|
4859
4953
|
} = state;
|
|
4860
4954
|
const {
|
|
4861
4955
|
confirmDelete,
|
|
4956
|
+
excluded,
|
|
4862
4957
|
sourceControlDecorations,
|
|
4863
4958
|
useChevrons
|
|
4864
4959
|
} = await getSettings();
|
|
@@ -4869,7 +4964,6 @@ const loadContent = async (state, savedState) => {
|
|
|
4869
4964
|
const [pathSeparator, isReadonly$1] = await Promise.all([getPathSeparator(root),
|
|
4870
4965
|
// TODO only load path separator once
|
|
4871
4966
|
isReadonly(root)]);
|
|
4872
|
-
const excluded = getExcluded();
|
|
4873
4967
|
const restoredDirents = await restoreExpandedState(savedState, root, pathSeparator, excluded);
|
|
4874
4968
|
const rawDeltaY = getRestoredDeltaY(savedState);
|
|
4875
4969
|
const maxDeltaY = Math.max(restoredDirents.length * itemHeight - height, 0);
|
|
@@ -5012,8 +5106,8 @@ const uploadFileSystemHandles = async (root, pathSeparator, fileSystemHandles) =
|
|
|
5012
5106
|
const mergeDirents$1 = (oldDirents, newDirents) => {
|
|
5013
5107
|
return newDirents;
|
|
5014
5108
|
};
|
|
5015
|
-
const getMergedDirents$2 = async (root, pathSeparator, dirents) => {
|
|
5016
|
-
const childDirents = await getChildDirents(pathSeparator, root, 0);
|
|
5109
|
+
const getMergedDirents$2 = async (root, pathSeparator, dirents, excluded) => {
|
|
5110
|
+
const childDirents = await getChildDirents(pathSeparator, root, 0, excluded, root);
|
|
5017
5111
|
const mergedDirents = mergeDirents$1(dirents, childDirents);
|
|
5018
5112
|
return mergedDirents;
|
|
5019
5113
|
};
|
|
@@ -5044,6 +5138,7 @@ const getFirstDroppedDirectory = (state, fileHandles) => {
|
|
|
5044
5138
|
};
|
|
5045
5139
|
const handleDrop$2 = async (state, fileHandles, files, paths) => {
|
|
5046
5140
|
const {
|
|
5141
|
+
excluded,
|
|
5047
5142
|
items,
|
|
5048
5143
|
pathSeparator,
|
|
5049
5144
|
root
|
|
@@ -5066,7 +5161,7 @@ const handleDrop$2 = async (state, fileHandles, files, paths) => {
|
|
|
5066
5161
|
dropTargets: []
|
|
5067
5162
|
};
|
|
5068
5163
|
}
|
|
5069
|
-
const mergedDirents = await getMergedDirents$2(root, pathSeparator, items);
|
|
5164
|
+
const mergedDirents = await getMergedDirents$2(root, pathSeparator, items, excluded);
|
|
5070
5165
|
return {
|
|
5071
5166
|
...state,
|
|
5072
5167
|
dropTargets: [],
|
|
@@ -5099,8 +5194,8 @@ const copyFilesElectron = async (root, fileHandles, files, paths) => {
|
|
|
5099
5194
|
const mergeDirents = (oldDirents, newDirents) => {
|
|
5100
5195
|
return newDirents;
|
|
5101
5196
|
};
|
|
5102
|
-
const getMergedDirents$1 = async (root, pathSeparator, dirents) => {
|
|
5103
|
-
const childDirents = await getChildDirents(pathSeparator, root, 0);
|
|
5197
|
+
const getMergedDirents$1 = async (root, pathSeparator, dirents, excluded) => {
|
|
5198
|
+
const childDirents = await getChildDirents(pathSeparator, root, 0, excluded, root);
|
|
5104
5199
|
const mergedDirents = mergeDirents(dirents, childDirents);
|
|
5105
5200
|
return mergedDirents;
|
|
5106
5201
|
};
|
|
@@ -5126,6 +5221,7 @@ const getFirstDroppedDirectoryPath = (state, fileHandles, paths) => {
|
|
|
5126
5221
|
};
|
|
5127
5222
|
const handleDrop$1 = async (state, fileHandles, files, paths) => {
|
|
5128
5223
|
const {
|
|
5224
|
+
excluded,
|
|
5129
5225
|
items,
|
|
5130
5226
|
pathSeparator,
|
|
5131
5227
|
root
|
|
@@ -5141,7 +5237,7 @@ const handleDrop$1 = async (state, fileHandles, files, paths) => {
|
|
|
5141
5237
|
};
|
|
5142
5238
|
}
|
|
5143
5239
|
await copyFilesElectron(root, fileHandles, files, paths);
|
|
5144
|
-
const mergedDirents = await getMergedDirents$1(root, pathSeparator, items);
|
|
5240
|
+
const mergedDirents = await getMergedDirents$1(root, pathSeparator, items, excluded);
|
|
5145
5241
|
return {
|
|
5146
5242
|
...state,
|
|
5147
5243
|
dropTargets: [],
|
|
@@ -5182,11 +5278,13 @@ const getMergedDirents = (items, index, dirent, childDirents) => {
|
|
|
5182
5278
|
};
|
|
5183
5279
|
const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, paths) => {
|
|
5184
5280
|
const {
|
|
5281
|
+
excluded,
|
|
5185
5282
|
items,
|
|
5186
|
-
pathSeparator
|
|
5283
|
+
pathSeparator,
|
|
5284
|
+
root
|
|
5187
5285
|
} = state;
|
|
5188
5286
|
await uploadFileSystemHandles(dirent.path, '/', fileHandles);
|
|
5189
|
-
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
|
|
5287
|
+
const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth, excluded, root);
|
|
5190
5288
|
const mergedDirents = getMergedDirents(items, index, dirent, childDirents);
|
|
5191
5289
|
// TODO update maxlineY
|
|
5192
5290
|
return {
|
|
@@ -6738,6 +6836,7 @@ const mergeVisibleWithHiddenItems = (visibleItems, hiddenItems) => {
|
|
|
6738
6836
|
// TODO maybe just insert items into explorer and refresh whole explorer
|
|
6739
6837
|
const revealItemHidden = async (state, uri) => {
|
|
6740
6838
|
const {
|
|
6839
|
+
excluded,
|
|
6741
6840
|
items,
|
|
6742
6841
|
maxLineY,
|
|
6743
6842
|
minLineY,
|
|
@@ -6749,7 +6848,7 @@ const revealItemHidden = async (state, uri) => {
|
|
|
6749
6848
|
return state;
|
|
6750
6849
|
}
|
|
6751
6850
|
const pathPartsToReveal = getPathPartsToReveal(root, pathParts, items);
|
|
6752
|
-
const pathPartsChildren = await getPathPartsChildren(pathPartsToReveal);
|
|
6851
|
+
const pathPartsChildren = await getPathPartsChildren(pathPartsToReveal, excluded, root);
|
|
6753
6852
|
const pathPartsChildrenFlat = pathPartsChildren.flat();
|
|
6754
6853
|
const orderedPathParts = orderDirents(pathPartsChildrenFlat);
|
|
6755
6854
|
const mergedDirents = mergeVisibleWithHiddenItems(items, orderedPathParts);
|
|
@@ -6803,6 +6902,7 @@ const revealItem = async (state, uri) => {
|
|
|
6803
6902
|
object(state);
|
|
6804
6903
|
string(uri);
|
|
6805
6904
|
const {
|
|
6905
|
+
excluded,
|
|
6806
6906
|
items,
|
|
6807
6907
|
pathSeparator,
|
|
6808
6908
|
root
|
|
@@ -6810,6 +6910,9 @@ const revealItem = async (state, uri) => {
|
|
|
6810
6910
|
if (!isUriWithinRoot(root, uri, pathSeparator)) {
|
|
6811
6911
|
return state;
|
|
6812
6912
|
}
|
|
6913
|
+
if (isExcluded(root, uri, excluded)) {
|
|
6914
|
+
return state;
|
|
6915
|
+
}
|
|
6813
6916
|
const index = getIndex(items, uri);
|
|
6814
6917
|
if (index === -1) {
|
|
6815
6918
|
return revealItemHidden(state, uri);
|