@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,
|
|
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
|
-
|
|
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
|
-
|
|
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}/`)) {
|