@lvce-editor/explorer-view 2.43.0 → 2.45.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.
@@ -431,7 +431,7 @@ const create$4 = (method, params) => {
431
431
  };
432
432
  };
433
433
  const callbacks = Object.create(null);
434
- const set$3 = (id, fn) => {
434
+ const set$2 = (id, fn) => {
435
435
  callbacks[id] = fn;
436
436
  };
437
437
  const get$2 = id => {
@@ -450,7 +450,7 @@ const registerPromise = () => {
450
450
  resolve,
451
451
  promise
452
452
  } = Promise.withResolvers();
453
- set$3(id, resolve);
453
+ set$2(id, resolve);
454
454
  return {
455
455
  id,
456
456
  promise
@@ -761,7 +761,7 @@ const send = (transport, method, ...params) => {
761
761
  const message = create$4(method, params);
762
762
  transport.send(message);
763
763
  };
764
- const invoke$3 = (ipc, method, ...params) => {
764
+ const invoke$2 = (ipc, method, ...params) => {
765
765
  return invokeHelper(ipc, method, params, false);
766
766
  };
767
767
  const invokeAndTransfer = (ipc, method, ...params) => {
@@ -794,7 +794,7 @@ const createRpc = ipc => {
794
794
  send(ipc, method, ...params);
795
795
  },
796
796
  invoke(method, ...params) {
797
- return invoke$3(ipc, method, ...params);
797
+ return invoke$2(ipc, method, ...params);
798
798
  },
799
799
  invokeAndTransfer(method, ...params) {
800
800
  return invokeAndTransfer(ipc, method, ...params);
@@ -851,7 +851,7 @@ const WebWorkerRpcClient = {
851
851
  };
852
852
 
853
853
  const rpcs = Object.create(null);
854
- const set$7 = (id, rpc) => {
854
+ const set$9 = (id, rpc) => {
855
855
  rpcs[id] = rpc;
856
856
  };
857
857
  const get$1 = id => {
@@ -875,19 +875,19 @@ const create$2 = rpcId => {
875
875
  return rpc.invokeAndTransfer(method, ...params);
876
876
  },
877
877
  set(rpc) {
878
- set$7(rpcId, rpc);
878
+ set$9(rpcId, rpc);
879
879
  }
880
880
  };
881
881
  };
882
882
  const RendererWorker$1 = 1;
883
883
  const {
884
- invoke: invoke$2,
885
- set: set$2
884
+ invoke: invoke$4,
885
+ set: set$4
886
886
  } = create$2(RendererWorker$1);
887
887
  const RendererWorker = {
888
888
  __proto__: null,
889
- invoke: invoke$2,
890
- set: set$2
889
+ invoke: invoke$4,
890
+ set: set$4
891
891
  };
892
892
 
893
893
  const {
@@ -978,10 +978,10 @@ const createNewDirentsAccept = async (newFileName, pathSeparator, absolutePath,
978
978
  await createNestedPath(root, parentPath, pathSeparator);
979
979
  }
980
980
  await createFn(absolutePath);
981
- return true;
981
+ return '';
982
982
  } catch (error) {
983
983
  console.error(new VError(error, `Failed to create file`));
984
- return false;
984
+ return `${error}`;
985
985
  }
986
986
  };
987
987
 
@@ -1481,9 +1481,12 @@ const acceptCreate = async (state, newDirentType, createFn) => {
1481
1481
  }
1482
1482
  const parentFolder = getParentFolder(items, focusedIndex, root);
1483
1483
  const absolutePath = join2(parentFolder, newFileName);
1484
- const successful = await createNewDirentsAccept(newFileName, pathSeparator, absolutePath, root, createFn);
1485
- if (!successful) {
1486
- return state;
1484
+ const createErrorMessage = await createNewDirentsAccept(newFileName, pathSeparator, absolutePath, root, createFn);
1485
+ if (createErrorMessage) {
1486
+ return {
1487
+ ...state,
1488
+ editingErrorMessage: createErrorMessage
1489
+ };
1487
1490
  }
1488
1491
  const pathPaths = getPathParts(root, absolutePath, pathSeparator);
1489
1492
  const children = await getPathPartsChildren(pathPaths);
@@ -2279,7 +2282,7 @@ const focusPrevious = state => {
2279
2282
  }
2280
2283
  };
2281
2284
 
2282
- const commandIds = ['acceptEdit', 'cancelEdit', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'handleInputKeyDown', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleDragLeave', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'cancelTypeAhead', 'updateEditingValue', 'handleKeyDown', 'updateIcons'];
2285
+ const commandIds = ['acceptEdit', 'cancelEdit', 'cancelTypeAhead', 'collapseAll', 'copyPath', 'copyRelativePath', 'dispose', 'expandAll', 'expandRecursively', 'focus', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusNone', 'focusPrevious', 'getFocusedDirent', 'getMenuEntries2', 'getMouseActions', 'handleArrowLeft', 'handleArrowLeft', 'handleArrowRight', 'handleArrowRight', 'handleBlur', 'handleClick', 'handleClickAt', 'handleClickCurrent', 'handleClickCurrentButKeepFocus', 'handleClickOpenFolder', 'handleContextMenu', 'handleContextMenuKeyboard', 'handleCopy', 'handleDragLeave', 'handleDragOver', 'handleDrop', 'handleFocus', 'handleIconThemeChange', 'handleInputBlur', 'handleInputClick', 'handleInputKeyDown', 'handleKeyDown', 'handleLanguagesChanged', 'handleMouseEnter', 'handleMouseLeave', 'handlePaste', 'handlePointerDown', 'handleUpload', 'handleWheel', 'handleWorkspaceChange', 'hotReload', 'newFile', 'newFolder', 'openContainingFolder', 'refresh', 'removeDirent', 'rename', 'renameDirent', 'renderEventListeners', 'revealItem', 'revealItem', 'scrollDown', 'scrollUp', 'selectAll', 'selectDown', 'selectUp', 'setDeltaY', 'setSelectedIndices', 'updateEditingValue', 'updateIcons'];
2283
2286
 
2284
2287
  const getCommandIds = () => {
2285
2288
  return commandIds;
@@ -4071,6 +4074,18 @@ const getNewDirentType = editingType => {
4071
4074
  }
4072
4075
  };
4073
4076
 
4077
+ const isFolder = direntType => {
4078
+ return direntType === Directory || direntType === DirectoryExpanded || direntType === SymLinkFolder;
4079
+ };
4080
+ const getFittingIndex = (dirents, startIndex) => {
4081
+ for (let i = startIndex; i >= 0; i--) {
4082
+ const dirent = dirents[i];
4083
+ if (isFolder(dirent.type)) {
4084
+ return i;
4085
+ }
4086
+ }
4087
+ return -1;
4088
+ };
4074
4089
  const newDirent = async (state, editingType) => {
4075
4090
  // TODO make focus functional instead of side effect
4076
4091
  await setFocus(ExplorerEditBox);
@@ -4084,8 +4099,9 @@ const newDirent = async (state, editingType) => {
4084
4099
  fileIconCache,
4085
4100
  root
4086
4101
  } = state;
4102
+ const index = getFittingIndex(items, focusedIndex);
4087
4103
  const direntType = getNewDirentType(editingType);
4088
- const newDirents = await getNewDirentsForNewDirent(items, focusedIndex, direntType, root);
4104
+ const newDirents = await getNewDirentsForNewDirent(items, index, direntType, root);
4089
4105
  const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, newDirents.length);
4090
4106
  const visible = newDirents.slice(minLineY, maxLineY);
4091
4107
  const {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "2.43.0",
3
+ "version": "2.45.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",