@lvce-editor/explorer-view 2.54.0 → 2.55.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.
- package/dist/explorerViewWorkerMain.js +69 -44
- package/package.json +1 -1
|
@@ -889,7 +889,7 @@ const Copy$2 = 3;
|
|
|
889
889
|
const Rename$2 = 4;
|
|
890
890
|
|
|
891
891
|
const rpcs = Object.create(null);
|
|
892
|
-
const set$
|
|
892
|
+
const set$g = (id, rpc) => {
|
|
893
893
|
rpcs[id] = rpc;
|
|
894
894
|
};
|
|
895
895
|
const get$1 = id => {
|
|
@@ -913,7 +913,7 @@ const create$2 = rpcId => {
|
|
|
913
913
|
return rpc.invokeAndTransfer(method, ...params);
|
|
914
914
|
},
|
|
915
915
|
set(rpc) {
|
|
916
|
-
set$
|
|
916
|
+
set$g(rpcId, rpc);
|
|
917
917
|
},
|
|
918
918
|
async dispose() {
|
|
919
919
|
const rpc = get$1(rpcId);
|
|
@@ -3680,6 +3680,49 @@ const handleKeyDown = (state, key) => {
|
|
|
3680
3680
|
};
|
|
3681
3681
|
};
|
|
3682
3682
|
|
|
3683
|
+
const scrollInto = (index, minLineY, maxLineY) => {
|
|
3684
|
+
const diff = maxLineY - minLineY;
|
|
3685
|
+
const smallerHalf = Math.floor(diff / 2);
|
|
3686
|
+
const largerHalf = diff - smallerHalf;
|
|
3687
|
+
if (index < minLineY) {
|
|
3688
|
+
return {
|
|
3689
|
+
newMinLineY: index - smallerHalf,
|
|
3690
|
+
newMaxLineY: index + largerHalf
|
|
3691
|
+
};
|
|
3692
|
+
}
|
|
3693
|
+
if (index >= maxLineY) {
|
|
3694
|
+
return {
|
|
3695
|
+
newMinLineY: index - smallerHalf,
|
|
3696
|
+
newMaxLineY: index + largerHalf
|
|
3697
|
+
};
|
|
3698
|
+
}
|
|
3699
|
+
return {
|
|
3700
|
+
newMinLineY: minLineY,
|
|
3701
|
+
newMaxLineY: maxLineY
|
|
3702
|
+
};
|
|
3703
|
+
};
|
|
3704
|
+
|
|
3705
|
+
const adjustScrollAfterPaste = (state, focusedIndex) => {
|
|
3706
|
+
const {
|
|
3707
|
+
minLineY,
|
|
3708
|
+
maxLineY,
|
|
3709
|
+
itemHeight
|
|
3710
|
+
} = state;
|
|
3711
|
+
const {
|
|
3712
|
+
newMinLineY,
|
|
3713
|
+
newMaxLineY
|
|
3714
|
+
} = scrollInto(focusedIndex, minLineY, maxLineY);
|
|
3715
|
+
const newDeltaY = newMinLineY * itemHeight;
|
|
3716
|
+
return {
|
|
3717
|
+
...state,
|
|
3718
|
+
focusedIndex,
|
|
3719
|
+
focused: true,
|
|
3720
|
+
minLineY: newMinLineY,
|
|
3721
|
+
maxLineY: newMaxLineY,
|
|
3722
|
+
deltaY: newDeltaY
|
|
3723
|
+
};
|
|
3724
|
+
};
|
|
3725
|
+
|
|
3683
3726
|
const generateUniqueName = (baseName, existingPaths, root) => {
|
|
3684
3727
|
// Handle files with extensions
|
|
3685
3728
|
const lastDotIndex = baseName.lastIndexOf('.');
|
|
@@ -3756,17 +3799,13 @@ const handlePasteCopy = async (state, nativeFiles) => {
|
|
|
3756
3799
|
// TODO only update folder at which level it changed
|
|
3757
3800
|
const latestState = await refresh(state);
|
|
3758
3801
|
|
|
3759
|
-
// Focus on the first newly created file
|
|
3802
|
+
// Focus on the first newly created file and adjust scroll position
|
|
3760
3803
|
const newFilePaths = operations.map(operation => operation.path);
|
|
3761
3804
|
if (newFilePaths.length > 0) {
|
|
3762
3805
|
const firstNewFilePath = newFilePaths[0];
|
|
3763
3806
|
const newFileIndex = getIndex(latestState.items, firstNewFilePath);
|
|
3764
3807
|
if (newFileIndex !== -1) {
|
|
3765
|
-
return
|
|
3766
|
-
...latestState,
|
|
3767
|
-
focusedIndex: newFileIndex,
|
|
3768
|
-
focused: true
|
|
3769
|
-
};
|
|
3808
|
+
return adjustScrollAfterPaste(latestState, newFileIndex);
|
|
3770
3809
|
}
|
|
3771
3810
|
}
|
|
3772
3811
|
// If there are no items, ensure focusedIndex is 0
|
|
@@ -3784,7 +3823,20 @@ const handlePasteCut = async (state, nativeFiles) => {
|
|
|
3784
3823
|
const target = `${state.root}${state.pathSeparator}${getBaseName(state.pathSeparator, source)}`;
|
|
3785
3824
|
await rename$1(source, target);
|
|
3786
3825
|
}
|
|
3787
|
-
|
|
3826
|
+
|
|
3827
|
+
// Refresh the state after cut operations
|
|
3828
|
+
const latestState = await refresh(state);
|
|
3829
|
+
|
|
3830
|
+
// Focus on the first pasted file and adjust scroll position
|
|
3831
|
+
if (nativeFiles.files.length > 0) {
|
|
3832
|
+
const firstPastedFile = nativeFiles.files[0];
|
|
3833
|
+
const targetPath = `${state.root}${state.pathSeparator}${getBaseName(state.pathSeparator, firstPastedFile)}`;
|
|
3834
|
+
const pastedFileIndex = getIndex(latestState.items, targetPath);
|
|
3835
|
+
if (pastedFileIndex !== -1) {
|
|
3836
|
+
return adjustScrollAfterPaste(latestState, pastedFileIndex);
|
|
3837
|
+
}
|
|
3838
|
+
}
|
|
3839
|
+
return latestState;
|
|
3788
3840
|
};
|
|
3789
3841
|
|
|
3790
3842
|
const handlePasteNone = async (state, nativeFiles) => {
|
|
@@ -3797,18 +3849,6 @@ const Copy = 'copy';
|
|
|
3797
3849
|
const Cut = 'cut';
|
|
3798
3850
|
|
|
3799
3851
|
const getPasteHandler = type => {
|
|
3800
|
-
// TODO detect cut/paste event, not sure if that is possible
|
|
3801
|
-
// TODO check that pasted folder is not a parent folder of opened folder
|
|
3802
|
-
// TODO support pasting multiple paths
|
|
3803
|
-
// TODO what happens when pasting multiple paths, but some of them error?
|
|
3804
|
-
// how many error messages should be shown? Should the operation be undone?
|
|
3805
|
-
// TODO what if it is a large folder and takes a long time to copy? Should show progress
|
|
3806
|
-
// TODO what if there is a permission error? Probably should show a modal to ask for permission
|
|
3807
|
-
// TODO if error is EEXISTS, just rename the copy (e.g. file-copy-1.txt, file-copy-2.txt)
|
|
3808
|
-
// TODO actual target should be selected folder
|
|
3809
|
-
// TODO but what if a file is currently selected? Then maybe the parent folder
|
|
3810
|
-
// TODO but will it work if the folder is a symlink?
|
|
3811
|
-
// TODO handle error gracefully when copy fails
|
|
3812
3852
|
switch (type) {
|
|
3813
3853
|
case None$3:
|
|
3814
3854
|
return handlePasteNone;
|
|
@@ -3823,6 +3863,9 @@ const getPasteHandler = type => {
|
|
|
3823
3863
|
|
|
3824
3864
|
const handlePaste = async state => {
|
|
3825
3865
|
const nativeFiles = await readNativeFiles();
|
|
3866
|
+
if (!nativeFiles) {
|
|
3867
|
+
return state;
|
|
3868
|
+
}
|
|
3826
3869
|
// TODO detect cut/paste event, not sure if that is possible
|
|
3827
3870
|
// TODO check that pasted folder is not a parent folder of opened folder
|
|
3828
3871
|
// TODO support pasting multiple paths
|
|
@@ -4312,7 +4355,11 @@ const removeDirent = async state => {
|
|
|
4312
4355
|
// TODO use file operations, bulk edit and explorer refresh
|
|
4313
4356
|
await removePaths(toRemove);
|
|
4314
4357
|
const newState = await refresh(state);
|
|
4315
|
-
return
|
|
4358
|
+
return {
|
|
4359
|
+
...newState,
|
|
4360
|
+
focused: true,
|
|
4361
|
+
focus: List
|
|
4362
|
+
};
|
|
4316
4363
|
};
|
|
4317
4364
|
|
|
4318
4365
|
const getEditingType = direntType => {
|
|
@@ -5132,28 +5179,6 @@ const mergeVisibleWithHiddenItems = (visibleItems, hiddenItems) => {
|
|
|
5132
5179
|
return unique;
|
|
5133
5180
|
};
|
|
5134
5181
|
|
|
5135
|
-
const scrollInto = (index, minLineY, maxLineY) => {
|
|
5136
|
-
const diff = maxLineY - minLineY;
|
|
5137
|
-
const smallerHalf = Math.floor(diff / 2);
|
|
5138
|
-
const largerHalf = diff - smallerHalf;
|
|
5139
|
-
if (index < minLineY) {
|
|
5140
|
-
return {
|
|
5141
|
-
newMinLineY: index - smallerHalf,
|
|
5142
|
-
newMaxLineY: index + largerHalf
|
|
5143
|
-
};
|
|
5144
|
-
}
|
|
5145
|
-
if (index >= maxLineY) {
|
|
5146
|
-
return {
|
|
5147
|
-
newMinLineY: index - smallerHalf,
|
|
5148
|
-
newMaxLineY: index + largerHalf
|
|
5149
|
-
};
|
|
5150
|
-
}
|
|
5151
|
-
return {
|
|
5152
|
-
newMinLineY: minLineY,
|
|
5153
|
-
newMaxLineY: maxLineY
|
|
5154
|
-
};
|
|
5155
|
-
};
|
|
5156
|
-
|
|
5157
5182
|
// TODO maybe just insert items into explorer and refresh whole explorer
|
|
5158
5183
|
const revealItemHidden = async (state, uri) => {
|
|
5159
5184
|
const {
|