@lvce-editor/explorer-view 7.29.0 → 7.30.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.
@@ -2653,10 +2653,15 @@ const cancelEditRename = (state, keepFocus) => {
2653
2653
  };
2654
2654
  };
2655
2655
 
2656
- const getUpdatedChildren = (children, oldItems, newUri) => {
2656
+ const getUpdatedChildren = (children, previousChildren, oldUri, newUri, renamedChildren) => {
2657
2657
  const setSize = children.length;
2658
+ const previousTypes = new Map(previousChildren.map(child => [child.name, normalizeDirentType(child.type)]));
2659
+ const oldName = getBaseName('/', oldUri);
2658
2660
  return children.toSorted(compareDirent).map((child, index) => {
2659
- if (oldItems.length > 0 && child.path === newUri && child.type === Directory) {
2661
+ const previousName = child.path === newUri ? oldName : child.name;
2662
+ const previousType = previousTypes.get(previousName);
2663
+ const wasExpanded = previousType === DirectoryExpanded || child.path === newUri && renamedChildren.length > 0;
2664
+ if (wasExpanded && child.type === Directory) {
2660
2665
  return {
2661
2666
  ...child,
2662
2667
  posInSet: index + 1,
@@ -2678,7 +2683,8 @@ const computeExplorerRenamedDirentUpdate = (root, parentPath, oldUri, children,
2678
2683
  const relativeNewUri = newUri.slice(rootLength);
2679
2684
  const update = Object.create(null);
2680
2685
  const oldItems = tree[relativeOldPath] || [];
2681
- update[relativeDirname] = getUpdatedChildren(children, oldItems, newUri);
2686
+ const previousChildren = tree[relativeDirname] || [];
2687
+ update[relativeDirname] = getUpdatedChildren(children, previousChildren, oldUri, newUri, oldItems);
2682
2688
  update[relativeNewUri] = oldItems;
2683
2689
  for (const [key, value] of Object.entries(tree)) {
2684
2690
  if (!key.startsWith(`${relativeOldPath}/`)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.29.0",
3
+ "version": "7.30.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",