@lvce-editor/explorer-view 7.30.0 → 7.30.2

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.
@@ -2782,13 +2782,14 @@ const User = 1;
2782
2782
  const Script = 2;
2783
2783
 
2784
2784
  const acceptEdit = async (state, inputSource = Script) => {
2785
- if (state.isReadonly) {
2786
- return state;
2787
- }
2788
2785
  const {
2789
2786
  editingType,
2790
- inputSource: currentInputSource
2787
+ inputSource: currentInputSource,
2788
+ isReadonly
2791
2789
  } = state;
2790
+ if (isReadonly) {
2791
+ return state;
2792
+ }
2792
2793
  let newState;
2793
2794
  switch (editingType) {
2794
2795
  case CreateFile:
@@ -2893,10 +2894,14 @@ const collapseAll = async state => {
2893
2894
  };
2894
2895
 
2895
2896
  const getFocusedFile = state => {
2896
- if (state.focusedIndex < 0 || state.focusedIndex >= state.items.length) {
2897
+ const {
2898
+ focusedIndex,
2899
+ items
2900
+ } = state;
2901
+ if (focusedIndex < 0 || focusedIndex >= items.length) {
2897
2902
  return undefined;
2898
2903
  }
2899
- const item = state.items[state.focusedIndex];
2904
+ const item = items[focusedIndex];
2900
2905
  if (item.type !== File) {
2901
2906
  return undefined;
2902
2907
  }
@@ -2908,14 +2913,17 @@ const openDiff = async (leftUri, rightUri, focus) => {
2908
2913
  };
2909
2914
 
2910
2915
  const compareWithSelected = async state => {
2916
+ const {
2917
+ compareSourceUri
2918
+ } = state;
2911
2919
  const focusedFile = getFocusedFile(state);
2912
2920
  if (!focusedFile) {
2913
2921
  return state;
2914
2922
  }
2915
- if (!state.compareSourceUri || state.compareSourceUri === focusedFile.path) {
2923
+ if (!compareSourceUri || compareSourceUri === focusedFile.path) {
2916
2924
  return state;
2917
2925
  }
2918
- await openDiff(state.compareSourceUri, focusedFile.path, true);
2926
+ await openDiff(compareSourceUri, focusedFile.path, true);
2919
2927
  return {
2920
2928
  ...state,
2921
2929
  compareSourceUri: ''
@@ -2932,10 +2940,13 @@ const getFocusedDirent$1 = state => {
2932
2940
  };
2933
2941
 
2934
2942
  const copyPath = async state => {
2943
+ const {
2944
+ root
2945
+ } = state;
2935
2946
  const dirent = getFocusedDirent$1(state);
2936
2947
  // TODO windows paths
2937
2948
  // TODO handle error
2938
- const path = dirent ? dirent.path : state.root;
2949
+ const path = dirent ? dirent.path : root;
2939
2950
  await writeClipBoardText(path);
2940
2951
  return state;
2941
2952
  };
@@ -2964,11 +2975,15 @@ const getRelativePath = (root, pathSeparator, path) => {
2964
2975
  return path;
2965
2976
  };
2966
2977
  const copyRelativePath = async state => {
2978
+ const {
2979
+ pathSeparator,
2980
+ root
2981
+ } = state;
2967
2982
  const dirent = getFocusedDirent$1(state);
2968
2983
  if (!dirent) {
2969
2984
  return state;
2970
2985
  }
2971
- const relativePath = getRelativePath(state.root, state.pathSeparator, dirent.path);
2986
+ const relativePath = getRelativePath(root, pathSeparator, dirent.path);
2972
2987
  // TODO handle error
2973
2988
  await writeText(relativePath);
2974
2989
  return state;
@@ -3408,6 +3423,7 @@ const ExplorerDropTarget = 'DropTarget';
3408
3423
  const ExplorerErrorMessage = 'ExplorerErrorMessage';
3409
3424
  const ExplorerInputBox = 'ExplorerInputBox';
3410
3425
  const FileIcon = 'FileIcon';
3426
+ const FileIconSlot = 'FileIconSlot';
3411
3427
  const FocusOutline = 'FocusOutline';
3412
3428
  const IconButton = 'IconButton';
3413
3429
  const InputValidationError = 'InputValidationError';
@@ -4087,7 +4103,10 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, ass
4087
4103
  x,
4088
4104
  y
4089
4105
  };
4090
- set(state.uid, state, state);
4106
+ const {
4107
+ uid
4108
+ } = state;
4109
+ set(uid, state, state);
4091
4110
  return state;
4092
4111
  };
4093
4112
 
@@ -4282,7 +4301,10 @@ const expandRecursively = async state => {
4282
4301
  };
4283
4302
 
4284
4303
  const focus = state => {
4285
- if (state.focus) {
4304
+ const {
4305
+ focus
4306
+ } = state;
4307
+ if (focus) {
4286
4308
  return state;
4287
4309
  }
4288
4310
  return {
@@ -4593,7 +4615,10 @@ const disable = entry => {
4593
4615
  };
4594
4616
  };
4595
4617
  const getWritableEntry = (state, entry) => {
4596
- if (state.isReadonly) {
4618
+ const {
4619
+ isReadonly
4620
+ } = state;
4621
+ if (isReadonly) {
4597
4622
  return disable(entry);
4598
4623
  }
4599
4624
  return entry;
@@ -4637,6 +4662,9 @@ const getMenuEntriesRoot = state => {
4637
4662
  return entries;
4638
4663
  };
4639
4664
  const getMenuEntries = state => {
4665
+ const {
4666
+ compareSourceUri
4667
+ } = state;
4640
4668
  const focusedDirent = getFocusedDirent(state);
4641
4669
  if (!focusedDirent) {
4642
4670
  return getMenuEntriesRoot(state);
@@ -4645,7 +4673,7 @@ const getMenuEntries = state => {
4645
4673
  case Directory:
4646
4674
  return getMenuEntriesDirectory(state);
4647
4675
  case File:
4648
- if (state.compareSourceUri && state.compareSourceUri !== focusedDirent.path) {
4676
+ if (compareSourceUri && compareSourceUri !== focusedDirent.path) {
4649
4677
  return getMenuEntriesFileCompareWithSelected(state);
4650
4678
  }
4651
4679
  return getMenuEntriesFile(state);
@@ -4709,7 +4737,11 @@ const getParentStartIndex = (dirents, index) => {
4709
4737
  };
4710
4738
 
4711
4739
  const focusParentFolder = state => {
4712
- const parentStartIndex = getParentStartIndex(state.items, state.focusedIndex);
4740
+ const {
4741
+ focusedIndex,
4742
+ items
4743
+ } = state;
4744
+ const parentStartIndex = getParentStartIndex(items, focusedIndex);
4713
4745
  if (parentStartIndex === -1) {
4714
4746
  return state;
4715
4747
  }
@@ -5130,7 +5162,11 @@ const newDirent = async (state, editingType, editingIcon = '') => {
5130
5162
 
5131
5163
  // TODO much shared logic with newFolder
5132
5164
  const newFile = state => {
5133
- if (state.root === '' || state.isReadonly) {
5165
+ const {
5166
+ isReadonly,
5167
+ root
5168
+ } = state;
5169
+ if (root === '' || isReadonly) {
5134
5170
  return Promise.resolve(state);
5135
5171
  }
5136
5172
  return newDirent(state, CreateFile);
@@ -5163,7 +5199,12 @@ const getEditingIcon = async (editingType, value, direntType) => {
5163
5199
  };
5164
5200
 
5165
5201
  const newFolder = async state => {
5166
- if (state.root === '' || state.isReadonly || state.editingIndex !== -1) {
5202
+ const {
5203
+ editingIndex,
5204
+ isReadonly,
5205
+ root
5206
+ } = state;
5207
+ if (root === '' || isReadonly || editingIndex !== -1) {
5167
5208
  return state;
5168
5209
  }
5169
5210
  const editingIcon = await getEditingIcon(CreateFolder, '');
@@ -5219,6 +5260,13 @@ const refresh = async state => {
5219
5260
  sourceControlIgnoredUris
5220
5261
  };
5221
5262
  };
5263
+ const refreshExplorer = async state => {
5264
+ const {
5265
+ editingIndex
5266
+ } = state;
5267
+ const stateWithoutEdit = editingIndex === -1 ? state : await cancelEditInternal(state, true);
5268
+ return refresh(stateWithoutEdit);
5269
+ };
5222
5270
 
5223
5271
  const handleButtonClick = async (state, name) => {
5224
5272
  switch (name) {
@@ -5229,7 +5277,7 @@ const handleButtonClick = async (state, name) => {
5229
5277
  case NewFolder$1:
5230
5278
  return newFolder(state);
5231
5279
  case Refresh$1:
5232
- return refresh(state);
5280
+ return refreshExplorer(state);
5233
5281
  default:
5234
5282
  return state;
5235
5283
  }
@@ -5437,11 +5485,14 @@ const toggleIndividualSelection = async (state, index) => {
5437
5485
  };
5438
5486
 
5439
5487
  const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey, eventX, eventY) => {
5488
+ const {
5489
+ items
5490
+ } = state;
5440
5491
  if (defaultPrevented || button !== LeftClick) {
5441
5492
  return state;
5442
5493
  }
5443
5494
  const index = getIndexFromPosition(state, eventX, eventY);
5444
- if (index === -1 || index >= state.items.length) {
5495
+ if (index === -1 || index >= items.length) {
5445
5496
  return focusIndex(state, -1);
5446
5497
  }
5447
5498
  if (shiftKey) {
@@ -5454,11 +5505,19 @@ const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey,
5454
5505
  };
5455
5506
 
5456
5507
  const handleClickCurrent = state => {
5457
- return handleClick(state, state.focusedIndex - state.minLineY, /* keepFocus */false);
5508
+ const {
5509
+ focusedIndex,
5510
+ minLineY
5511
+ } = state;
5512
+ return handleClick(state, focusedIndex - minLineY, /* keepFocus */false);
5458
5513
  };
5459
5514
 
5460
5515
  const handleClickCurrentButKeepFocus = state => {
5461
- return handleClick(state, state.focusedIndex - state.minLineY, /* keepFocus */true);
5516
+ const {
5517
+ focusedIndex,
5518
+ minLineY
5519
+ } = state;
5520
+ return handleClick(state, focusedIndex - minLineY, /* keepFocus */true);
5462
5521
  };
5463
5522
 
5464
5523
  const openFolder = async () => {
@@ -5502,16 +5561,18 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
5502
5561
  return newState;
5503
5562
  };
5504
5563
 
5505
- const handleContextMenuKeyboard = async (state, index = state.focusedIndex) => {
5564
+ const handleContextMenuKeyboard = async (state, index) => {
5506
5565
  const {
5566
+ focusedIndex,
5507
5567
  itemHeight,
5508
5568
  minLineY,
5509
5569
  x,
5510
5570
  y
5511
5571
  } = state;
5572
+ const actualIndex = index === undefined ? focusedIndex : index;
5512
5573
  const menuX = x;
5513
- const menuY = y + (index - minLineY + 1) * itemHeight;
5514
- return handleContextMenuAtIndex(state, index, menuX, menuY);
5574
+ const menuY = y + (actualIndex - minLineY + 1) * itemHeight;
5575
+ return handleContextMenuAtIndex(state, actualIndex, menuX, menuY);
5515
5576
  };
5516
5577
 
5517
5578
  const handleContextMenuMouseAt = async (state, x, y) => {
@@ -5566,15 +5627,16 @@ const getSelectedItems = (items, focusedIndex) => {
5566
5627
  };
5567
5628
 
5568
5629
  const handleCut = async state => {
5569
- if (state.isReadonly) {
5570
- return state;
5571
- }
5572
- // TODO handle multiple files
5573
- // TODO if not file is selected, what happens?
5574
5630
  const {
5575
5631
  focusedIndex,
5632
+ isReadonly,
5576
5633
  items
5577
5634
  } = state;
5635
+ if (isReadonly) {
5636
+ return state;
5637
+ }
5638
+ // TODO handle multiple files
5639
+ // TODO if not file is selected, what happens?
5578
5640
  const dirents = getSelectedItems(items, focusedIndex);
5579
5641
  if (dirents.length === 0) {
5580
5642
  return state;
@@ -5592,11 +5654,14 @@ const handleCut = async state => {
5592
5654
  };
5593
5655
 
5594
5656
  const handleDoubleClick = async (state, eventX, eventY) => {
5657
+ const {
5658
+ items
5659
+ } = state;
5595
5660
  const index = getIndexFromPosition(state, eventX, eventY);
5596
5661
  if (index === -1) {
5597
5662
  return newFile(state);
5598
5663
  }
5599
- const item = state.items[index];
5664
+ const item = items[index];
5600
5665
  const type = normalizeDirentType(item.type);
5601
5666
  if (type === File || type === SymLinkFile) {
5602
5667
  return set$1(state, openUri(item.path, true));
@@ -5686,12 +5751,14 @@ const isEqual = (a, b) => {
5686
5751
  };
5687
5752
 
5688
5753
  const handleDragOverIndex = (state, index) => {
5689
- if (state.isReadonly && state.root !== '') {
5690
- return state;
5691
- }
5692
5754
  const {
5693
- dropTargets
5755
+ dropTargets,
5756
+ isReadonly,
5757
+ root
5694
5758
  } = state;
5759
+ if (isReadonly && root !== '') {
5760
+ return state;
5761
+ }
5695
5762
  const newDropTargets = getNewDropTargets(state, index);
5696
5763
  if (isEqual(dropTargets, newDropTargets)) {
5697
5764
  return state;
@@ -5703,9 +5770,13 @@ const handleDragOverIndex = (state, index) => {
5703
5770
  };
5704
5771
 
5705
5772
  const handleDragOver = (state, x, y) => {
5773
+ const {
5774
+ isReadonly,
5775
+ root
5776
+ } = state;
5706
5777
  number(x);
5707
5778
  number(y);
5708
- if (state.isReadonly && state.root !== '') {
5779
+ if (isReadonly && root !== '') {
5709
5780
  return state;
5710
5781
  }
5711
5782
  const index = getIndexFromPosition(state, x, y);
@@ -6152,7 +6223,10 @@ const openDroppedDirectoryAsWorkspace$1 = async (state, fileHandle) => {
6152
6223
  };
6153
6224
  };
6154
6225
  const getFirstDroppedDirectory = (state, fileHandles) => {
6155
- if (state.root !== '') {
6226
+ const {
6227
+ root
6228
+ } = state;
6229
+ if (root !== '') {
6156
6230
  return undefined;
6157
6231
  }
6158
6232
  for (const item of fileHandles) {
@@ -6235,7 +6309,10 @@ const openDroppedDirectoryAsWorkspace = async (state, path) => {
6235
6309
  };
6236
6310
  };
6237
6311
  const getFirstDroppedDirectoryPath = (state, fileHandles, paths) => {
6238
- if (state.root !== '') {
6312
+ const {
6313
+ root
6314
+ } = state;
6315
+ if (root !== '') {
6239
6316
  return undefined;
6240
6317
  }
6241
6318
  for (let i = 0; i < fileHandles.length; i++) {
@@ -6400,13 +6477,18 @@ const getModule = isElectron => {
6400
6477
  return handleDrop$2;
6401
6478
  };
6402
6479
  const handleDropRoot = async (state, fileHandles, files, paths) => {
6403
- if (state.isReadonly && state.root !== '') {
6480
+ const {
6481
+ isReadonly,
6482
+ platform,
6483
+ root
6484
+ } = state;
6485
+ if (isReadonly && root !== '') {
6404
6486
  return state;
6405
6487
  }
6406
6488
  if (fileHandles.length === 0 && paths.length > 0) {
6407
6489
  return handleInternalDrop(state, paths, -1);
6408
6490
  }
6409
- const isElectron = state.platform === Electron;
6491
+ const isElectron = platform === Electron;
6410
6492
  const fn = getModule(isElectron);
6411
6493
  return fn(state, fileHandles, files, paths);
6412
6494
  };
@@ -6456,15 +6538,16 @@ const handleDropIntoFile = (state, dirent, index, fileHandles, files, paths) =>
6456
6538
  return handleDropIndex(state, fileHandles, files, paths, parentIndex);
6457
6539
  };
6458
6540
  const handleDropIndex = async (state, fileHandles, files, paths, index) => {
6459
- if (state.isReadonly) {
6541
+ const {
6542
+ isReadonly,
6543
+ items
6544
+ } = state;
6545
+ if (isReadonly) {
6460
6546
  return state;
6461
6547
  }
6462
6548
  if (fileHandles.length === 0 && paths.length > 0) {
6463
6549
  return handleInternalDrop(state, paths, index);
6464
6550
  }
6465
- const {
6466
- items
6467
- } = state;
6468
6551
  const dirent = items[index];
6469
6552
  // TODO if it is a file, drop into the folder of the file
6470
6553
  // TODO if it is a folder, drop into the folder
@@ -6530,20 +6613,26 @@ const getInternalDragPaths = (items, uris) => {
6530
6613
  };
6531
6614
 
6532
6615
  const handleDrop = async (state, x, y, dropIdOrFileIds) => {
6533
- if (state.isReadonly && state.root !== '') {
6616
+ const {
6617
+ isReadonly,
6618
+ items,
6619
+ platform,
6620
+ root
6621
+ } = state;
6622
+ if (isReadonly && root !== '') {
6534
6623
  if (typeof dropIdOrFileIds === 'number') {
6535
6624
  await discardDrop(dropIdOrFileIds);
6536
6625
  }
6537
6626
  return state;
6538
6627
  }
6539
6628
  try {
6540
- const isElectron = state.platform === Electron;
6629
+ const isElectron = platform === Electron;
6541
6630
  const {
6542
6631
  fileHandles,
6543
6632
  paths,
6544
6633
  uris
6545
6634
  } = await getDroppedItems(dropIdOrFileIds, isElectron);
6546
- const internalPaths = getInternalDragPaths(state.items, uris);
6635
+ const internalPaths = getInternalDragPaths(items, uris);
6547
6636
  const droppedPaths = internalPaths.length > 0 ? internalPaths : paths;
6548
6637
  const index = getIndexFromPosition(state, x, y);
6549
6638
  const fn = getDropHandler(index);
@@ -6562,7 +6651,10 @@ const handleEscape = async state => {
6562
6651
  };
6563
6652
 
6564
6653
  const handleFocus = async state => {
6565
- if (state.editingIndex !== -1) {
6654
+ const {
6655
+ editingIndex
6656
+ } = state;
6657
+ if (editingIndex !== -1) {
6566
6658
  return state;
6567
6659
  }
6568
6660
  return {
@@ -6736,14 +6828,17 @@ const scrollInto = (index, minLineY, maxLineY) => {
6736
6828
 
6737
6829
  const adjustScrollAfterPaste = (state, focusedIndex) => {
6738
6830
  const {
6831
+ height,
6739
6832
  itemHeight,
6833
+ items,
6740
6834
  maxLineY,
6741
6835
  minLineY
6742
6836
  } = state;
6837
+ const currentMaxLineY = Math.max(maxLineY, getExplorerMaxLineY(minLineY, height, itemHeight, items.length));
6743
6838
  const {
6744
6839
  newMaxLineY,
6745
6840
  newMinLineY
6746
- } = scrollInto(focusedIndex, minLineY, maxLineY);
6841
+ } = scrollInto(focusedIndex, minLineY, currentMaxLineY);
6747
6842
  const newDeltaY = newMinLineY * itemHeight;
6748
6843
  return {
6749
6844
  ...state,
@@ -6921,7 +7016,11 @@ const handlePasteCut = async (state, nativeFiles) => {
6921
7016
  const None$1 = 'none';
6922
7017
 
6923
7018
  const handlePaste = async state => {
6924
- if (state.isReadonly) {
7019
+ const {
7020
+ isReadonly,
7021
+ pasteShouldMove
7022
+ } = state;
7023
+ if (isReadonly) {
6925
7024
  return state;
6926
7025
  }
6927
7026
  const nativeFiles = await readNativeFiles();
@@ -6947,7 +7046,7 @@ const handlePaste = async state => {
6947
7046
  }
6948
7047
 
6949
7048
  // Use the pasteShouldMove flag to determine whether to cut or copy
6950
- if (state.pasteShouldMove) {
7049
+ if (pasteShouldMove) {
6951
7050
  return handlePasteCut(state, nativeFiles);
6952
7051
  }
6953
7052
  return handlePasteCopy(state, nativeFiles);
@@ -7032,6 +7131,16 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
7032
7131
  };
7033
7132
 
7034
7133
  const handleResize = (state, dimensions) => {
7134
+ const {
7135
+ deltaY: currentDeltaY,
7136
+ height: currentHeight,
7137
+ itemHeight,
7138
+ items,
7139
+ maxLineY: currentMaxLineY,
7140
+ minLineY: currentMinLineY,
7141
+ scrollBarHeight: currentScrollBarHeight,
7142
+ width: currentWidth
7143
+ } = state;
7035
7144
  const {
7036
7145
  height: rawHeight,
7037
7146
  width: rawWidth
@@ -7041,18 +7150,13 @@ const handleResize = (state, dimensions) => {
7041
7150
  }
7042
7151
  const height = Math.max(0, rawHeight);
7043
7152
  const width = Math.max(0, rawWidth);
7044
- const {
7045
- deltaY,
7046
- itemHeight,
7047
- items
7048
- } = state;
7049
7153
  const contentHeight = items.length * itemHeight;
7050
7154
  const maxDeltaY = Math.max(contentHeight - height, 0);
7051
- const newDeltaY = Math.min(Math.max(deltaY, 0), maxDeltaY);
7155
+ const newDeltaY = Math.min(Math.max(currentDeltaY, 0), maxDeltaY);
7052
7156
  const minLineY = Math.round(newDeltaY / itemHeight);
7053
7157
  const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
7054
7158
  const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
7055
- if (state.height === height && state.width === width && state.deltaY === newDeltaY && state.minLineY === minLineY && state.maxLineY === maxLineY && state.scrollBarHeight === scrollBarHeight) {
7159
+ if (currentHeight === height && currentWidth === width && currentDeltaY === newDeltaY && currentMinLineY === minLineY && currentMaxLineY === maxLineY && currentScrollBarHeight === scrollBarHeight) {
7056
7160
  return state;
7057
7161
  }
7058
7162
  return {
@@ -7094,20 +7198,21 @@ const getNewDeltaYPercent = (height, scrollBarHeight, relativeY) => {
7094
7198
  };
7095
7199
 
7096
7200
  const setDeltaY = async (state, deltaY) => {
7097
- if (!Number.isFinite(deltaY)) {
7098
- return state;
7099
- }
7100
7201
  const {
7202
+ deltaY: currentDeltaY,
7101
7203
  height,
7102
7204
  itemHeight,
7103
7205
  items
7104
7206
  } = state;
7207
+ if (!Number.isFinite(deltaY)) {
7208
+ return state;
7209
+ }
7105
7210
  if (deltaY < 0) {
7106
7211
  deltaY = 0;
7107
7212
  } else if (deltaY > items.length * itemHeight - height) {
7108
7213
  deltaY = Math.max(items.length * itemHeight - height, 0);
7109
7214
  }
7110
- if (state.deltaY === deltaY) {
7215
+ if (currentDeltaY === deltaY) {
7111
7216
  return state;
7112
7217
  }
7113
7218
  const minLineY = Math.round(deltaY / itemHeight);
@@ -7181,13 +7286,14 @@ const handleScrollBarMove = async (state, eventY) => {
7181
7286
  };
7182
7287
 
7183
7288
  const handleUpload = async (state, dirents) => {
7184
- if (state.isReadonly) {
7185
- return state;
7186
- }
7187
7289
  const {
7290
+ isReadonly,
7188
7291
  pathSeparator,
7189
7292
  root
7190
7293
  } = state;
7294
+ if (isReadonly) {
7295
+ return state;
7296
+ }
7191
7297
  for (const dirent of dirents) {
7192
7298
  // TODO switch
7193
7299
  // TODO symlink might not be possible to be copied
@@ -7204,7 +7310,10 @@ const handleUpload = async (state, dirents) => {
7204
7310
  };
7205
7311
 
7206
7312
  const handleWheel = (state, deltaMode, deltaY) => {
7207
- return setDeltaY(state, state.deltaY + deltaY);
7313
+ const {
7314
+ deltaY: currentDeltaY
7315
+ } = state;
7316
+ return setDeltaY(state, currentDeltaY + deltaY);
7208
7317
  };
7209
7318
 
7210
7319
  const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
@@ -7292,14 +7401,15 @@ const showErrorAlert = async errorMessage => {
7292
7401
  };
7293
7402
 
7294
7403
  const removeDirent = async state => {
7295
- if (state.isReadonly) {
7296
- return state;
7297
- }
7298
7404
  const {
7299
7405
  confirmDelete: confirmDelete$1,
7300
7406
  focusedIndex,
7407
+ isReadonly,
7301
7408
  items
7302
7409
  } = state;
7410
+ if (isReadonly) {
7411
+ return state;
7412
+ }
7303
7413
  const selectedItems = getSelectedItems(items, focusedIndex);
7304
7414
  if (selectedItems.length === 0) {
7305
7415
  return state;
@@ -7362,16 +7472,17 @@ const getRenameSelectionRange = name => {
7362
7472
  };
7363
7473
 
7364
7474
  const renameDirent = async state => {
7365
- if (state.isReadonly) {
7366
- return state;
7367
- }
7368
7475
  const {
7369
7476
  editingSessionId,
7370
7477
  focusedIndex,
7371
7478
  icons,
7479
+ isReadonly,
7372
7480
  items,
7373
7481
  minLineY
7374
7482
  } = state;
7483
+ if (isReadonly) {
7484
+ return state;
7485
+ }
7375
7486
  if (items.length === 0) {
7376
7487
  return state;
7377
7488
  }
@@ -7760,6 +7871,7 @@ const getExplorerItemVirtualDom = (item, editingSessionId = 0) => {
7760
7871
  setSize
7761
7872
  } = item;
7762
7873
  const chevronDom = getChevronVirtualDom(chevron);
7874
+ const fileIconDom = icon ? [getFileIconVirtualDom(icon)] : [];
7763
7875
  return [{
7764
7876
  ariaExpanded,
7765
7877
  ariaLabel: name,
@@ -7777,7 +7889,11 @@ const getExplorerItemVirtualDom = (item, editingSessionId = 0) => {
7777
7889
  role: TreeItem,
7778
7890
  title: getTitle(path),
7779
7891
  type: Div
7780
- }, ...chevronDom, getFileIconVirtualDom(icon), ...getInputDom(isEditing, hasEditingError, editingSessionId), ...getLabelDom(isEditing, name, isCut || isIgnored)];
7892
+ }, ...chevronDom, {
7893
+ childCount: fileIconDom.length,
7894
+ className: FileIconSlot,
7895
+ type: Div
7896
+ }, ...fileIconDom, ...getInputDom(isEditing, hasEditingError, editingSessionId), ...getLabelDom(isEditing, name, isCut || isIgnored)];
7781
7897
  };
7782
7898
 
7783
7899
  const getActiveDescendant = focusedIndex => {
@@ -7904,25 +8020,40 @@ const getExplorerVirtualDom = (visibleItems, focusedIndex, root, isWide, focused
7904
8020
  return dom;
7905
8021
  };
7906
8022
 
8023
+ const RE_SENTENCE_END = /[.!?]$/;
7907
8024
  const getMissingFolderMessage = root => {
7908
8025
  if (root) {
7909
8026
  return `Could not open "${root}" because the folder does not exist. It may have been moved or deleted.`;
7910
8027
  }
7911
8028
  return 'Could not open folder because the folder does not exist. It may have been moved or deleted.';
7912
8029
  };
8030
+ const toSentence = message => {
8031
+ const normalized = `${message[0].toUpperCase()}${message.slice(1)}`;
8032
+ return RE_SENTENCE_END.test(normalized) ? normalized : `${normalized}.`;
8033
+ };
7913
8034
  const getLoadErrorMessage = state => {
7914
- if (state.hasError) {
7915
- if (state.errorCode === 'ENOENT') {
7916
- return getMissingFolderMessage(state.root);
8035
+ const {
8036
+ errorCode,
8037
+ errorMessage,
8038
+ hasError,
8039
+ root
8040
+ } = state;
8041
+ if (hasError) {
8042
+ if (errorCode === 'ENOENT') {
8043
+ return getMissingFolderMessage(root);
7917
8044
  }
7918
- const code = state.errorCode ? ` (error code: ${state.errorCode})` : '';
7919
- const reason = state.errorMessage || 'an unexpected error occurred';
7920
- return `Could not open folder due to ${reason}${code}.`;
8045
+ const reason = errorMessage || 'an unexpected error occurred';
8046
+ const code = errorCode ? ` Error code: ${errorCode}.` : '';
8047
+ return `Could not open folder. ${toSentence(reason)}${code}`;
7921
8048
  }
7922
8049
  return '';
7923
8050
  };
7924
8051
  const shouldShowOpenAnotherFolderButton = state => {
7925
- return state.hasError && state.errorCode === 'ENOENT';
8052
+ const {
8053
+ errorCode,
8054
+ hasError
8055
+ } = state;
8056
+ return hasError && errorCode === 'ENOENT';
7926
8057
  };
7927
8058
 
7928
8059
  const renderItems = (oldState, newState) => {
@@ -8584,7 +8715,7 @@ const commandMap = {
8584
8715
  'Explorer.newFolder': wrapListItemCommand(newFolder),
8585
8716
  'Explorer.openContainingFolder': wrapListItemCommand(openContainingFolder),
8586
8717
  'Explorer.openInIntegratedTerminal': wrapListItemCommand(openInIntegratedTerminal),
8587
- 'Explorer.refresh': wrapListItemCommand(refresh),
8718
+ 'Explorer.refresh': wrapListItemCommand(refreshExplorer),
8588
8719
  'Explorer.removeDirent': wrapListItemCommand(removeDirent),
8589
8720
  'Explorer.renameDirent': wrapListItemCommand(renameDirent),
8590
8721
  'Explorer.render2': render2,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "7.30.0",
3
+ "version": "7.30.2",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",