@lvce-editor/explorer-view 3.6.0 → 3.7.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.
@@ -4499,18 +4499,26 @@ const generateUniqueName = (baseName, existingPaths, root) => {
4499
4499
  }
4500
4500
  };
4501
4501
 
4502
- const getFileOperationsCopy = (root, existingUris, files) => {
4502
+ const getFileOperationsCopy = (root, existingUris, files, focusedUri) => {
4503
4503
  const operations = [];
4504
4504
  for (const file of files) {
4505
4505
  const baseName = getBaseName('/', file);
4506
- const uniqueName = generateUniqueName(baseName, existingUris, root);
4507
- const newUri = join2(root, uniqueName);
4508
- operations.push({
4509
- type: Copy$1,
4510
- from: file,
4511
- // TODO ensure file is uri
4512
- path: newUri
4513
- });
4506
+ if (existingUris.includes(file)) {
4507
+ operations.push({
4508
+ type: Rename$2,
4509
+ from: file,
4510
+ path: join2(focusedUri, baseName)
4511
+ });
4512
+ } else {
4513
+ const uniqueName = generateUniqueName(baseName, existingUris, root);
4514
+ const newUri = join2(root, uniqueName);
4515
+ operations.push({
4516
+ type: Copy$1,
4517
+ from: file,
4518
+ // TODO ensure file is uri
4519
+ path: newUri
4520
+ });
4521
+ }
4514
4522
  }
4515
4523
  return operations;
4516
4524
  };
@@ -4525,10 +4533,12 @@ const handlePasteCopy = async (state, nativeFiles) => {
4525
4533
  // TODO use file operations and bulk edit
4526
4534
  const {
4527
4535
  items,
4528
- root
4536
+ root,
4537
+ focusedIndex
4529
4538
  } = state;
4539
+ const focusedUri = items[focusedIndex]?.path || root;
4530
4540
  const existingUris = items.map(item => item.path);
4531
- const operations = getFileOperationsCopy(root, existingUris, nativeFiles.files);
4541
+ const operations = getFileOperationsCopy(root, existingUris, nativeFiles.files, focusedUri);
4532
4542
  // TODO handle error?
4533
4543
  await applyFileOperations(operations);
4534
4544
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "3.6.0",
3
+ "version": "3.7.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",