@lvce-editor/explorer-view 2.47.0 → 2.48.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.
@@ -1135,8 +1135,7 @@ const getFileOperationsNestedPath = (path, root, pathSeparator) => {
1135
1135
  currentPath = currentPath ? `${currentPath}${pathSeparator}${part}` : part;
1136
1136
  operations.push({
1137
1137
  type: CreateFolder$1,
1138
- path: `${root}${currentPath}`,
1139
- text: ''
1138
+ path: `${root}${currentPath}`
1140
1139
  });
1141
1140
  }
1142
1141
  return operations;
@@ -1154,8 +1153,7 @@ const getFileOperationsCreate = (newFileName, newDirentType, pathSeparator, abso
1154
1153
  } else if (newDirentType === Directory) {
1155
1154
  operations.push({
1156
1155
  type: CreateFolder$1,
1157
- path: absolutePath,
1158
- text: ''
1156
+ path: absolutePath
1159
1157
  });
1160
1158
  }
1161
1159
  return operations;
@@ -1508,7 +1506,7 @@ const validateFileName2 = name => {
1508
1506
  return '';
1509
1507
  };
1510
1508
 
1511
- const acceptCreate = async (state, newDirentType, createFn) => {
1509
+ const acceptCreate = async (state, newDirentType) => {
1512
1510
  const {
1513
1511
  editingValue,
1514
1512
  minLineY,
@@ -1591,18 +1589,16 @@ const computeExplorerRenamedDirentUpdate = (root, parentPath, oldUri, children,
1591
1589
  return update;
1592
1590
  };
1593
1591
 
1594
- const createNewDirentsRename = async (renamedDirent, editingValue, pathSeparator) => {
1595
- try {
1596
- // TODO this does not work with rename of nested file
1597
- const oldAbsolutePath = renamedDirent.path;
1598
- const oldParentPath = dirname2(oldAbsolutePath);
1599
- const newAbsolutePath = join2(oldParentPath, editingValue);
1600
- await rename$1(oldAbsolutePath, newAbsolutePath);
1601
- } catch (error) {
1602
- console.error(new VError(error, `Failed to rename file`));
1603
- return `${error}`;
1604
- }
1605
- return '';
1592
+ const getFileOperationsRename = (oldAbsolutePath, newFileName) => {
1593
+ const operations = [];
1594
+ const oldParentPath = dirname2(oldAbsolutePath);
1595
+ const newAbsolutePath = join2(oldParentPath, newFileName);
1596
+ operations.push({
1597
+ type: Rename$2,
1598
+ path: newAbsolutePath,
1599
+ from: oldAbsolutePath
1600
+ });
1601
+ return operations;
1606
1602
  };
1607
1603
 
1608
1604
  const updateTree2 = (tree, update) => {
@@ -1632,7 +1628,8 @@ const acceptRename = async state => {
1632
1628
  };
1633
1629
  }
1634
1630
  const renamedDirent = items[editingIndex];
1635
- const renameErrorMessage = await createNewDirentsRename(renamedDirent, editingValue);
1631
+ const operations = getFileOperationsRename(renamedDirent.path, editingValue);
1632
+ const renameErrorMessage = await applyFileOperations(operations);
1636
1633
  if (renameErrorMessage) {
1637
1634
  return {
1638
1635
  ...state,
@@ -3309,8 +3306,7 @@ const getFileOperations = (root, uploadTree) => {
3309
3306
  if (typeof value === 'object') {
3310
3307
  operations.push({
3311
3308
  type: CreateFolder$1,
3312
- path: join2(root, fullPath),
3313
- text: ''
3309
+ path: join2(root, fullPath)
3314
3310
  });
3315
3311
  processTree(value, fullPath);
3316
3312
  } else if (typeof value === 'string') {
@@ -3380,7 +3376,6 @@ const getFileOperationsElectron = async (root, paths, fileHandles) => {
3380
3376
  operations.push({
3381
3377
  type: 'copy',
3382
3378
  path: join2(root, name),
3383
- text: '',
3384
3379
  from: path
3385
3380
  });
3386
3381
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.47.0",
3
+ "version": "2.48.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",