@lvce-editor/explorer-view 7.29.0 → 7.30.1
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.
- package/dist/explorerViewWorkerMain.js +214 -82
- package/package.json +1 -1
|
@@ -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}/`)) {
|
|
@@ -2776,13 +2782,14 @@ const User = 1;
|
|
|
2776
2782
|
const Script = 2;
|
|
2777
2783
|
|
|
2778
2784
|
const acceptEdit = async (state, inputSource = Script) => {
|
|
2779
|
-
if (state.isReadonly) {
|
|
2780
|
-
return state;
|
|
2781
|
-
}
|
|
2782
2785
|
const {
|
|
2783
2786
|
editingType,
|
|
2784
|
-
inputSource: currentInputSource
|
|
2787
|
+
inputSource: currentInputSource,
|
|
2788
|
+
isReadonly
|
|
2785
2789
|
} = state;
|
|
2790
|
+
if (isReadonly) {
|
|
2791
|
+
return state;
|
|
2792
|
+
}
|
|
2786
2793
|
let newState;
|
|
2787
2794
|
switch (editingType) {
|
|
2788
2795
|
case CreateFile:
|
|
@@ -2887,10 +2894,14 @@ const collapseAll = async state => {
|
|
|
2887
2894
|
};
|
|
2888
2895
|
|
|
2889
2896
|
const getFocusedFile = state => {
|
|
2890
|
-
|
|
2897
|
+
const {
|
|
2898
|
+
focusedIndex,
|
|
2899
|
+
items
|
|
2900
|
+
} = state;
|
|
2901
|
+
if (focusedIndex < 0 || focusedIndex >= items.length) {
|
|
2891
2902
|
return undefined;
|
|
2892
2903
|
}
|
|
2893
|
-
const item =
|
|
2904
|
+
const item = items[focusedIndex];
|
|
2894
2905
|
if (item.type !== File) {
|
|
2895
2906
|
return undefined;
|
|
2896
2907
|
}
|
|
@@ -2902,14 +2913,17 @@ const openDiff = async (leftUri, rightUri, focus) => {
|
|
|
2902
2913
|
};
|
|
2903
2914
|
|
|
2904
2915
|
const compareWithSelected = async state => {
|
|
2916
|
+
const {
|
|
2917
|
+
compareSourceUri
|
|
2918
|
+
} = state;
|
|
2905
2919
|
const focusedFile = getFocusedFile(state);
|
|
2906
2920
|
if (!focusedFile) {
|
|
2907
2921
|
return state;
|
|
2908
2922
|
}
|
|
2909
|
-
if (!
|
|
2923
|
+
if (!compareSourceUri || compareSourceUri === focusedFile.path) {
|
|
2910
2924
|
return state;
|
|
2911
2925
|
}
|
|
2912
|
-
await openDiff(
|
|
2926
|
+
await openDiff(compareSourceUri, focusedFile.path, true);
|
|
2913
2927
|
return {
|
|
2914
2928
|
...state,
|
|
2915
2929
|
compareSourceUri: ''
|
|
@@ -2926,10 +2940,13 @@ const getFocusedDirent$1 = state => {
|
|
|
2926
2940
|
};
|
|
2927
2941
|
|
|
2928
2942
|
const copyPath = async state => {
|
|
2943
|
+
const {
|
|
2944
|
+
root
|
|
2945
|
+
} = state;
|
|
2929
2946
|
const dirent = getFocusedDirent$1(state);
|
|
2930
2947
|
// TODO windows paths
|
|
2931
2948
|
// TODO handle error
|
|
2932
|
-
const path = dirent ? dirent.path :
|
|
2949
|
+
const path = dirent ? dirent.path : root;
|
|
2933
2950
|
await writeClipBoardText(path);
|
|
2934
2951
|
return state;
|
|
2935
2952
|
};
|
|
@@ -2958,11 +2975,15 @@ const getRelativePath = (root, pathSeparator, path) => {
|
|
|
2958
2975
|
return path;
|
|
2959
2976
|
};
|
|
2960
2977
|
const copyRelativePath = async state => {
|
|
2978
|
+
const {
|
|
2979
|
+
pathSeparator,
|
|
2980
|
+
root
|
|
2981
|
+
} = state;
|
|
2961
2982
|
const dirent = getFocusedDirent$1(state);
|
|
2962
2983
|
if (!dirent) {
|
|
2963
2984
|
return state;
|
|
2964
2985
|
}
|
|
2965
|
-
const relativePath = getRelativePath(
|
|
2986
|
+
const relativePath = getRelativePath(root, pathSeparator, dirent.path);
|
|
2966
2987
|
// TODO handle error
|
|
2967
2988
|
await writeText(relativePath);
|
|
2968
2989
|
return state;
|
|
@@ -3402,6 +3423,7 @@ const ExplorerDropTarget = 'DropTarget';
|
|
|
3402
3423
|
const ExplorerErrorMessage = 'ExplorerErrorMessage';
|
|
3403
3424
|
const ExplorerInputBox = 'ExplorerInputBox';
|
|
3404
3425
|
const FileIcon = 'FileIcon';
|
|
3426
|
+
const FileIconSlot = 'FileIconSlot';
|
|
3405
3427
|
const FocusOutline = 'FocusOutline';
|
|
3406
3428
|
const IconButton = 'IconButton';
|
|
3407
3429
|
const InputValidationError = 'InputValidationError';
|
|
@@ -4081,7 +4103,10 @@ const create = (id, uri, x, y, width, height, args, parentUid, platform = 0, ass
|
|
|
4081
4103
|
x,
|
|
4082
4104
|
y
|
|
4083
4105
|
};
|
|
4084
|
-
|
|
4106
|
+
const {
|
|
4107
|
+
uid
|
|
4108
|
+
} = state;
|
|
4109
|
+
set(uid, state, state);
|
|
4085
4110
|
return state;
|
|
4086
4111
|
};
|
|
4087
4112
|
|
|
@@ -4276,7 +4301,10 @@ const expandRecursively = async state => {
|
|
|
4276
4301
|
};
|
|
4277
4302
|
|
|
4278
4303
|
const focus = state => {
|
|
4279
|
-
|
|
4304
|
+
const {
|
|
4305
|
+
focus
|
|
4306
|
+
} = state;
|
|
4307
|
+
if (focus) {
|
|
4280
4308
|
return state;
|
|
4281
4309
|
}
|
|
4282
4310
|
return {
|
|
@@ -4587,7 +4615,10 @@ const disable = entry => {
|
|
|
4587
4615
|
};
|
|
4588
4616
|
};
|
|
4589
4617
|
const getWritableEntry = (state, entry) => {
|
|
4590
|
-
|
|
4618
|
+
const {
|
|
4619
|
+
isReadonly
|
|
4620
|
+
} = state;
|
|
4621
|
+
if (isReadonly) {
|
|
4591
4622
|
return disable(entry);
|
|
4592
4623
|
}
|
|
4593
4624
|
return entry;
|
|
@@ -4631,6 +4662,9 @@ const getMenuEntriesRoot = state => {
|
|
|
4631
4662
|
return entries;
|
|
4632
4663
|
};
|
|
4633
4664
|
const getMenuEntries = state => {
|
|
4665
|
+
const {
|
|
4666
|
+
compareSourceUri
|
|
4667
|
+
} = state;
|
|
4634
4668
|
const focusedDirent = getFocusedDirent(state);
|
|
4635
4669
|
if (!focusedDirent) {
|
|
4636
4670
|
return getMenuEntriesRoot(state);
|
|
@@ -4639,7 +4673,7 @@ const getMenuEntries = state => {
|
|
|
4639
4673
|
case Directory:
|
|
4640
4674
|
return getMenuEntriesDirectory(state);
|
|
4641
4675
|
case File:
|
|
4642
|
-
if (
|
|
4676
|
+
if (compareSourceUri && compareSourceUri !== focusedDirent.path) {
|
|
4643
4677
|
return getMenuEntriesFileCompareWithSelected(state);
|
|
4644
4678
|
}
|
|
4645
4679
|
return getMenuEntriesFile(state);
|
|
@@ -4703,7 +4737,11 @@ const getParentStartIndex = (dirents, index) => {
|
|
|
4703
4737
|
};
|
|
4704
4738
|
|
|
4705
4739
|
const focusParentFolder = state => {
|
|
4706
|
-
const
|
|
4740
|
+
const {
|
|
4741
|
+
focusedIndex,
|
|
4742
|
+
items
|
|
4743
|
+
} = state;
|
|
4744
|
+
const parentStartIndex = getParentStartIndex(items, focusedIndex);
|
|
4707
4745
|
if (parentStartIndex === -1) {
|
|
4708
4746
|
return state;
|
|
4709
4747
|
}
|
|
@@ -5124,7 +5162,11 @@ const newDirent = async (state, editingType, editingIcon = '') => {
|
|
|
5124
5162
|
|
|
5125
5163
|
// TODO much shared logic with newFolder
|
|
5126
5164
|
const newFile = state => {
|
|
5127
|
-
|
|
5165
|
+
const {
|
|
5166
|
+
isReadonly,
|
|
5167
|
+
root
|
|
5168
|
+
} = state;
|
|
5169
|
+
if (root === '' || isReadonly) {
|
|
5128
5170
|
return Promise.resolve(state);
|
|
5129
5171
|
}
|
|
5130
5172
|
return newDirent(state, CreateFile);
|
|
@@ -5157,7 +5199,12 @@ const getEditingIcon = async (editingType, value, direntType) => {
|
|
|
5157
5199
|
};
|
|
5158
5200
|
|
|
5159
5201
|
const newFolder = async state => {
|
|
5160
|
-
|
|
5202
|
+
const {
|
|
5203
|
+
editingIndex,
|
|
5204
|
+
isReadonly,
|
|
5205
|
+
root
|
|
5206
|
+
} = state;
|
|
5207
|
+
if (root === '' || isReadonly || editingIndex !== -1) {
|
|
5161
5208
|
return state;
|
|
5162
5209
|
}
|
|
5163
5210
|
const editingIcon = await getEditingIcon(CreateFolder, '');
|
|
@@ -5213,6 +5260,13 @@ const refresh = async state => {
|
|
|
5213
5260
|
sourceControlIgnoredUris
|
|
5214
5261
|
};
|
|
5215
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
|
+
};
|
|
5216
5270
|
|
|
5217
5271
|
const handleButtonClick = async (state, name) => {
|
|
5218
5272
|
switch (name) {
|
|
@@ -5223,7 +5277,7 @@ const handleButtonClick = async (state, name) => {
|
|
|
5223
5277
|
case NewFolder$1:
|
|
5224
5278
|
return newFolder(state);
|
|
5225
5279
|
case Refresh$1:
|
|
5226
|
-
return
|
|
5280
|
+
return refreshExplorer(state);
|
|
5227
5281
|
default:
|
|
5228
5282
|
return state;
|
|
5229
5283
|
}
|
|
@@ -5431,11 +5485,14 @@ const toggleIndividualSelection = async (state, index) => {
|
|
|
5431
5485
|
};
|
|
5432
5486
|
|
|
5433
5487
|
const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey, eventX, eventY) => {
|
|
5488
|
+
const {
|
|
5489
|
+
items
|
|
5490
|
+
} = state;
|
|
5434
5491
|
if (defaultPrevented || button !== LeftClick) {
|
|
5435
5492
|
return state;
|
|
5436
5493
|
}
|
|
5437
5494
|
const index = getIndexFromPosition(state, eventX, eventY);
|
|
5438
|
-
if (index === -1 || index >=
|
|
5495
|
+
if (index === -1 || index >= items.length) {
|
|
5439
5496
|
return focusIndex(state, -1);
|
|
5440
5497
|
}
|
|
5441
5498
|
if (shiftKey) {
|
|
@@ -5448,11 +5505,19 @@ const handleClickAt = async (state, defaultPrevented, button, ctrlKey, shiftKey,
|
|
|
5448
5505
|
};
|
|
5449
5506
|
|
|
5450
5507
|
const handleClickCurrent = state => {
|
|
5451
|
-
|
|
5508
|
+
const {
|
|
5509
|
+
focusedIndex,
|
|
5510
|
+
minLineY
|
|
5511
|
+
} = state;
|
|
5512
|
+
return handleClick(state, focusedIndex - minLineY, /* keepFocus */false);
|
|
5452
5513
|
};
|
|
5453
5514
|
|
|
5454
5515
|
const handleClickCurrentButKeepFocus = state => {
|
|
5455
|
-
|
|
5516
|
+
const {
|
|
5517
|
+
focusedIndex,
|
|
5518
|
+
minLineY
|
|
5519
|
+
} = state;
|
|
5520
|
+
return handleClick(state, focusedIndex - minLineY, /* keepFocus */true);
|
|
5456
5521
|
};
|
|
5457
5522
|
|
|
5458
5523
|
const openFolder = async () => {
|
|
@@ -5496,16 +5561,18 @@ const handleContextMenuAtIndex = async (state, index, x, y) => {
|
|
|
5496
5561
|
return newState;
|
|
5497
5562
|
};
|
|
5498
5563
|
|
|
5499
|
-
const handleContextMenuKeyboard = async (state, index
|
|
5564
|
+
const handleContextMenuKeyboard = async (state, index) => {
|
|
5500
5565
|
const {
|
|
5566
|
+
focusedIndex,
|
|
5501
5567
|
itemHeight,
|
|
5502
5568
|
minLineY,
|
|
5503
5569
|
x,
|
|
5504
5570
|
y
|
|
5505
5571
|
} = state;
|
|
5572
|
+
const actualIndex = index === undefined ? focusedIndex : index;
|
|
5506
5573
|
const menuX = x;
|
|
5507
|
-
const menuY = y + (
|
|
5508
|
-
return handleContextMenuAtIndex(state,
|
|
5574
|
+
const menuY = y + (actualIndex - minLineY + 1) * itemHeight;
|
|
5575
|
+
return handleContextMenuAtIndex(state, actualIndex, menuX, menuY);
|
|
5509
5576
|
};
|
|
5510
5577
|
|
|
5511
5578
|
const handleContextMenuMouseAt = async (state, x, y) => {
|
|
@@ -5560,15 +5627,16 @@ const getSelectedItems = (items, focusedIndex) => {
|
|
|
5560
5627
|
};
|
|
5561
5628
|
|
|
5562
5629
|
const handleCut = async state => {
|
|
5563
|
-
if (state.isReadonly) {
|
|
5564
|
-
return state;
|
|
5565
|
-
}
|
|
5566
|
-
// TODO handle multiple files
|
|
5567
|
-
// TODO if not file is selected, what happens?
|
|
5568
5630
|
const {
|
|
5569
5631
|
focusedIndex,
|
|
5632
|
+
isReadonly,
|
|
5570
5633
|
items
|
|
5571
5634
|
} = state;
|
|
5635
|
+
if (isReadonly) {
|
|
5636
|
+
return state;
|
|
5637
|
+
}
|
|
5638
|
+
// TODO handle multiple files
|
|
5639
|
+
// TODO if not file is selected, what happens?
|
|
5572
5640
|
const dirents = getSelectedItems(items, focusedIndex);
|
|
5573
5641
|
if (dirents.length === 0) {
|
|
5574
5642
|
return state;
|
|
@@ -5586,11 +5654,14 @@ const handleCut = async state => {
|
|
|
5586
5654
|
};
|
|
5587
5655
|
|
|
5588
5656
|
const handleDoubleClick = async (state, eventX, eventY) => {
|
|
5657
|
+
const {
|
|
5658
|
+
items
|
|
5659
|
+
} = state;
|
|
5589
5660
|
const index = getIndexFromPosition(state, eventX, eventY);
|
|
5590
5661
|
if (index === -1) {
|
|
5591
5662
|
return newFile(state);
|
|
5592
5663
|
}
|
|
5593
|
-
const item =
|
|
5664
|
+
const item = items[index];
|
|
5594
5665
|
const type = normalizeDirentType(item.type);
|
|
5595
5666
|
if (type === File || type === SymLinkFile) {
|
|
5596
5667
|
return set$1(state, openUri(item.path, true));
|
|
@@ -5680,12 +5751,14 @@ const isEqual = (a, b) => {
|
|
|
5680
5751
|
};
|
|
5681
5752
|
|
|
5682
5753
|
const handleDragOverIndex = (state, index) => {
|
|
5683
|
-
if (state.isReadonly && state.root !== '') {
|
|
5684
|
-
return state;
|
|
5685
|
-
}
|
|
5686
5754
|
const {
|
|
5687
|
-
dropTargets
|
|
5755
|
+
dropTargets,
|
|
5756
|
+
isReadonly,
|
|
5757
|
+
root
|
|
5688
5758
|
} = state;
|
|
5759
|
+
if (isReadonly && root !== '') {
|
|
5760
|
+
return state;
|
|
5761
|
+
}
|
|
5689
5762
|
const newDropTargets = getNewDropTargets(state, index);
|
|
5690
5763
|
if (isEqual(dropTargets, newDropTargets)) {
|
|
5691
5764
|
return state;
|
|
@@ -5697,9 +5770,13 @@ const handleDragOverIndex = (state, index) => {
|
|
|
5697
5770
|
};
|
|
5698
5771
|
|
|
5699
5772
|
const handleDragOver = (state, x, y) => {
|
|
5773
|
+
const {
|
|
5774
|
+
isReadonly,
|
|
5775
|
+
root
|
|
5776
|
+
} = state;
|
|
5700
5777
|
number(x);
|
|
5701
5778
|
number(y);
|
|
5702
|
-
if (
|
|
5779
|
+
if (isReadonly && root !== '') {
|
|
5703
5780
|
return state;
|
|
5704
5781
|
}
|
|
5705
5782
|
const index = getIndexFromPosition(state, x, y);
|
|
@@ -6146,7 +6223,10 @@ const openDroppedDirectoryAsWorkspace$1 = async (state, fileHandle) => {
|
|
|
6146
6223
|
};
|
|
6147
6224
|
};
|
|
6148
6225
|
const getFirstDroppedDirectory = (state, fileHandles) => {
|
|
6149
|
-
|
|
6226
|
+
const {
|
|
6227
|
+
root
|
|
6228
|
+
} = state;
|
|
6229
|
+
if (root !== '') {
|
|
6150
6230
|
return undefined;
|
|
6151
6231
|
}
|
|
6152
6232
|
for (const item of fileHandles) {
|
|
@@ -6229,7 +6309,10 @@ const openDroppedDirectoryAsWorkspace = async (state, path) => {
|
|
|
6229
6309
|
};
|
|
6230
6310
|
};
|
|
6231
6311
|
const getFirstDroppedDirectoryPath = (state, fileHandles, paths) => {
|
|
6232
|
-
|
|
6312
|
+
const {
|
|
6313
|
+
root
|
|
6314
|
+
} = state;
|
|
6315
|
+
if (root !== '') {
|
|
6233
6316
|
return undefined;
|
|
6234
6317
|
}
|
|
6235
6318
|
for (let i = 0; i < fileHandles.length; i++) {
|
|
@@ -6394,13 +6477,18 @@ const getModule = isElectron => {
|
|
|
6394
6477
|
return handleDrop$2;
|
|
6395
6478
|
};
|
|
6396
6479
|
const handleDropRoot = async (state, fileHandles, files, paths) => {
|
|
6397
|
-
|
|
6480
|
+
const {
|
|
6481
|
+
isReadonly,
|
|
6482
|
+
platform,
|
|
6483
|
+
root
|
|
6484
|
+
} = state;
|
|
6485
|
+
if (isReadonly && root !== '') {
|
|
6398
6486
|
return state;
|
|
6399
6487
|
}
|
|
6400
6488
|
if (fileHandles.length === 0 && paths.length > 0) {
|
|
6401
6489
|
return handleInternalDrop(state, paths, -1);
|
|
6402
6490
|
}
|
|
6403
|
-
const isElectron =
|
|
6491
|
+
const isElectron = platform === Electron;
|
|
6404
6492
|
const fn = getModule(isElectron);
|
|
6405
6493
|
return fn(state, fileHandles, files, paths);
|
|
6406
6494
|
};
|
|
@@ -6450,15 +6538,16 @@ const handleDropIntoFile = (state, dirent, index, fileHandles, files, paths) =>
|
|
|
6450
6538
|
return handleDropIndex(state, fileHandles, files, paths, parentIndex);
|
|
6451
6539
|
};
|
|
6452
6540
|
const handleDropIndex = async (state, fileHandles, files, paths, index) => {
|
|
6453
|
-
|
|
6541
|
+
const {
|
|
6542
|
+
isReadonly,
|
|
6543
|
+
items
|
|
6544
|
+
} = state;
|
|
6545
|
+
if (isReadonly) {
|
|
6454
6546
|
return state;
|
|
6455
6547
|
}
|
|
6456
6548
|
if (fileHandles.length === 0 && paths.length > 0) {
|
|
6457
6549
|
return handleInternalDrop(state, paths, index);
|
|
6458
6550
|
}
|
|
6459
|
-
const {
|
|
6460
|
-
items
|
|
6461
|
-
} = state;
|
|
6462
6551
|
const dirent = items[index];
|
|
6463
6552
|
// TODO if it is a file, drop into the folder of the file
|
|
6464
6553
|
// TODO if it is a folder, drop into the folder
|
|
@@ -6524,20 +6613,26 @@ const getInternalDragPaths = (items, uris) => {
|
|
|
6524
6613
|
};
|
|
6525
6614
|
|
|
6526
6615
|
const handleDrop = async (state, x, y, dropIdOrFileIds) => {
|
|
6527
|
-
|
|
6616
|
+
const {
|
|
6617
|
+
isReadonly,
|
|
6618
|
+
items,
|
|
6619
|
+
platform,
|
|
6620
|
+
root
|
|
6621
|
+
} = state;
|
|
6622
|
+
if (isReadonly && root !== '') {
|
|
6528
6623
|
if (typeof dropIdOrFileIds === 'number') {
|
|
6529
6624
|
await discardDrop(dropIdOrFileIds);
|
|
6530
6625
|
}
|
|
6531
6626
|
return state;
|
|
6532
6627
|
}
|
|
6533
6628
|
try {
|
|
6534
|
-
const isElectron =
|
|
6629
|
+
const isElectron = platform === Electron;
|
|
6535
6630
|
const {
|
|
6536
6631
|
fileHandles,
|
|
6537
6632
|
paths,
|
|
6538
6633
|
uris
|
|
6539
6634
|
} = await getDroppedItems(dropIdOrFileIds, isElectron);
|
|
6540
|
-
const internalPaths = getInternalDragPaths(
|
|
6635
|
+
const internalPaths = getInternalDragPaths(items, uris);
|
|
6541
6636
|
const droppedPaths = internalPaths.length > 0 ? internalPaths : paths;
|
|
6542
6637
|
const index = getIndexFromPosition(state, x, y);
|
|
6543
6638
|
const fn = getDropHandler(index);
|
|
@@ -6556,7 +6651,10 @@ const handleEscape = async state => {
|
|
|
6556
6651
|
};
|
|
6557
6652
|
|
|
6558
6653
|
const handleFocus = async state => {
|
|
6559
|
-
|
|
6654
|
+
const {
|
|
6655
|
+
editingIndex
|
|
6656
|
+
} = state;
|
|
6657
|
+
if (editingIndex !== -1) {
|
|
6560
6658
|
return state;
|
|
6561
6659
|
}
|
|
6562
6660
|
return {
|
|
@@ -6730,14 +6828,17 @@ const scrollInto = (index, minLineY, maxLineY) => {
|
|
|
6730
6828
|
|
|
6731
6829
|
const adjustScrollAfterPaste = (state, focusedIndex) => {
|
|
6732
6830
|
const {
|
|
6831
|
+
height,
|
|
6733
6832
|
itemHeight,
|
|
6833
|
+
items,
|
|
6734
6834
|
maxLineY,
|
|
6735
6835
|
minLineY
|
|
6736
6836
|
} = state;
|
|
6837
|
+
const currentMaxLineY = Math.max(maxLineY, getExplorerMaxLineY(minLineY, height, itemHeight, items.length));
|
|
6737
6838
|
const {
|
|
6738
6839
|
newMaxLineY,
|
|
6739
6840
|
newMinLineY
|
|
6740
|
-
} = scrollInto(focusedIndex, minLineY,
|
|
6841
|
+
} = scrollInto(focusedIndex, minLineY, currentMaxLineY);
|
|
6741
6842
|
const newDeltaY = newMinLineY * itemHeight;
|
|
6742
6843
|
return {
|
|
6743
6844
|
...state,
|
|
@@ -6915,7 +7016,11 @@ const handlePasteCut = async (state, nativeFiles) => {
|
|
|
6915
7016
|
const None$1 = 'none';
|
|
6916
7017
|
|
|
6917
7018
|
const handlePaste = async state => {
|
|
6918
|
-
|
|
7019
|
+
const {
|
|
7020
|
+
isReadonly,
|
|
7021
|
+
pasteShouldMove
|
|
7022
|
+
} = state;
|
|
7023
|
+
if (isReadonly) {
|
|
6919
7024
|
return state;
|
|
6920
7025
|
}
|
|
6921
7026
|
const nativeFiles = await readNativeFiles();
|
|
@@ -6941,7 +7046,7 @@ const handlePaste = async state => {
|
|
|
6941
7046
|
}
|
|
6942
7047
|
|
|
6943
7048
|
// Use the pasteShouldMove flag to determine whether to cut or copy
|
|
6944
|
-
if (
|
|
7049
|
+
if (pasteShouldMove) {
|
|
6945
7050
|
return handlePasteCut(state, nativeFiles);
|
|
6946
7051
|
}
|
|
6947
7052
|
return handlePasteCopy(state, nativeFiles);
|
|
@@ -7026,6 +7131,16 @@ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
|
7026
7131
|
};
|
|
7027
7132
|
|
|
7028
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;
|
|
7029
7144
|
const {
|
|
7030
7145
|
height: rawHeight,
|
|
7031
7146
|
width: rawWidth
|
|
@@ -7035,18 +7150,13 @@ const handleResize = (state, dimensions) => {
|
|
|
7035
7150
|
}
|
|
7036
7151
|
const height = Math.max(0, rawHeight);
|
|
7037
7152
|
const width = Math.max(0, rawWidth);
|
|
7038
|
-
const {
|
|
7039
|
-
deltaY,
|
|
7040
|
-
itemHeight,
|
|
7041
|
-
items
|
|
7042
|
-
} = state;
|
|
7043
7153
|
const contentHeight = items.length * itemHeight;
|
|
7044
7154
|
const maxDeltaY = Math.max(contentHeight - height, 0);
|
|
7045
|
-
const newDeltaY = Math.min(Math.max(
|
|
7155
|
+
const newDeltaY = Math.min(Math.max(currentDeltaY, 0), maxDeltaY);
|
|
7046
7156
|
const minLineY = Math.round(newDeltaY / itemHeight);
|
|
7047
7157
|
const maxLineY = getExplorerMaxLineY(minLineY, height, itemHeight, items.length);
|
|
7048
7158
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, 20);
|
|
7049
|
-
if (
|
|
7159
|
+
if (currentHeight === height && currentWidth === width && currentDeltaY === newDeltaY && currentMinLineY === minLineY && currentMaxLineY === maxLineY && currentScrollBarHeight === scrollBarHeight) {
|
|
7050
7160
|
return state;
|
|
7051
7161
|
}
|
|
7052
7162
|
return {
|
|
@@ -7088,20 +7198,21 @@ const getNewDeltaYPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
7088
7198
|
};
|
|
7089
7199
|
|
|
7090
7200
|
const setDeltaY = async (state, deltaY) => {
|
|
7091
|
-
if (!Number.isFinite(deltaY)) {
|
|
7092
|
-
return state;
|
|
7093
|
-
}
|
|
7094
7201
|
const {
|
|
7202
|
+
deltaY: currentDeltaY,
|
|
7095
7203
|
height,
|
|
7096
7204
|
itemHeight,
|
|
7097
7205
|
items
|
|
7098
7206
|
} = state;
|
|
7207
|
+
if (!Number.isFinite(deltaY)) {
|
|
7208
|
+
return state;
|
|
7209
|
+
}
|
|
7099
7210
|
if (deltaY < 0) {
|
|
7100
7211
|
deltaY = 0;
|
|
7101
7212
|
} else if (deltaY > items.length * itemHeight - height) {
|
|
7102
7213
|
deltaY = Math.max(items.length * itemHeight - height, 0);
|
|
7103
7214
|
}
|
|
7104
|
-
if (
|
|
7215
|
+
if (currentDeltaY === deltaY) {
|
|
7105
7216
|
return state;
|
|
7106
7217
|
}
|
|
7107
7218
|
const minLineY = Math.round(deltaY / itemHeight);
|
|
@@ -7175,13 +7286,14 @@ const handleScrollBarMove = async (state, eventY) => {
|
|
|
7175
7286
|
};
|
|
7176
7287
|
|
|
7177
7288
|
const handleUpload = async (state, dirents) => {
|
|
7178
|
-
if (state.isReadonly) {
|
|
7179
|
-
return state;
|
|
7180
|
-
}
|
|
7181
7289
|
const {
|
|
7290
|
+
isReadonly,
|
|
7182
7291
|
pathSeparator,
|
|
7183
7292
|
root
|
|
7184
7293
|
} = state;
|
|
7294
|
+
if (isReadonly) {
|
|
7295
|
+
return state;
|
|
7296
|
+
}
|
|
7185
7297
|
for (const dirent of dirents) {
|
|
7186
7298
|
// TODO switch
|
|
7187
7299
|
// TODO symlink might not be possible to be copied
|
|
@@ -7198,7 +7310,10 @@ const handleUpload = async (state, dirents) => {
|
|
|
7198
7310
|
};
|
|
7199
7311
|
|
|
7200
7312
|
const handleWheel = (state, deltaMode, deltaY) => {
|
|
7201
|
-
|
|
7313
|
+
const {
|
|
7314
|
+
deltaY: currentDeltaY
|
|
7315
|
+
} = state;
|
|
7316
|
+
return setDeltaY(state, currentDeltaY + deltaY);
|
|
7202
7317
|
};
|
|
7203
7318
|
|
|
7204
7319
|
const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
|
|
@@ -7286,14 +7401,15 @@ const showErrorAlert = async errorMessage => {
|
|
|
7286
7401
|
};
|
|
7287
7402
|
|
|
7288
7403
|
const removeDirent = async state => {
|
|
7289
|
-
if (state.isReadonly) {
|
|
7290
|
-
return state;
|
|
7291
|
-
}
|
|
7292
7404
|
const {
|
|
7293
7405
|
confirmDelete: confirmDelete$1,
|
|
7294
7406
|
focusedIndex,
|
|
7407
|
+
isReadonly,
|
|
7295
7408
|
items
|
|
7296
7409
|
} = state;
|
|
7410
|
+
if (isReadonly) {
|
|
7411
|
+
return state;
|
|
7412
|
+
}
|
|
7297
7413
|
const selectedItems = getSelectedItems(items, focusedIndex);
|
|
7298
7414
|
if (selectedItems.length === 0) {
|
|
7299
7415
|
return state;
|
|
@@ -7356,16 +7472,17 @@ const getRenameSelectionRange = name => {
|
|
|
7356
7472
|
};
|
|
7357
7473
|
|
|
7358
7474
|
const renameDirent = async state => {
|
|
7359
|
-
if (state.isReadonly) {
|
|
7360
|
-
return state;
|
|
7361
|
-
}
|
|
7362
7475
|
const {
|
|
7363
7476
|
editingSessionId,
|
|
7364
7477
|
focusedIndex,
|
|
7365
7478
|
icons,
|
|
7479
|
+
isReadonly,
|
|
7366
7480
|
items,
|
|
7367
7481
|
minLineY
|
|
7368
7482
|
} = state;
|
|
7483
|
+
if (isReadonly) {
|
|
7484
|
+
return state;
|
|
7485
|
+
}
|
|
7369
7486
|
if (items.length === 0) {
|
|
7370
7487
|
return state;
|
|
7371
7488
|
}
|
|
@@ -7754,6 +7871,7 @@ const getExplorerItemVirtualDom = (item, editingSessionId = 0) => {
|
|
|
7754
7871
|
setSize
|
|
7755
7872
|
} = item;
|
|
7756
7873
|
const chevronDom = getChevronVirtualDom(chevron);
|
|
7874
|
+
const fileIconDom = icon ? [getFileIconVirtualDom(icon)] : [];
|
|
7757
7875
|
return [{
|
|
7758
7876
|
ariaExpanded,
|
|
7759
7877
|
ariaLabel: name,
|
|
@@ -7771,7 +7889,11 @@ const getExplorerItemVirtualDom = (item, editingSessionId = 0) => {
|
|
|
7771
7889
|
role: TreeItem,
|
|
7772
7890
|
title: getTitle(path),
|
|
7773
7891
|
type: Div
|
|
7774
|
-
}, ...chevronDom,
|
|
7892
|
+
}, ...chevronDom, {
|
|
7893
|
+
childCount: fileIconDom.length,
|
|
7894
|
+
className: FileIconSlot,
|
|
7895
|
+
type: Div
|
|
7896
|
+
}, ...fileIconDom, ...getInputDom(isEditing, hasEditingError, editingSessionId), ...getLabelDom(isEditing, name, isCut || isIgnored)];
|
|
7775
7897
|
};
|
|
7776
7898
|
|
|
7777
7899
|
const getActiveDescendant = focusedIndex => {
|
|
@@ -7905,18 +8027,28 @@ const getMissingFolderMessage = root => {
|
|
|
7905
8027
|
return 'Could not open folder because the folder does not exist. It may have been moved or deleted.';
|
|
7906
8028
|
};
|
|
7907
8029
|
const getLoadErrorMessage = state => {
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
8030
|
+
const {
|
|
8031
|
+
errorCode,
|
|
8032
|
+
errorMessage,
|
|
8033
|
+
hasError,
|
|
8034
|
+
root
|
|
8035
|
+
} = state;
|
|
8036
|
+
if (hasError) {
|
|
8037
|
+
if (errorCode === 'ENOENT') {
|
|
8038
|
+
return getMissingFolderMessage(root);
|
|
7911
8039
|
}
|
|
7912
|
-
const code =
|
|
7913
|
-
const reason =
|
|
8040
|
+
const code = errorCode ? ` (error code: ${errorCode})` : '';
|
|
8041
|
+
const reason = errorMessage || 'an unexpected error occurred';
|
|
7914
8042
|
return `Could not open folder due to ${reason}${code}.`;
|
|
7915
8043
|
}
|
|
7916
8044
|
return '';
|
|
7917
8045
|
};
|
|
7918
8046
|
const shouldShowOpenAnotherFolderButton = state => {
|
|
7919
|
-
|
|
8047
|
+
const {
|
|
8048
|
+
errorCode,
|
|
8049
|
+
hasError
|
|
8050
|
+
} = state;
|
|
8051
|
+
return hasError && errorCode === 'ENOENT';
|
|
7920
8052
|
};
|
|
7921
8053
|
|
|
7922
8054
|
const renderItems = (oldState, newState) => {
|
|
@@ -8578,7 +8710,7 @@ const commandMap = {
|
|
|
8578
8710
|
'Explorer.newFolder': wrapListItemCommand(newFolder),
|
|
8579
8711
|
'Explorer.openContainingFolder': wrapListItemCommand(openContainingFolder),
|
|
8580
8712
|
'Explorer.openInIntegratedTerminal': wrapListItemCommand(openInIntegratedTerminal),
|
|
8581
|
-
'Explorer.refresh': wrapListItemCommand(
|
|
8713
|
+
'Explorer.refresh': wrapListItemCommand(refreshExplorer),
|
|
8582
8714
|
'Explorer.removeDirent': wrapListItemCommand(removeDirent),
|
|
8583
8715
|
'Explorer.renameDirent': wrapListItemCommand(renameDirent),
|
|
8584
8716
|
'Explorer.render2': render2,
|