@lvce-editor/text-search-worker 5.18.0 → 5.20.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/textSearchWorkerMain.js +232 -73
- package/package.json +1 -1
|
@@ -596,13 +596,13 @@ const create$4$1 = (method, params) => {
|
|
|
596
596
|
};
|
|
597
597
|
};
|
|
598
598
|
const callbacks = Object.create(null);
|
|
599
|
-
const set$
|
|
599
|
+
const set$5 = (id, fn) => {
|
|
600
600
|
callbacks[id] = fn;
|
|
601
601
|
};
|
|
602
602
|
const get$3 = id => {
|
|
603
603
|
return callbacks[id];
|
|
604
604
|
};
|
|
605
|
-
const remove$
|
|
605
|
+
const remove$2 = id => {
|
|
606
606
|
delete callbacks[id];
|
|
607
607
|
};
|
|
608
608
|
let id = 0;
|
|
@@ -615,7 +615,7 @@ const registerPromise = () => {
|
|
|
615
615
|
resolve,
|
|
616
616
|
promise
|
|
617
617
|
} = Promise.withResolvers();
|
|
618
|
-
set$
|
|
618
|
+
set$5(id, resolve);
|
|
619
619
|
return {
|
|
620
620
|
id,
|
|
621
621
|
promise
|
|
@@ -787,7 +787,7 @@ const resolve = (id, response) => {
|
|
|
787
787
|
return;
|
|
788
788
|
}
|
|
789
789
|
fn(response);
|
|
790
|
-
remove$
|
|
790
|
+
remove$2(id);
|
|
791
791
|
};
|
|
792
792
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
793
793
|
const getErrorType = prettyError => {
|
|
@@ -956,11 +956,11 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
956
956
|
const responseMessage = await promise;
|
|
957
957
|
return unwrapJsonRpcResult(responseMessage);
|
|
958
958
|
};
|
|
959
|
-
const send = (transport, method, ...params) => {
|
|
959
|
+
const send$1 = (transport, method, ...params) => {
|
|
960
960
|
const message = create$4$1(method, params);
|
|
961
961
|
transport.send(message);
|
|
962
962
|
};
|
|
963
|
-
const invoke$
|
|
963
|
+
const invoke$4 = (ipc, method, ...params) => {
|
|
964
964
|
return invokeHelper(ipc, method, params, false);
|
|
965
965
|
};
|
|
966
966
|
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
@@ -996,10 +996,10 @@ const createRpc = ipc => {
|
|
|
996
996
|
* @deprecated
|
|
997
997
|
*/
|
|
998
998
|
send(method, ...params) {
|
|
999
|
-
send(ipc, method, ...params);
|
|
999
|
+
send$1(ipc, method, ...params);
|
|
1000
1000
|
},
|
|
1001
1001
|
invoke(method, ...params) {
|
|
1002
|
-
return invoke$
|
|
1002
|
+
return invoke$4(ipc, method, ...params);
|
|
1003
1003
|
},
|
|
1004
1004
|
invokeAndTransfer(method, ...params) {
|
|
1005
1005
|
return invokeAndTransfer$1(ipc, method, ...params);
|
|
@@ -1328,6 +1328,8 @@ const DeltaY = 'event.deltaY';
|
|
|
1328
1328
|
const TargetName = 'event.target.name';
|
|
1329
1329
|
const TargetValue = 'event.target.value';
|
|
1330
1330
|
|
|
1331
|
+
const Script$1 = 2;
|
|
1332
|
+
|
|
1331
1333
|
const Search$1 = 18;
|
|
1332
1334
|
|
|
1333
1335
|
const None$1 = 0;
|
|
@@ -1338,8 +1340,11 @@ const Electron = 2;
|
|
|
1338
1340
|
const Remote = 3;
|
|
1339
1341
|
|
|
1340
1342
|
const DebugWorker = 55;
|
|
1341
|
-
const RendererWorker$
|
|
1343
|
+
const RendererWorker$2 = 1;
|
|
1342
1344
|
const SearchProcess = 77;
|
|
1345
|
+
const IconThemeWorker = 7009;
|
|
1346
|
+
|
|
1347
|
+
const Match$1 = 2;
|
|
1343
1348
|
|
|
1344
1349
|
const FocusElementByName = 'Viewlet.focusElementByName';
|
|
1345
1350
|
const SetDom2 = 'Viewlet.setDom2';
|
|
@@ -1661,7 +1666,7 @@ const collapseDetails = state => {
|
|
|
1661
1666
|
};
|
|
1662
1667
|
|
|
1663
1668
|
const rpcs = Object.create(null);
|
|
1664
|
-
const set$
|
|
1669
|
+
const set$4 = (id, rpc) => {
|
|
1665
1670
|
rpcs[id] = rpc;
|
|
1666
1671
|
};
|
|
1667
1672
|
const get$2 = id => {
|
|
@@ -1683,7 +1688,7 @@ const create$2 = rpcId => {
|
|
|
1683
1688
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1684
1689
|
},
|
|
1685
1690
|
set(rpc) {
|
|
1686
|
-
set$
|
|
1691
|
+
set$4(rpcId, rpc);
|
|
1687
1692
|
},
|
|
1688
1693
|
async dispose() {
|
|
1689
1694
|
const rpc = get$2(rpcId);
|
|
@@ -1692,12 +1697,20 @@ const create$2 = rpcId => {
|
|
|
1692
1697
|
};
|
|
1693
1698
|
};
|
|
1694
1699
|
|
|
1700
|
+
const {
|
|
1701
|
+
invoke: invoke$3,
|
|
1702
|
+
set: set$3} = create$2(IconThemeWorker);
|
|
1703
|
+
const getIcons$1 = async iconRequests => {
|
|
1704
|
+
// @ts-ignore
|
|
1705
|
+
return invoke$3('IconTheme.getIcons', iconRequests);
|
|
1706
|
+
};
|
|
1707
|
+
|
|
1695
1708
|
const {
|
|
1696
1709
|
invoke: invoke$2,
|
|
1697
1710
|
invokeAndTransfer,
|
|
1698
1711
|
set: set$2,
|
|
1699
1712
|
dispose
|
|
1700
|
-
} = create$2(RendererWorker$
|
|
1713
|
+
} = create$2(RendererWorker$2);
|
|
1701
1714
|
const searchFileHtml = async uri => {
|
|
1702
1715
|
return invoke$2('ExtensionHost.searchFileWithHtml', uri);
|
|
1703
1716
|
};
|
|
@@ -1707,6 +1720,10 @@ const getFilePathElectron = async file => {
|
|
|
1707
1720
|
const showContextMenu$1 = async (x, y, id, ...args) => {
|
|
1708
1721
|
return invoke$2('ContextMenu.show', x, y, id, ...args);
|
|
1709
1722
|
};
|
|
1723
|
+
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
1724
|
+
// @ts-ignore
|
|
1725
|
+
await RendererWorker.invoke('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1726
|
+
};
|
|
1710
1727
|
const getElectronVersion = async () => {
|
|
1711
1728
|
return invoke$2('Process.getElectronVersion');
|
|
1712
1729
|
};
|
|
@@ -1842,7 +1859,7 @@ const handleDebugResumed = async params => {
|
|
|
1842
1859
|
const openWidget = async name => {
|
|
1843
1860
|
await invoke$2('Viewlet.openWidget', name);
|
|
1844
1861
|
};
|
|
1845
|
-
const getIcons
|
|
1862
|
+
const getIcons = async requests => {
|
|
1846
1863
|
const icons = await invoke$2('IconTheme.getIcons', requests);
|
|
1847
1864
|
return icons;
|
|
1848
1865
|
};
|
|
@@ -1936,7 +1953,7 @@ const openExtensionSearch = async () => {
|
|
|
1936
1953
|
};
|
|
1937
1954
|
const setExtensionsSearchValue = async searchValue => {
|
|
1938
1955
|
// @ts-ignore
|
|
1939
|
-
return invoke$2('Extensions.handleInput', searchValue);
|
|
1956
|
+
return invoke$2('Extensions.handleInput', searchValue, Script$1);
|
|
1940
1957
|
};
|
|
1941
1958
|
const openExternal = async uri => {
|
|
1942
1959
|
// @ts-ignore
|
|
@@ -1966,7 +1983,7 @@ const registerMockRpc = commandMap => {
|
|
|
1966
1983
|
return mockRpc;
|
|
1967
1984
|
};
|
|
1968
1985
|
|
|
1969
|
-
const RendererWorker = {
|
|
1986
|
+
const RendererWorker$1 = {
|
|
1970
1987
|
__proto__: null,
|
|
1971
1988
|
activateByEvent,
|
|
1972
1989
|
applyBulkReplacement: applyBulkReplacement$1,
|
|
@@ -1989,7 +2006,7 @@ const RendererWorker = {
|
|
|
1989
2006
|
getFilePathElectron,
|
|
1990
2007
|
getFolderIcon,
|
|
1991
2008
|
getFolderSize,
|
|
1992
|
-
getIcons
|
|
2009
|
+
getIcons,
|
|
1993
2010
|
getKeyBindings: getKeyBindings$1,
|
|
1994
2011
|
getLogsDir,
|
|
1995
2012
|
getMarkdownDom,
|
|
@@ -2038,6 +2055,7 @@ const RendererWorker = {
|
|
|
2038
2055
|
setWebViewPort,
|
|
2039
2056
|
setWorkspacePath,
|
|
2040
2057
|
showContextMenu: showContextMenu$1,
|
|
2058
|
+
showContextMenu2,
|
|
2041
2059
|
showErrorDialog,
|
|
2042
2060
|
showMessageBox,
|
|
2043
2061
|
showSaveFilePicker,
|
|
@@ -2052,7 +2070,7 @@ const createLazyRpc = rpcId => {
|
|
|
2052
2070
|
let factory;
|
|
2053
2071
|
const createRpc = async () => {
|
|
2054
2072
|
const rpc = await factory();
|
|
2055
|
-
set$
|
|
2073
|
+
set$4(rpcId, rpc);
|
|
2056
2074
|
};
|
|
2057
2075
|
const ensureRpc = async () => {
|
|
2058
2076
|
if (!rpcPromise) {
|
|
@@ -2078,9 +2096,7 @@ const {
|
|
|
2078
2096
|
sendMessagePortToSearchProcess,
|
|
2079
2097
|
set: set$1,
|
|
2080
2098
|
showContextMenu,
|
|
2081
|
-
writeClipBoardText
|
|
2082
|
-
getIcons
|
|
2083
|
-
} = RendererWorker;
|
|
2099
|
+
writeClipBoardText} = RendererWorker$1;
|
|
2084
2100
|
|
|
2085
2101
|
const copy = async state => {
|
|
2086
2102
|
const {
|
|
@@ -2195,7 +2211,10 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2195
2211
|
useFileIcons: true,
|
|
2196
2212
|
limitHit: false,
|
|
2197
2213
|
limitHitWarning: '',
|
|
2198
|
-
limit: 20_000
|
|
2214
|
+
limit: 20_000,
|
|
2215
|
+
fileIconCache: {},
|
|
2216
|
+
removeButtonWidth: 20,
|
|
2217
|
+
removeButtonRight: 0
|
|
2199
2218
|
};
|
|
2200
2219
|
set(uid, state, state);
|
|
2201
2220
|
return state;
|
|
@@ -2268,7 +2287,7 @@ const diff2 = uid => {
|
|
|
2268
2287
|
|
|
2269
2288
|
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
2270
2289
|
|
|
2271
|
-
const remove = (array, index, deleteCount) => {
|
|
2290
|
+
const remove$1 = (array, index, deleteCount) => {
|
|
2272
2291
|
return array.toSpliced(index, deleteCount);
|
|
2273
2292
|
};
|
|
2274
2293
|
|
|
@@ -2301,6 +2320,7 @@ const Include = 'Include';
|
|
|
2301
2320
|
const ManyResultsInManyFiles = '{PH1} results in {PH2} files';
|
|
2302
2321
|
const ManyResultsInOneFile = '{PH1} results in 1 file';
|
|
2303
2322
|
const MatchCase$1 = 'Match Case';
|
|
2323
|
+
const Remove$1 = 'Remove';
|
|
2304
2324
|
const MatchWholeWord$1 = 'Match Whole Word';
|
|
2305
2325
|
const NoResults = 'No results found';
|
|
2306
2326
|
const Oneresult = '1 result in 1 file';
|
|
@@ -2334,6 +2354,9 @@ const toggleReplace$1 = () => {
|
|
|
2334
2354
|
const matchCase = () => {
|
|
2335
2355
|
return i18nString(MatchCase$1);
|
|
2336
2356
|
};
|
|
2357
|
+
const remove = () => {
|
|
2358
|
+
return i18nString(Remove$1);
|
|
2359
|
+
};
|
|
2337
2360
|
const preserveCase = () => {
|
|
2338
2361
|
return i18nString(PreserveCase$1);
|
|
2339
2362
|
};
|
|
@@ -2541,7 +2564,7 @@ const removeItemFromItems = (items, index, matchCount, fileCount) => {
|
|
|
2541
2564
|
newFileCount,
|
|
2542
2565
|
newMatchCount
|
|
2543
2566
|
} = getRemoveIndices(items, index, matchCount, fileCount);
|
|
2544
|
-
const newItems = remove(items, startIndex, removeCount);
|
|
2567
|
+
const newItems = remove$1(items, startIndex, removeCount);
|
|
2545
2568
|
return {
|
|
2546
2569
|
newItems,
|
|
2547
2570
|
newFocusedIndex,
|
|
@@ -2819,6 +2842,10 @@ const getSearchResultKeyBindings = () => {
|
|
|
2819
2842
|
key: CtrlCmd | KeyC,
|
|
2820
2843
|
command: 'Search.copy',
|
|
2821
2844
|
when: FocusSearchResults
|
|
2845
|
+
}, {
|
|
2846
|
+
key: Delete,
|
|
2847
|
+
command: 'Search.removeCurrent',
|
|
2848
|
+
when: FocusSearchResults
|
|
2822
2849
|
}];
|
|
2823
2850
|
};
|
|
2824
2851
|
|
|
@@ -2883,29 +2910,114 @@ const handleUpdateError = async (state, update, error) => {
|
|
|
2883
2910
|
};
|
|
2884
2911
|
};
|
|
2885
2912
|
|
|
2886
|
-
const
|
|
2913
|
+
const getFilePath = text => {
|
|
2914
|
+
// TODO make api stricter so that results always have the same shape
|
|
2887
2915
|
if (text.startsWith('./')) {
|
|
2888
2916
|
return text.slice(2);
|
|
2889
2917
|
}
|
|
2890
2918
|
return text;
|
|
2891
2919
|
};
|
|
2892
|
-
|
|
2893
|
-
|
|
2894
|
-
|
|
2895
|
-
if (
|
|
2896
|
-
|
|
2897
|
-
requests.push({
|
|
2898
|
-
type: File$1,
|
|
2899
|
-
name: fileName,
|
|
2900
|
-
path: `/${fileName}`
|
|
2901
|
-
});
|
|
2920
|
+
|
|
2921
|
+
const getIconsCached = (dirents, fileIconCache) => {
|
|
2922
|
+
return dirents.map(dirent => {
|
|
2923
|
+
if (dirent.type === Match$1) {
|
|
2924
|
+
return '';
|
|
2902
2925
|
}
|
|
2926
|
+
const path = getFilePath(dirent.text);
|
|
2927
|
+
return fileIconCache[path];
|
|
2928
|
+
});
|
|
2929
|
+
};
|
|
2930
|
+
|
|
2931
|
+
const getFileName = path => {
|
|
2932
|
+
const slashIndex = path.lastIndexOf('/');
|
|
2933
|
+
if (slashIndex === -1) {
|
|
2934
|
+
return '';
|
|
2903
2935
|
}
|
|
2904
|
-
|
|
2905
|
-
|
|
2936
|
+
return path.slice(slashIndex + 1);
|
|
2937
|
+
};
|
|
2938
|
+
|
|
2939
|
+
const isFile = match => {
|
|
2940
|
+
return match.type === File;
|
|
2941
|
+
};
|
|
2942
|
+
|
|
2943
|
+
const getMissingDirents = (searchResults, fileIconCache) => {
|
|
2944
|
+
const missingDirents = [];
|
|
2945
|
+
const files = searchResults.filter(isFile);
|
|
2946
|
+
for (const file of files) {
|
|
2947
|
+
const uri = getFilePath(file.text);
|
|
2948
|
+
if (!(uri in fileIconCache)) {
|
|
2949
|
+
missingDirents.push(file);
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2952
|
+
return missingDirents;
|
|
2953
|
+
};
|
|
2954
|
+
const toIconRequest = item => {
|
|
2955
|
+
const filePath = getFilePath(item.text);
|
|
2956
|
+
const fileName = getFileName(filePath);
|
|
2957
|
+
return {
|
|
2958
|
+
type: File$1,
|
|
2959
|
+
name: fileName,
|
|
2960
|
+
path: filePath
|
|
2961
|
+
};
|
|
2962
|
+
};
|
|
2963
|
+
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
2964
|
+
const missingRequests = getMissingDirents(dirents, fileIconCache);
|
|
2965
|
+
const iconRequests = missingRequests.map(toIconRequest);
|
|
2966
|
+
return iconRequests;
|
|
2967
|
+
};
|
|
2968
|
+
|
|
2969
|
+
const Directory = 3;
|
|
2970
|
+
const DirectoryExpanded = 4;
|
|
2971
|
+
|
|
2972
|
+
const getSimpleIconRequestType = direntType => {
|
|
2973
|
+
if (direntType === Directory || direntType === DirectoryExpanded) {
|
|
2974
|
+
return 2;
|
|
2975
|
+
}
|
|
2976
|
+
return 1;
|
|
2977
|
+
};
|
|
2978
|
+
|
|
2979
|
+
const toSimpleIconRequest = request => {
|
|
2980
|
+
return {
|
|
2981
|
+
name: request.name,
|
|
2982
|
+
type: getSimpleIconRequestType(request.type)
|
|
2983
|
+
};
|
|
2984
|
+
};
|
|
2985
|
+
|
|
2986
|
+
const requestFileIcons = async requests => {
|
|
2987
|
+
if (requests.length === 0) {
|
|
2988
|
+
return [];
|
|
2989
|
+
}
|
|
2990
|
+
const simpleRequests = requests.map(toSimpleIconRequest);
|
|
2991
|
+
const icons = await getIcons$1(simpleRequests);
|
|
2906
2992
|
return icons;
|
|
2907
2993
|
};
|
|
2908
2994
|
|
|
2995
|
+
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
2996
|
+
if (missingRequests.length === 0) {
|
|
2997
|
+
return iconCache;
|
|
2998
|
+
}
|
|
2999
|
+
const newFileIconCache = {
|
|
3000
|
+
...iconCache
|
|
3001
|
+
};
|
|
3002
|
+
for (let i = 0; i < missingRequests.length; i++) {
|
|
3003
|
+
const request = missingRequests[i];
|
|
3004
|
+
const icon = newIcons[i];
|
|
3005
|
+
newFileIconCache[request.path] = icon;
|
|
3006
|
+
}
|
|
3007
|
+
return newFileIconCache;
|
|
3008
|
+
};
|
|
3009
|
+
|
|
3010
|
+
const getFileIcons = async (items, fileIconCache) => {
|
|
3011
|
+
const missingRequests = getMissingIconRequests(items, fileIconCache);
|
|
3012
|
+
const newIcons = await requestFileIcons(missingRequests);
|
|
3013
|
+
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
3014
|
+
const icons = getIconsCached(items, newFileIconCache);
|
|
3015
|
+
return {
|
|
3016
|
+
icons,
|
|
3017
|
+
newFileIconCache
|
|
3018
|
+
};
|
|
3019
|
+
};
|
|
3020
|
+
|
|
2909
3021
|
// TODO optimize this function to return the minimum number
|
|
2910
3022
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
2911
3023
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
@@ -2991,7 +3103,8 @@ const handleUpdateFull = async (state, update) => {
|
|
|
2991
3103
|
excludeValue,
|
|
2992
3104
|
assetDir,
|
|
2993
3105
|
platform,
|
|
2994
|
-
limit
|
|
3106
|
+
limit,
|
|
3107
|
+
fileIconCache
|
|
2995
3108
|
} = partialNewState;
|
|
2996
3109
|
const root = state.workspacePath;
|
|
2997
3110
|
const scheme = getProtocol(root);
|
|
@@ -3028,7 +3141,10 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3028
3141
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
3029
3142
|
const finalDeltaY = Math.max(contentHeight - listHeight, 0);
|
|
3030
3143
|
const visible = results.slice(0, maxLineY);
|
|
3031
|
-
const
|
|
3144
|
+
const {
|
|
3145
|
+
icons,
|
|
3146
|
+
newFileIconCache
|
|
3147
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
3032
3148
|
|
|
3033
3149
|
// TODO add info message if limit was hit
|
|
3034
3150
|
|
|
@@ -3037,6 +3153,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3037
3153
|
...partialNewState,
|
|
3038
3154
|
deltaY: 0,
|
|
3039
3155
|
fileCount,
|
|
3156
|
+
fileIconCache: newFileIconCache,
|
|
3040
3157
|
finalDeltaY,
|
|
3041
3158
|
icons,
|
|
3042
3159
|
items: results,
|
|
@@ -3270,6 +3387,7 @@ const ToggleReplace = 'ToggleReplace';
|
|
|
3270
3387
|
const ToggleSearchDetails = 'ToggleSearchDetails';
|
|
3271
3388
|
const UseExcludeSettings = 'UseExcludeSettings';
|
|
3272
3389
|
const UseRegularExpression = 'UseRegularExpression';
|
|
3390
|
+
const Remove = 'Remove';
|
|
3273
3391
|
|
|
3274
3392
|
const noop = state => {
|
|
3275
3393
|
return state;
|
|
@@ -3289,14 +3407,6 @@ const getReplacedMessage = (fileCount, replaceCount, replacement) => {
|
|
|
3289
3407
|
return replacedManyOccurrencesInManyFiles(replaceCount, fileCount, replacement);
|
|
3290
3408
|
};
|
|
3291
3409
|
|
|
3292
|
-
const getFileName = text => {
|
|
3293
|
-
// TODO make api stricter so that results always have the same shape
|
|
3294
|
-
if (text.startsWith('./')) {
|
|
3295
|
-
return text.slice(2);
|
|
3296
|
-
}
|
|
3297
|
-
return text;
|
|
3298
|
-
};
|
|
3299
|
-
|
|
3300
3410
|
const getReplaceElements = (items, workspacePath, replacement) => {
|
|
3301
3411
|
let element = {
|
|
3302
3412
|
uri: '',
|
|
@@ -3315,7 +3425,7 @@ const getReplaceElements = (items, workspacePath, replacement) => {
|
|
|
3315
3425
|
} = match;
|
|
3316
3426
|
if (type === File) {
|
|
3317
3427
|
changes = [];
|
|
3318
|
-
const fileName =
|
|
3428
|
+
const fileName = getFilePath(text);
|
|
3319
3429
|
const absolutePath = `${workspacePath}/${fileName}`;
|
|
3320
3430
|
element = {
|
|
3321
3431
|
uri: absolutePath,
|
|
@@ -3481,10 +3591,14 @@ const handleIconThemeChange = async state => {
|
|
|
3481
3591
|
maxLineY
|
|
3482
3592
|
} = state;
|
|
3483
3593
|
const visibleItems = items.slice(minLineY, maxLineY);
|
|
3484
|
-
const
|
|
3594
|
+
const {
|
|
3595
|
+
icons,
|
|
3596
|
+
newFileIconCache
|
|
3597
|
+
} = await getFileIcons(visibleItems, {});
|
|
3485
3598
|
return {
|
|
3486
3599
|
...state,
|
|
3487
|
-
icons
|
|
3600
|
+
icons,
|
|
3601
|
+
fileIconCache: newFileIconCache
|
|
3488
3602
|
};
|
|
3489
3603
|
};
|
|
3490
3604
|
|
|
@@ -3601,6 +3715,23 @@ const handleSharedInput = (state, name, value, inputSource = Script) => {
|
|
|
3601
3715
|
return fn(state, value, inputSource);
|
|
3602
3716
|
};
|
|
3603
3717
|
|
|
3718
|
+
const send = async port => {
|
|
3719
|
+
await sendMessagePortToIconThemeWorker(port, 0);
|
|
3720
|
+
};
|
|
3721
|
+
const launchIconThemeWorker = async () => {
|
|
3722
|
+
// TODO connect to icon theme worker
|
|
3723
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
3724
|
+
commandMap: {},
|
|
3725
|
+
send
|
|
3726
|
+
});
|
|
3727
|
+
return rpc;
|
|
3728
|
+
};
|
|
3729
|
+
|
|
3730
|
+
const initializeIconThemeWorker = async () => {
|
|
3731
|
+
const rpc = await launchIconThemeWorker();
|
|
3732
|
+
set$3(rpc);
|
|
3733
|
+
};
|
|
3734
|
+
|
|
3604
3735
|
const launchSearchProcessElectron = async () => {
|
|
3605
3736
|
const rpc = await TransferMessagePortRpcParent.create({
|
|
3606
3737
|
commandMap: {},
|
|
@@ -3627,8 +3758,7 @@ const setSearchProcessFactory = platform => {
|
|
|
3627
3758
|
};
|
|
3628
3759
|
const initialize = async platform => {
|
|
3629
3760
|
setSearchProcessFactory(platform);
|
|
3630
|
-
|
|
3631
|
-
// TODO connect to icon theme worker
|
|
3761
|
+
await initializeIconThemeWorker();
|
|
3632
3762
|
};
|
|
3633
3763
|
|
|
3634
3764
|
// TODO optimize this function to return the minimum number
|
|
@@ -3975,18 +4105,22 @@ const toggleCollapsedPath = (collapsedPaths, path) => {
|
|
|
3975
4105
|
return [...collapsedPaths, path];
|
|
3976
4106
|
};
|
|
3977
4107
|
|
|
3978
|
-
const selectIndexFile = async (state, searchResult, index) => {
|
|
4108
|
+
const selectIndexFile = async (state, searchResult, index, isRemove) => {
|
|
3979
4109
|
const {
|
|
3980
4110
|
collapsedPaths,
|
|
3981
4111
|
items,
|
|
3982
4112
|
itemHeight,
|
|
3983
4113
|
headerHeight,
|
|
3984
|
-
height
|
|
4114
|
+
height,
|
|
4115
|
+
fileIconCache
|
|
3985
4116
|
} = state;
|
|
3986
4117
|
const path = searchResult.text;
|
|
3987
4118
|
const newCollapsedPaths = toggleCollapsedPath(collapsedPaths, path);
|
|
3988
4119
|
const filteredResults = getFilteredResults(items, newCollapsedPaths);
|
|
3989
|
-
const
|
|
4120
|
+
const {
|
|
4121
|
+
icons,
|
|
4122
|
+
newFileIconCache
|
|
4123
|
+
} = await getFileIcons(filteredResults, fileIconCache);
|
|
3990
4124
|
const total = filteredResults.length;
|
|
3991
4125
|
const listHeight = height - headerHeight;
|
|
3992
4126
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
@@ -3994,13 +4128,14 @@ const selectIndexFile = async (state, searchResult, index) => {
|
|
|
3994
4128
|
return {
|
|
3995
4129
|
...state,
|
|
3996
4130
|
collapsedPaths: newCollapsedPaths,
|
|
3997
|
-
|
|
4131
|
+
fileIconCache: newFileIconCache,
|
|
4132
|
+
focus: FocusSearchResults,
|
|
4133
|
+
focusSource: Script,
|
|
4134
|
+
icons,
|
|
3998
4135
|
listFocused: true,
|
|
4136
|
+
listFocusedIndex: index,
|
|
3999
4137
|
listItems: filteredResults,
|
|
4000
|
-
maxLineY
|
|
4001
|
-
icons,
|
|
4002
|
-
focus: FocusSearchResults,
|
|
4003
|
-
focusSource: Script
|
|
4138
|
+
maxLineY
|
|
4004
4139
|
};
|
|
4005
4140
|
};
|
|
4006
4141
|
|
|
@@ -4029,7 +4164,7 @@ const getRelativePath = relativePath => {
|
|
|
4029
4164
|
return `/${relativePath}`; // TODO support windows paths
|
|
4030
4165
|
};
|
|
4031
4166
|
|
|
4032
|
-
const selectIndexPreview = async (state, searchResult, index) => {
|
|
4167
|
+
const selectIndexPreview = async (state, searchResult, index, isRemove) => {
|
|
4033
4168
|
const {
|
|
4034
4169
|
items,
|
|
4035
4170
|
workspacePath
|
|
@@ -4067,7 +4202,7 @@ const getSelectHandler = type => {
|
|
|
4067
4202
|
}
|
|
4068
4203
|
};
|
|
4069
4204
|
|
|
4070
|
-
const selectIndex = async (state, index) => {
|
|
4205
|
+
const selectIndex = async (state, index, isRemoveButton = false) => {
|
|
4071
4206
|
if (index === -1) {
|
|
4072
4207
|
return {
|
|
4073
4208
|
...state,
|
|
@@ -4080,10 +4215,10 @@ const selectIndex = async (state, index) => {
|
|
|
4080
4215
|
} = state;
|
|
4081
4216
|
const searchResult = listItems[index];
|
|
4082
4217
|
const fn = getSelectHandler(searchResult.type);
|
|
4083
|
-
return fn(state, searchResult, index);
|
|
4218
|
+
return fn(state, searchResult, index, isRemoveButton);
|
|
4084
4219
|
};
|
|
4085
4220
|
|
|
4086
|
-
const handleClickAt = async (state, eventX, eventY) => {
|
|
4221
|
+
const handleClickAt = async (state, eventX, eventY, name) => {
|
|
4087
4222
|
const {
|
|
4088
4223
|
x,
|
|
4089
4224
|
y,
|
|
@@ -4094,7 +4229,8 @@ const handleClickAt = async (state, eventX, eventY) => {
|
|
|
4094
4229
|
} = state;
|
|
4095
4230
|
const topHeight = getTopHeight(flags);
|
|
4096
4231
|
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
|
|
4097
|
-
|
|
4232
|
+
const isRemoveButton = name === Remove;
|
|
4233
|
+
return selectIndex(state, index, isRemoveButton);
|
|
4098
4234
|
};
|
|
4099
4235
|
|
|
4100
4236
|
const handleListPointerDown = async (state, button) => {
|
|
@@ -4263,6 +4399,24 @@ const refresh = state => {
|
|
|
4263
4399
|
return handleUpdate(state, {});
|
|
4264
4400
|
};
|
|
4265
4401
|
|
|
4402
|
+
const removeCurrent = async state => {
|
|
4403
|
+
// TODO
|
|
4404
|
+
// 1. get focused index
|
|
4405
|
+
// 2. if it is -1, do nothing
|
|
4406
|
+
// 3. get search result at focused index
|
|
4407
|
+
// 4. call removeIndex with state, searchResult, index
|
|
4408
|
+
return {
|
|
4409
|
+
...state
|
|
4410
|
+
};
|
|
4411
|
+
};
|
|
4412
|
+
|
|
4413
|
+
const removeIndex = async (state, searchResult, index) => {
|
|
4414
|
+
// TODO
|
|
4415
|
+
return {
|
|
4416
|
+
...state
|
|
4417
|
+
};
|
|
4418
|
+
};
|
|
4419
|
+
|
|
4266
4420
|
const getFocusSelector = focusKey => {
|
|
4267
4421
|
switch (focusKey) {
|
|
4268
4422
|
case FocusSearchInput:
|
|
@@ -4970,17 +5124,20 @@ const getChildCount = (icon, expanded, badgeText) => {
|
|
|
4970
5124
|
return childCount;
|
|
4971
5125
|
};
|
|
4972
5126
|
|
|
5127
|
+
const closeIcon = {
|
|
5128
|
+
type: Div,
|
|
5129
|
+
className: CloseMaskIcon,
|
|
5130
|
+
childCount: 0
|
|
5131
|
+
};
|
|
4973
5132
|
const getSearchRemoveVirtualDom = () => {
|
|
4974
|
-
|
|
5133
|
+
const title = remove();
|
|
4975
5134
|
const dom = [{
|
|
4976
|
-
type:
|
|
5135
|
+
type: Button$2,
|
|
4977
5136
|
className: SearchRemove,
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
4982
|
-
childCount: 0
|
|
4983
|
-
}];
|
|
5137
|
+
name: Remove,
|
|
5138
|
+
childCount: 1,
|
|
5139
|
+
title
|
|
5140
|
+
}, closeIcon];
|
|
4984
5141
|
return dom;
|
|
4985
5142
|
};
|
|
4986
5143
|
|
|
@@ -5227,7 +5384,7 @@ const renderEventListeners = () => {
|
|
|
5227
5384
|
params: ['handleReplaceInput', TargetValue]
|
|
5228
5385
|
}, {
|
|
5229
5386
|
name: HandleClick,
|
|
5230
|
-
params: ['handleClickAt', ClientX, ClientY]
|
|
5387
|
+
params: ['handleClickAt', ClientX, ClientY, TargetName]
|
|
5231
5388
|
}, {
|
|
5232
5389
|
name: HandleListPointerDown,
|
|
5233
5390
|
params: ['handleListPointerDown', Button$1]
|
|
@@ -5498,6 +5655,7 @@ const commandMap = {
|
|
|
5498
5655
|
'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
|
|
5499
5656
|
'TextSearch.collapseAll': wrapCommand(collapseAll$1),
|
|
5500
5657
|
'TextSearch.collapseDetails': wrapCommand(collapseDetails),
|
|
5658
|
+
'TextSearch.removeCurrent': wrapCommand(removeCurrent),
|
|
5501
5659
|
'TextSearch.copy': wrapCommand(copy),
|
|
5502
5660
|
'TextSearch.copyPath': wrapCommand(copyPath$1),
|
|
5503
5661
|
'TextSearch.diff2': diff2,
|
|
@@ -5552,6 +5710,7 @@ const commandMap = {
|
|
|
5552
5710
|
'TextSearch.nextHistoryResult': wrapCommand(nextHistoryResult),
|
|
5553
5711
|
'TextSearch.previousHistoryResult': wrapCommand(previousHistoryResult),
|
|
5554
5712
|
'TextSearch.refresh': wrapCommand(refresh),
|
|
5713
|
+
'TextSearch.removeIndex': wrapCommand(removeIndex),
|
|
5555
5714
|
'TextSearch.replaceAll': wrapCommand(replaceAll),
|
|
5556
5715
|
'TextSearch.rerender': rerender,
|
|
5557
5716
|
'TextSearch.selectIndex': wrapCommand(selectIndex),
|