@lvce-editor/explorer-view 7.5.0 → 7.8.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.
@@ -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 => !excluded.includes(item.name));
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('/', dirname, renamedDirent.depth - 1, []);
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
- existingChildren = childDirents.map((dirent, index) => ({
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: childDirents.length,
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;
@@ -4350,15 +4438,21 @@ const handleRangeSelection = (state, startIndex, endIndex) => {
4350
4438
 
4351
4439
  const handleClickAtRangeSelection = async (state, index) => {
4352
4440
  const {
4441
+ focusedIndex,
4353
4442
  items
4354
4443
  } = state;
4355
4444
  const firstSelectedIndex = items.findIndex(item => item.selected);
4356
- if (firstSelectedIndex === -1) {
4357
- return handleRangeSelection(state, index, index);
4445
+ let anchorIndex = firstSelectedIndex;
4446
+ if (anchorIndex === -1) {
4447
+ anchorIndex = focusedIndex === -1 ? index : focusedIndex;
4358
4448
  }
4359
- const min = Math.min(firstSelectedIndex, index);
4360
- const max = Math.min(firstSelectedIndex, index);
4361
- return handleRangeSelection(state, min, max);
4449
+ const min = Math.min(anchorIndex, index);
4450
+ const max = Math.max(anchorIndex, index);
4451
+ const newState = handleRangeSelection(state, min, max);
4452
+ return {
4453
+ ...newState,
4454
+ focusedIndex: index
4455
+ };
4362
4456
  };
4363
4457
 
4364
4458
  const toggleIndividualSelection = async (state, index) => {
@@ -4652,17 +4746,6 @@ const getErrorMessage = error => {
4652
4746
  return 'Unknown error';
4653
4747
  };
4654
4748
 
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
4749
  const isValid = decoration => {
4667
4750
  return decoration && typeof decoration.decoration === 'string' && typeof decoration.uri === 'string';
4668
4751
  };
@@ -4734,6 +4817,19 @@ const getScheme = uri => {
4734
4817
  return match[0];
4735
4818
  };
4736
4819
 
4820
+ const getExcluded = excludedObject => {
4821
+ if (!excludedObject || typeof excludedObject !== 'object' || Array.isArray(excludedObject)) {
4822
+ return [];
4823
+ }
4824
+ const excluded = [];
4825
+ for (const [key, value] of Object.entries(excludedObject)) {
4826
+ if (value === true) {
4827
+ excluded.push(key);
4828
+ }
4829
+ }
4830
+ return excluded;
4831
+ };
4832
+
4737
4833
  const getSettings = async () => {
4738
4834
  // TODO don't return false always
4739
4835
  // TODO get all settings at once
@@ -4743,11 +4839,14 @@ const getSettings = async () => {
4743
4839
  const confirmDelete = confirmDeleteRaw === false ? false : false;
4744
4840
  const confirmPasteRaw = await invoke$2('Preferences.get', 'explorer.confirmpaste');
4745
4841
  const confirmPaste = confirmPasteRaw === false ? false : false;
4842
+ const excludedRaw = await invoke$2('Preferences.get', 'files.exclude');
4843
+ const excluded = getExcluded(excludedRaw);
4746
4844
  const sourceControlDecorationsRaw = await invoke$2('Preferences.get', 'explorer.sourceControlDecorations');
4747
4845
  const sourceControlDecorations = sourceControlDecorationsRaw === false ? false : true;
4748
4846
  return {
4749
4847
  confirmDelete,
4750
4848
  confirmPaste,
4849
+ excluded,
4751
4850
  sourceControlDecorations,
4752
4851
  useChevrons
4753
4852
  };
@@ -4757,7 +4856,7 @@ const getWorkspacePath = () => {
4757
4856
  return invoke$2('Workspace.getPath');
4758
4857
  };
4759
4858
 
4760
- const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
4859
+ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator, root = path) => {
4761
4860
  let children = map[path];
4762
4861
  if (!children) {
4763
4862
  return [];
@@ -4767,7 +4866,8 @@ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
4767
4866
  const visible = [];
4768
4867
  const displayRoot = path.endsWith(pathSeparator) ? path : path + pathSeparator;
4769
4868
  for (const child of children) {
4770
- if (excluded.includes(child.name)) {
4869
+ const childPath = displayRoot + child.name;
4870
+ if (isExcluded(root, childPath, excluded)) {
4771
4871
  continue;
4772
4872
  }
4773
4873
  visible.push(child);
@@ -4790,7 +4890,7 @@ const getSavedChildDirents = (map, path, depth, excluded, pathSeparator) => {
4790
4890
  setSize: visibleLength,
4791
4891
  type: DirectoryExpanded
4792
4892
  });
4793
- dirents.push(...getSavedChildDirents(map, childPath, depth + 1, excluded, pathSeparator));
4893
+ dirents.push(...getSavedChildDirents(map, childPath, depth + 1, excluded, pathSeparator, root));
4794
4894
  } else {
4795
4895
  dirents.push({
4796
4896
  depth,
@@ -4819,7 +4919,7 @@ const createDirents = (root, expandedDirentPaths, expandedDirentChildren, exclud
4819
4919
  map[path] = children.value;
4820
4920
  }
4821
4921
  }
4822
- dirents.push(...getSavedChildDirents(map, root, 1, excluded, pathSeparator));
4922
+ dirents.push(...getSavedChildDirents(map, root, 1, excluded, pathSeparator, root));
4823
4923
  return dirents;
4824
4924
  };
4825
4925
  const getSavedExpandedPaths = (savedState, root) => {
@@ -4859,6 +4959,7 @@ const loadContent = async (state, savedState) => {
4859
4959
  } = state;
4860
4960
  const {
4861
4961
  confirmDelete,
4962
+ excluded,
4862
4963
  sourceControlDecorations,
4863
4964
  useChevrons
4864
4965
  } = await getSettings();
@@ -4869,7 +4970,6 @@ const loadContent = async (state, savedState) => {
4869
4970
  const [pathSeparator, isReadonly$1] = await Promise.all([getPathSeparator(root),
4870
4971
  // TODO only load path separator once
4871
4972
  isReadonly(root)]);
4872
- const excluded = getExcluded();
4873
4973
  const restoredDirents = await restoreExpandedState(savedState, root, pathSeparator, excluded);
4874
4974
  const rawDeltaY = getRestoredDeltaY(savedState);
4875
4975
  const maxDeltaY = Math.max(restoredDirents.length * itemHeight - height, 0);
@@ -5012,8 +5112,8 @@ const uploadFileSystemHandles = async (root, pathSeparator, fileSystemHandles) =
5012
5112
  const mergeDirents$1 = (oldDirents, newDirents) => {
5013
5113
  return newDirents;
5014
5114
  };
5015
- const getMergedDirents$2 = async (root, pathSeparator, dirents) => {
5016
- const childDirents = await getChildDirents(pathSeparator, root, 0);
5115
+ const getMergedDirents$2 = async (root, pathSeparator, dirents, excluded) => {
5116
+ const childDirents = await getChildDirents(pathSeparator, root, 0, excluded, root);
5017
5117
  const mergedDirents = mergeDirents$1(dirents, childDirents);
5018
5118
  return mergedDirents;
5019
5119
  };
@@ -5044,6 +5144,7 @@ const getFirstDroppedDirectory = (state, fileHandles) => {
5044
5144
  };
5045
5145
  const handleDrop$2 = async (state, fileHandles, files, paths) => {
5046
5146
  const {
5147
+ excluded,
5047
5148
  items,
5048
5149
  pathSeparator,
5049
5150
  root
@@ -5066,7 +5167,7 @@ const handleDrop$2 = async (state, fileHandles, files, paths) => {
5066
5167
  dropTargets: []
5067
5168
  };
5068
5169
  }
5069
- const mergedDirents = await getMergedDirents$2(root, pathSeparator, items);
5170
+ const mergedDirents = await getMergedDirents$2(root, pathSeparator, items, excluded);
5070
5171
  return {
5071
5172
  ...state,
5072
5173
  dropTargets: [],
@@ -5099,8 +5200,8 @@ const copyFilesElectron = async (root, fileHandles, files, paths) => {
5099
5200
  const mergeDirents = (oldDirents, newDirents) => {
5100
5201
  return newDirents;
5101
5202
  };
5102
- const getMergedDirents$1 = async (root, pathSeparator, dirents) => {
5103
- const childDirents = await getChildDirents(pathSeparator, root, 0);
5203
+ const getMergedDirents$1 = async (root, pathSeparator, dirents, excluded) => {
5204
+ const childDirents = await getChildDirents(pathSeparator, root, 0, excluded, root);
5104
5205
  const mergedDirents = mergeDirents(dirents, childDirents);
5105
5206
  return mergedDirents;
5106
5207
  };
@@ -5126,6 +5227,7 @@ const getFirstDroppedDirectoryPath = (state, fileHandles, paths) => {
5126
5227
  };
5127
5228
  const handleDrop$1 = async (state, fileHandles, files, paths) => {
5128
5229
  const {
5230
+ excluded,
5129
5231
  items,
5130
5232
  pathSeparator,
5131
5233
  root
@@ -5141,7 +5243,7 @@ const handleDrop$1 = async (state, fileHandles, files, paths) => {
5141
5243
  };
5142
5244
  }
5143
5245
  await copyFilesElectron(root, fileHandles, files, paths);
5144
- const mergedDirents = await getMergedDirents$1(root, pathSeparator, items);
5246
+ const mergedDirents = await getMergedDirents$1(root, pathSeparator, items, excluded);
5145
5247
  return {
5146
5248
  ...state,
5147
5249
  dropTargets: [],
@@ -5182,11 +5284,13 @@ const getMergedDirents = (items, index, dirent, childDirents) => {
5182
5284
  };
5183
5285
  const handleDropIntoFolder = async (state, dirent, index, fileHandles, files, paths) => {
5184
5286
  const {
5287
+ excluded,
5185
5288
  items,
5186
- pathSeparator
5289
+ pathSeparator,
5290
+ root
5187
5291
  } = state;
5188
5292
  await uploadFileSystemHandles(dirent.path, '/', fileHandles);
5189
- const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth);
5293
+ const childDirents = await getChildDirents(pathSeparator, dirent.path, dirent.depth, excluded, root);
5190
5294
  const mergedDirents = getMergedDirents(items, index, dirent, childDirents);
5191
5295
  // TODO update maxlineY
5192
5296
  return {
@@ -5758,13 +5862,13 @@ const handleWheel = (state, deltaMode, deltaY) => {
5758
5862
  return setDeltaY(state, state.deltaY + deltaY);
5759
5863
  };
5760
5864
 
5761
- const handleWorkspaceChange = async state => {
5865
+ const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
5762
5866
  const newRoot = await getWorkspacePath();
5763
5867
  const state1 = {
5764
5868
  ...state,
5765
5869
  root: newRoot
5766
5870
  };
5767
- const newState = await loadContent(state1, undefined);
5871
+ const newState = await loadContent(state1, savedState);
5768
5872
  return newState;
5769
5873
  };
5770
5874
 
@@ -6738,6 +6842,7 @@ const mergeVisibleWithHiddenItems = (visibleItems, hiddenItems) => {
6738
6842
  // TODO maybe just insert items into explorer and refresh whole explorer
6739
6843
  const revealItemHidden = async (state, uri) => {
6740
6844
  const {
6845
+ excluded,
6741
6846
  items,
6742
6847
  maxLineY,
6743
6848
  minLineY,
@@ -6749,7 +6854,7 @@ const revealItemHidden = async (state, uri) => {
6749
6854
  return state;
6750
6855
  }
6751
6856
  const pathPartsToReveal = getPathPartsToReveal(root, pathParts, items);
6752
- const pathPartsChildren = await getPathPartsChildren(pathPartsToReveal);
6857
+ const pathPartsChildren = await getPathPartsChildren(pathPartsToReveal, excluded, root);
6753
6858
  const pathPartsChildrenFlat = pathPartsChildren.flat();
6754
6859
  const orderedPathParts = orderDirents(pathPartsChildrenFlat);
6755
6860
  const mergedDirents = mergeVisibleWithHiddenItems(items, orderedPathParts);
@@ -6803,6 +6908,7 @@ const revealItem = async (state, uri) => {
6803
6908
  object(state);
6804
6909
  string(uri);
6805
6910
  const {
6911
+ excluded,
6806
6912
  items,
6807
6913
  pathSeparator,
6808
6914
  root
@@ -6810,6 +6916,9 @@ const revealItem = async (state, uri) => {
6810
6916
  if (!isUriWithinRoot(root, uri, pathSeparator)) {
6811
6917
  return state;
6812
6918
  }
6919
+ if (isExcluded(root, uri, excluded)) {
6920
+ return state;
6921
+ }
6813
6922
  const index = getIndex(items, uri);
6814
6923
  if (index === -1) {
6815
6924
  return revealItemHidden(state, uri);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.5.0",
3
+ "version": "7.8.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",