@lvce-editor/file-search-worker 3.5.0 → 3.6.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/fileSearchWorkerMain.js +544 -68
- package/package.json +1 -1
|
@@ -82,6 +82,18 @@ const getType = value => {
|
|
|
82
82
|
return 'unknown';
|
|
83
83
|
}
|
|
84
84
|
};
|
|
85
|
+
const object = value => {
|
|
86
|
+
const type = getType(value);
|
|
87
|
+
if (type !== 'object') {
|
|
88
|
+
throw new AssertionError('expected value to be of type object');
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
const number = value => {
|
|
92
|
+
const type = getType(value);
|
|
93
|
+
if (type !== 'number') {
|
|
94
|
+
throw new AssertionError('expected value to be of type number');
|
|
95
|
+
}
|
|
96
|
+
};
|
|
85
97
|
const array = value => {
|
|
86
98
|
const type = getType(value);
|
|
87
99
|
if (type !== 'array') {
|
|
@@ -416,7 +428,7 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
416
428
|
};
|
|
417
429
|
|
|
418
430
|
const Two = '2.0';
|
|
419
|
-
const create$4 = (method, params) => {
|
|
431
|
+
const create$4$1 = (method, params) => {
|
|
420
432
|
return {
|
|
421
433
|
jsonrpc: Two,
|
|
422
434
|
method,
|
|
@@ -751,7 +763,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
751
763
|
return unwrapJsonRpcResult(responseMessage);
|
|
752
764
|
};
|
|
753
765
|
const send = (transport, method, ...params) => {
|
|
754
|
-
const message = create$4(method, params);
|
|
766
|
+
const message = create$4$1(method, params);
|
|
755
767
|
transport.send(message);
|
|
756
768
|
};
|
|
757
769
|
const invoke$2 = (ipc, method, ...params) => {
|
|
@@ -825,7 +837,7 @@ const listen$1 = async (module, options) => {
|
|
|
825
837
|
const ipc = module.wrap(rawIpc);
|
|
826
838
|
return ipc;
|
|
827
839
|
};
|
|
828
|
-
const create$
|
|
840
|
+
const create$4 = async ({
|
|
829
841
|
commandMap
|
|
830
842
|
}) => {
|
|
831
843
|
// TODO create a commandMap per rpc instance
|
|
@@ -837,7 +849,7 @@ const create$3 = async ({
|
|
|
837
849
|
};
|
|
838
850
|
const WebWorkerRpcClient = {
|
|
839
851
|
__proto__: null,
|
|
840
|
-
create: create$
|
|
852
|
+
create: create$4
|
|
841
853
|
};
|
|
842
854
|
|
|
843
855
|
const User = 1;
|
|
@@ -875,63 +887,58 @@ const i18nString = (key, placeholders = emptyObject) => {
|
|
|
875
887
|
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
876
888
|
};
|
|
877
889
|
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
const
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
SelectToOpen: 'Select to open',
|
|
893
|
-
ShowAndRunCommands: 'Show And Run Commands',
|
|
894
|
-
TypeNameOfCommandToRun: 'Type the name of a command to run.',
|
|
895
|
-
TypeTheNameOfAViewToOpen: 'Type the name of a view, output channel or terminal to open.'
|
|
896
|
-
};
|
|
890
|
+
const Files = 'Files';
|
|
891
|
+
const GoToFile = 'Go to file';
|
|
892
|
+
const NoMatchingColorThemesFound = 'No matching color themes found';
|
|
893
|
+
const NoMatchingResults = 'No matching results';
|
|
894
|
+
const NoRecentlyOpenedFoldersFound = 'No recently opened folders found';
|
|
895
|
+
const NoResults = 'No Results';
|
|
896
|
+
const NoSymbolFound = 'No symbol found';
|
|
897
|
+
const NoWorkspaceSymbolsFound = 'no workspace symbols found';
|
|
898
|
+
const OpenRecent = 'Open Recent';
|
|
899
|
+
const SelectColorTheme = 'Select Color Theme';
|
|
900
|
+
const SelectToOpen = 'Select to open';
|
|
901
|
+
const ShowAndRunCommands = 'Show And Run Commands';
|
|
902
|
+
const TypeNameOfCommandToRun = 'Type the name of a command to run.';
|
|
903
|
+
|
|
897
904
|
const noMatchingColorThemesFound = () => {
|
|
898
|
-
return i18nString(
|
|
905
|
+
return i18nString(NoMatchingColorThemesFound);
|
|
899
906
|
};
|
|
900
907
|
const selectColorTheme = () => {
|
|
901
|
-
return i18nString(
|
|
908
|
+
return i18nString(SelectColorTheme);
|
|
902
909
|
};
|
|
903
910
|
const typeNameofCommandToRun = () => {
|
|
904
|
-
return i18nString(
|
|
911
|
+
return i18nString(TypeNameOfCommandToRun);
|
|
905
912
|
};
|
|
906
913
|
const showAndRunCommands = () => {
|
|
907
|
-
return i18nString(
|
|
914
|
+
return i18nString(ShowAndRunCommands);
|
|
908
915
|
};
|
|
909
916
|
const noMatchingResults = () => {
|
|
910
|
-
return i18nString(
|
|
917
|
+
return i18nString(NoMatchingResults);
|
|
911
918
|
};
|
|
912
919
|
const files = () => {
|
|
913
|
-
return i18nString(
|
|
920
|
+
return i18nString(Files);
|
|
914
921
|
};
|
|
915
922
|
const goToFile = () => {
|
|
916
|
-
return i18nString(
|
|
923
|
+
return i18nString(GoToFile);
|
|
917
924
|
};
|
|
918
925
|
const noResults = () => {
|
|
919
|
-
return i18nString(
|
|
926
|
+
return i18nString(NoResults);
|
|
920
927
|
};
|
|
921
928
|
const selectToOpen = () => {
|
|
922
|
-
return i18nString(
|
|
929
|
+
return i18nString(SelectToOpen);
|
|
923
930
|
};
|
|
924
931
|
const openRecent = () => {
|
|
925
|
-
return i18nString(
|
|
932
|
+
return i18nString(OpenRecent);
|
|
926
933
|
};
|
|
927
934
|
const noRecentlyOpenedFoldersFound = () => {
|
|
928
|
-
return i18nString(
|
|
935
|
+
return i18nString(NoRecentlyOpenedFoldersFound);
|
|
929
936
|
};
|
|
930
937
|
const noSymbolFound = () => {
|
|
931
|
-
return i18nString(
|
|
938
|
+
return i18nString(NoSymbolFound);
|
|
932
939
|
};
|
|
933
940
|
const noWorkspaceSymbolsFound = () => {
|
|
934
|
-
return i18nString(
|
|
941
|
+
return i18nString(NoWorkspaceSymbolsFound);
|
|
935
942
|
};
|
|
936
943
|
|
|
937
944
|
const state$4 = {
|
|
@@ -1616,11 +1623,7 @@ replaceTraps(oldTraps => ({
|
|
|
1616
1623
|
}));
|
|
1617
1624
|
|
|
1618
1625
|
const state$2 = {
|
|
1619
|
-
|
|
1620
|
-
eventId: 0,
|
|
1621
|
-
dbVersion: 1,
|
|
1622
|
-
cachedDb: undefined
|
|
1623
|
-
};
|
|
1626
|
+
dbVersion: 1};
|
|
1624
1627
|
|
|
1625
1628
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
1626
1629
|
|
|
@@ -2016,7 +2019,7 @@ const getPickLabel$4 = pick => {
|
|
|
2016
2019
|
const baseName = pathBaseName(pick);
|
|
2017
2020
|
return baseName;
|
|
2018
2021
|
};
|
|
2019
|
-
const getPickDescription$
|
|
2022
|
+
const getPickDescription$4 = pick => {
|
|
2020
2023
|
if (typeof pick === 'object') {
|
|
2021
2024
|
pick = pick.pick;
|
|
2022
2025
|
}
|
|
@@ -2042,7 +2045,7 @@ const QuickPickEntriesFile = {
|
|
|
2042
2045
|
getHelpEntries: getHelpEntries$9,
|
|
2043
2046
|
getLabel: getLabel$4,
|
|
2044
2047
|
getNoResults: getNoResults$9,
|
|
2045
|
-
getPickDescription: getPickDescription$
|
|
2048
|
+
getPickDescription: getPickDescription$4,
|
|
2046
2049
|
getPickFileIcon: getPickFileIcon$2,
|
|
2047
2050
|
getPickFilterValue: getPickFilterValue$5,
|
|
2048
2051
|
getPickIcon: getPickIcon$4,
|
|
@@ -2254,7 +2257,7 @@ const Symbol$2 = '@';
|
|
|
2254
2257
|
const WorkspaceSymbol$1 = '#';
|
|
2255
2258
|
const GoToLine = ':';
|
|
2256
2259
|
const View$1 = 'view ';
|
|
2257
|
-
const None$
|
|
2260
|
+
const None$2 = '';
|
|
2258
2261
|
|
|
2259
2262
|
// TODO avoid global variable
|
|
2260
2263
|
|
|
@@ -2296,7 +2299,7 @@ const getPrefix = value => {
|
|
|
2296
2299
|
if (value.startsWith(View$1)) {
|
|
2297
2300
|
return View$1;
|
|
2298
2301
|
}
|
|
2299
|
-
return None$
|
|
2302
|
+
return None$2;
|
|
2300
2303
|
};
|
|
2301
2304
|
const getQuickPickProvider = prefix => {
|
|
2302
2305
|
// TODO could use enum for prefix
|
|
@@ -2351,7 +2354,7 @@ const getPickFilterValue$3 = pick => {
|
|
|
2351
2354
|
} = state$1;
|
|
2352
2355
|
return provider.getPickFilterValue(pick);
|
|
2353
2356
|
};
|
|
2354
|
-
const getPickDescription$
|
|
2357
|
+
const getPickDescription$3 = pick => {
|
|
2355
2358
|
const {
|
|
2356
2359
|
provider
|
|
2357
2360
|
} = state$1;
|
|
@@ -2405,7 +2408,7 @@ const QuickPickEntriesEverything = {
|
|
|
2405
2408
|
getHelpEntries: getHelpEntries$3,
|
|
2406
2409
|
getLabel: getLabel$3,
|
|
2407
2410
|
getNoResults: getNoResults$4,
|
|
2408
|
-
getPickDescription: getPickDescription$
|
|
2411
|
+
getPickDescription: getPickDescription$3,
|
|
2409
2412
|
getPickFileIcon: getPickFileIcon$1,
|
|
2410
2413
|
getPickFilterValue: getPickFilterValue$3,
|
|
2411
2414
|
getPickIcon: getPickIcon$3,
|
|
@@ -2423,7 +2426,7 @@ const QuickPickEntriesEverything = {
|
|
|
2423
2426
|
const Default = 0;
|
|
2424
2427
|
const Finished = 2;
|
|
2425
2428
|
|
|
2426
|
-
const create$
|
|
2429
|
+
const create$3 = () => {
|
|
2427
2430
|
const states = Object.create(null);
|
|
2428
2431
|
return {
|
|
2429
2432
|
get(uid) {
|
|
@@ -2441,9 +2444,9 @@ const create$2 = () => {
|
|
|
2441
2444
|
const {
|
|
2442
2445
|
get,
|
|
2443
2446
|
set
|
|
2444
|
-
} = create$
|
|
2447
|
+
} = create$3();
|
|
2445
2448
|
|
|
2446
|
-
const create$
|
|
2449
|
+
const create$2 = ({
|
|
2447
2450
|
itemHeight,
|
|
2448
2451
|
headerHeight = 0,
|
|
2449
2452
|
minimumSliderSize = 20
|
|
@@ -2465,6 +2468,82 @@ const create$1 = ({
|
|
|
2465
2468
|
scrollBarActive: false
|
|
2466
2469
|
};
|
|
2467
2470
|
};
|
|
2471
|
+
const getListHeight = (height, headerHeight) => {
|
|
2472
|
+
if (headerHeight) {
|
|
2473
|
+
return height - headerHeight;
|
|
2474
|
+
}
|
|
2475
|
+
return headerHeight;
|
|
2476
|
+
};
|
|
2477
|
+
const setDeltaY = (state, deltaY) => {
|
|
2478
|
+
object(state);
|
|
2479
|
+
number(deltaY);
|
|
2480
|
+
const {
|
|
2481
|
+
itemHeight,
|
|
2482
|
+
items,
|
|
2483
|
+
height,
|
|
2484
|
+
headerHeight
|
|
2485
|
+
} = state;
|
|
2486
|
+
const listHeight = getListHeight(height, headerHeight);
|
|
2487
|
+
const itemsLength = items.length;
|
|
2488
|
+
const finalDeltaY = itemsLength * itemHeight - listHeight;
|
|
2489
|
+
if (deltaY < 0) {
|
|
2490
|
+
deltaY = 0;
|
|
2491
|
+
} else if (deltaY > finalDeltaY) {
|
|
2492
|
+
deltaY = Math.max(finalDeltaY, 0);
|
|
2493
|
+
}
|
|
2494
|
+
if (state.deltaY === deltaY) {
|
|
2495
|
+
return state;
|
|
2496
|
+
}
|
|
2497
|
+
const minLineY = Math.round(deltaY / itemHeight);
|
|
2498
|
+
const maxLineY = minLineY + Math.round(listHeight / itemHeight);
|
|
2499
|
+
number(minLineY);
|
|
2500
|
+
number(maxLineY);
|
|
2501
|
+
return {
|
|
2502
|
+
...state,
|
|
2503
|
+
deltaY,
|
|
2504
|
+
minLineY,
|
|
2505
|
+
maxLineY
|
|
2506
|
+
};
|
|
2507
|
+
};
|
|
2508
|
+
const handleWheel = (state, deltaMode, deltaY) => {
|
|
2509
|
+
object(state);
|
|
2510
|
+
number(deltaMode);
|
|
2511
|
+
number(deltaY);
|
|
2512
|
+
return setDeltaY(state, state.deltaY + deltaY);
|
|
2513
|
+
};
|
|
2514
|
+
|
|
2515
|
+
const create$1 = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
|
|
2516
|
+
const state = {
|
|
2517
|
+
uid,
|
|
2518
|
+
state: Default,
|
|
2519
|
+
picks: [],
|
|
2520
|
+
recentPicks: [],
|
|
2521
|
+
recentPickIds: new Map(),
|
|
2522
|
+
// TODO use object.create(null) instead
|
|
2523
|
+
versionId: 0,
|
|
2524
|
+
provider: QuickPickEntriesEverything,
|
|
2525
|
+
// TODO make this dynamic again
|
|
2526
|
+
warned: [],
|
|
2527
|
+
visiblePicks: [],
|
|
2528
|
+
maxVisibleItems: 10,
|
|
2529
|
+
uri,
|
|
2530
|
+
cursorOffset: 0,
|
|
2531
|
+
height: 300,
|
|
2532
|
+
top: 50,
|
|
2533
|
+
width: 600,
|
|
2534
|
+
...create$2({
|
|
2535
|
+
itemHeight: listItemHeight,
|
|
2536
|
+
headerHeight: 30,
|
|
2537
|
+
minimumSliderSize: minimumSliderSize
|
|
2538
|
+
}),
|
|
2539
|
+
inputSource: User,
|
|
2540
|
+
args,
|
|
2541
|
+
focused: false,
|
|
2542
|
+
platform,
|
|
2543
|
+
value: ''
|
|
2544
|
+
};
|
|
2545
|
+
set(uid, state, state);
|
|
2546
|
+
};
|
|
2468
2547
|
|
|
2469
2548
|
const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
|
|
2470
2549
|
const state = {
|
|
@@ -2485,7 +2564,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) =
|
|
|
2485
2564
|
height: 300,
|
|
2486
2565
|
top: 50,
|
|
2487
2566
|
width: 600,
|
|
2488
|
-
...create$
|
|
2567
|
+
...create$2({
|
|
2489
2568
|
itemHeight: listItemHeight,
|
|
2490
2569
|
headerHeight: 30,
|
|
2491
2570
|
minimumSliderSize: minimumSliderSize
|
|
@@ -2576,6 +2655,61 @@ const getBlob = async (uri, type) => {
|
|
|
2576
2655
|
return blob;
|
|
2577
2656
|
};
|
|
2578
2657
|
|
|
2658
|
+
const focusIndex = async (state, index) => {
|
|
2659
|
+
const {
|
|
2660
|
+
provider,
|
|
2661
|
+
maxVisibleItems,
|
|
2662
|
+
items,
|
|
2663
|
+
minLineY,
|
|
2664
|
+
maxLineY
|
|
2665
|
+
} = state;
|
|
2666
|
+
// TODO get types working
|
|
2667
|
+
// @ts-ignore
|
|
2668
|
+
if (provider.focusPick) {
|
|
2669
|
+
// @ts-ignore
|
|
2670
|
+
await provider.focusPick(items[index].pick);
|
|
2671
|
+
}
|
|
2672
|
+
if (index < minLineY + 1) {
|
|
2673
|
+
const minLineY = index;
|
|
2674
|
+
const maxLineY = Math.min(index + maxVisibleItems, items.length - 1);
|
|
2675
|
+
// TODO need to scroll up
|
|
2676
|
+
return {
|
|
2677
|
+
...state,
|
|
2678
|
+
minLineY,
|
|
2679
|
+
maxLineY,
|
|
2680
|
+
focusedIndex: index
|
|
2681
|
+
};
|
|
2682
|
+
}
|
|
2683
|
+
if (index >= maxLineY - 1) {
|
|
2684
|
+
// TODO need to scroll down
|
|
2685
|
+
const maxLineY = index + 1;
|
|
2686
|
+
const minLineY = Math.max(maxLineY - maxVisibleItems, 0);
|
|
2687
|
+
return {
|
|
2688
|
+
...state,
|
|
2689
|
+
minLineY,
|
|
2690
|
+
maxLineY,
|
|
2691
|
+
focusedIndex: index
|
|
2692
|
+
};
|
|
2693
|
+
}
|
|
2694
|
+
return {
|
|
2695
|
+
...state,
|
|
2696
|
+
focusedIndex: index
|
|
2697
|
+
};
|
|
2698
|
+
};
|
|
2699
|
+
|
|
2700
|
+
const next = (items, index) => {
|
|
2701
|
+
return (index + 1) % items.length;
|
|
2702
|
+
};
|
|
2703
|
+
|
|
2704
|
+
const focusNext = state => {
|
|
2705
|
+
const {
|
|
2706
|
+
items,
|
|
2707
|
+
focusedIndex
|
|
2708
|
+
} = state;
|
|
2709
|
+
const nextIndex = next(items, focusedIndex);
|
|
2710
|
+
return focusIndex(state, nextIndex);
|
|
2711
|
+
};
|
|
2712
|
+
|
|
2579
2713
|
const Enter = 3;
|
|
2580
2714
|
const Escape = 8;
|
|
2581
2715
|
const PageUp = 10;
|
|
@@ -2614,6 +2748,15 @@ const getKeyBindings = () => {
|
|
|
2614
2748
|
}];
|
|
2615
2749
|
};
|
|
2616
2750
|
|
|
2751
|
+
const closeWidget = async id => {
|
|
2752
|
+
await invoke$1('Viewlet.closeWidget', id);
|
|
2753
|
+
};
|
|
2754
|
+
|
|
2755
|
+
const handleBlur = async state => {
|
|
2756
|
+
await closeWidget(state.uid);
|
|
2757
|
+
return state;
|
|
2758
|
+
};
|
|
2759
|
+
|
|
2617
2760
|
const getDefaultValue = uri => {
|
|
2618
2761
|
switch (uri) {
|
|
2619
2762
|
case 'quickPick://everything':
|
|
@@ -2685,7 +2828,7 @@ const QuickPickEntriesColorTheme = {
|
|
|
2685
2828
|
const Tag$1 = 'Tag';
|
|
2686
2829
|
const Cloud$1 = 'Cloud';
|
|
2687
2830
|
const SourceControl$1 = 'SourceControl';
|
|
2688
|
-
const None = '';
|
|
2831
|
+
const None$1 = '';
|
|
2689
2832
|
|
|
2690
2833
|
const SourceControl = 1;
|
|
2691
2834
|
const Cloud = 2;
|
|
@@ -2737,7 +2880,7 @@ const getPickFilterValue$1 = pick => {
|
|
|
2737
2880
|
const getPickLabel$1 = pick => {
|
|
2738
2881
|
return pick.label;
|
|
2739
2882
|
};
|
|
2740
|
-
const getPickDescription$
|
|
2883
|
+
const getPickDescription$2 = pick => {
|
|
2741
2884
|
return pick.description || '';
|
|
2742
2885
|
};
|
|
2743
2886
|
const convertIcon = icon => {
|
|
@@ -2749,7 +2892,7 @@ const convertIcon = icon => {
|
|
|
2749
2892
|
case Tag:
|
|
2750
2893
|
return Tag$1;
|
|
2751
2894
|
default:
|
|
2752
|
-
return None;
|
|
2895
|
+
return None$1;
|
|
2753
2896
|
}
|
|
2754
2897
|
};
|
|
2755
2898
|
const getPickIcon$1 = pick => {
|
|
@@ -2762,7 +2905,7 @@ const QuickPickEntriesCustom = {
|
|
|
2762
2905
|
getHelpEntries: getHelpEntries$2,
|
|
2763
2906
|
getLabel: getLabel$1,
|
|
2764
2907
|
getNoResults: getNoResults$2,
|
|
2765
|
-
getPickDescription: getPickDescription$
|
|
2908
|
+
getPickDescription: getPickDescription$2,
|
|
2766
2909
|
getPickFilterValue: getPickFilterValue$1,
|
|
2767
2910
|
getPickIcon: getPickIcon$1,
|
|
2768
2911
|
getPickLabel: getPickLabel$1,
|
|
@@ -2879,7 +3022,7 @@ const getPickFilterValue = pick => {
|
|
|
2879
3022
|
const getPickLabel = pick => {
|
|
2880
3023
|
return pathBaseName(pick);
|
|
2881
3024
|
};
|
|
2882
|
-
const getPickDescription = pick => {
|
|
3025
|
+
const getPickDescription$1 = pick => {
|
|
2883
3026
|
return pathDirName(pick);
|
|
2884
3027
|
};
|
|
2885
3028
|
const getPickIcon = () => {
|
|
@@ -2895,7 +3038,7 @@ const QuickPickEntriesOpenRecent = {
|
|
|
2895
3038
|
getHelpEntries,
|
|
2896
3039
|
getLabel,
|
|
2897
3040
|
getNoResults,
|
|
2898
|
-
getPickDescription,
|
|
3041
|
+
getPickDescription: getPickDescription$1,
|
|
2899
3042
|
getPickFileIcon,
|
|
2900
3043
|
getPickFilterValue,
|
|
2901
3044
|
getPickIcon,
|
|
@@ -2986,7 +3129,350 @@ const loadQuickPickEntries = moduleId => {
|
|
|
2986
3129
|
}
|
|
2987
3130
|
};
|
|
2988
3131
|
|
|
3132
|
+
const RenderItems = 1;
|
|
3133
|
+
const RenderFocus = 2;
|
|
3134
|
+
const RenderValue = 3;
|
|
3135
|
+
const RenderCursorOffset = 7;
|
|
3136
|
+
const RenderFocusedIndex = 8;
|
|
3137
|
+
const Height = 9;
|
|
3138
|
+
|
|
3139
|
+
const FileIcon = 'FileIcon';
|
|
3140
|
+
const Label = 'Label';
|
|
3141
|
+
const QuickPickHighlight = 'QuickPickHighlight';
|
|
3142
|
+
const QuickPickItem = 'QuickPickItem';
|
|
3143
|
+
const QuickPickItemActive = 'QuickPickItemActive';
|
|
3144
|
+
const QuickPickItemDescription = 'QuickPickItemDescription';
|
|
3145
|
+
const QuickPickItemLabel = 'QuickPickItemLabel';
|
|
3146
|
+
|
|
3147
|
+
const None = 'none';
|
|
3148
|
+
const Option = 'option';
|
|
3149
|
+
|
|
3150
|
+
const Div = 4;
|
|
3151
|
+
const Span = 8;
|
|
3152
|
+
const Text = 12;
|
|
3153
|
+
const Img = 17;
|
|
3154
|
+
|
|
3155
|
+
const getFileIconVirtualDom = icon => {
|
|
3156
|
+
return {
|
|
3157
|
+
type: Img,
|
|
3158
|
+
className: FileIcon,
|
|
3159
|
+
src: icon,
|
|
3160
|
+
role: None,
|
|
3161
|
+
childCount: 0
|
|
3162
|
+
};
|
|
3163
|
+
};
|
|
3164
|
+
|
|
3165
|
+
const text = data => {
|
|
3166
|
+
return {
|
|
3167
|
+
type: Text,
|
|
3168
|
+
text: data,
|
|
3169
|
+
childCount: 0
|
|
3170
|
+
};
|
|
3171
|
+
};
|
|
3172
|
+
|
|
3173
|
+
const quickPickHighlight = {
|
|
3174
|
+
type: Span,
|
|
3175
|
+
className: QuickPickHighlight,
|
|
3176
|
+
childCount: 1
|
|
3177
|
+
};
|
|
3178
|
+
const addHighlights = (dom, highlights, label) => {
|
|
3179
|
+
const labelDom = {
|
|
3180
|
+
type: Div,
|
|
3181
|
+
className: QuickPickItemLabel,
|
|
3182
|
+
childCount: 0
|
|
3183
|
+
};
|
|
3184
|
+
dom.push(labelDom);
|
|
3185
|
+
let position = 0;
|
|
3186
|
+
for (let i = 0; i < highlights.length; i += 2) {
|
|
3187
|
+
const highlightStart = highlights[i];
|
|
3188
|
+
const highlightEnd = highlights[i + 1];
|
|
3189
|
+
if (position < highlightStart) {
|
|
3190
|
+
const beforeText = label.slice(position, highlightStart);
|
|
3191
|
+
labelDom.childCount++;
|
|
3192
|
+
dom.push(text(beforeText));
|
|
3193
|
+
}
|
|
3194
|
+
const highlightText = label.slice(highlightStart, highlightEnd);
|
|
3195
|
+
labelDom.childCount++;
|
|
3196
|
+
dom.push(quickPickHighlight, text(highlightText));
|
|
3197
|
+
position = highlightEnd;
|
|
3198
|
+
}
|
|
3199
|
+
if (position < label.length) {
|
|
3200
|
+
const afterText = label.slice(position);
|
|
3201
|
+
labelDom.childCount++;
|
|
3202
|
+
dom.push(text(afterText));
|
|
3203
|
+
}
|
|
3204
|
+
};
|
|
3205
|
+
const getQuickPickItemVirtualDom = visibleItem => {
|
|
3206
|
+
const {
|
|
3207
|
+
posInSet,
|
|
3208
|
+
label,
|
|
3209
|
+
setSize,
|
|
3210
|
+
isActive,
|
|
3211
|
+
description,
|
|
3212
|
+
icon,
|
|
3213
|
+
matches,
|
|
3214
|
+
fileIcon
|
|
3215
|
+
} = visibleItem;
|
|
3216
|
+
const highlights = matches.slice(1);
|
|
3217
|
+
const dom = [];
|
|
3218
|
+
dom.push({
|
|
3219
|
+
type: Div,
|
|
3220
|
+
className: QuickPickItem,
|
|
3221
|
+
role: Option,
|
|
3222
|
+
ariaPosInSet: posInSet,
|
|
3223
|
+
ariaSetSize: setSize,
|
|
3224
|
+
childCount: 1
|
|
3225
|
+
});
|
|
3226
|
+
const parent = dom[0];
|
|
3227
|
+
if (isActive) {
|
|
3228
|
+
// @ts-ignore
|
|
3229
|
+
parent.id = 'QuickPickItemActive';
|
|
3230
|
+
parent.className += ' ' + QuickPickItemActive;
|
|
3231
|
+
}
|
|
3232
|
+
if (fileIcon) {
|
|
3233
|
+
parent.childCount++;
|
|
3234
|
+
dom.push(getFileIconVirtualDom(fileIcon));
|
|
3235
|
+
} else if (icon) {
|
|
3236
|
+
parent.childCount++;
|
|
3237
|
+
dom.push({
|
|
3238
|
+
type: Div,
|
|
3239
|
+
className: `QuickPickMaskIcon MaskIcon MaskIcon${icon}`,
|
|
3240
|
+
childCount: 0
|
|
3241
|
+
});
|
|
3242
|
+
}
|
|
3243
|
+
addHighlights(dom, highlights, label);
|
|
3244
|
+
if (description) {
|
|
3245
|
+
parent.childCount++;
|
|
3246
|
+
dom.push({
|
|
3247
|
+
type: Div,
|
|
3248
|
+
className: QuickPickItemDescription,
|
|
3249
|
+
childCount: 1
|
|
3250
|
+
}, text(description));
|
|
3251
|
+
}
|
|
3252
|
+
return dom;
|
|
3253
|
+
};
|
|
3254
|
+
|
|
3255
|
+
const getQuickPickItemsVirtualDom = visibleItems => {
|
|
3256
|
+
if (visibleItems.length === 0) {
|
|
3257
|
+
return [{
|
|
3258
|
+
type: Div,
|
|
3259
|
+
className: 'QuickPickItem QuickPickItemActive QuickPickStatus',
|
|
3260
|
+
childCount: 1
|
|
3261
|
+
}, {
|
|
3262
|
+
type: Div,
|
|
3263
|
+
className: Label,
|
|
3264
|
+
childCount: 1
|
|
3265
|
+
}, text('No Results')];
|
|
3266
|
+
}
|
|
3267
|
+
const dom = visibleItems.flatMap(getQuickPickItemVirtualDom);
|
|
3268
|
+
return dom;
|
|
3269
|
+
};
|
|
3270
|
+
|
|
3271
|
+
const getPickDescription = (provider, pick) => {
|
|
3272
|
+
if (provider.getPickDescription) {
|
|
3273
|
+
return provider.getPickDescription(pick);
|
|
3274
|
+
}
|
|
3275
|
+
return '';
|
|
3276
|
+
};
|
|
3277
|
+
const getFileIcon = (provider, pick) => {
|
|
3278
|
+
if (provider.getPickFileIcon) {
|
|
3279
|
+
return provider.getPickFileIcon(pick);
|
|
3280
|
+
}
|
|
3281
|
+
return '';
|
|
3282
|
+
};
|
|
3283
|
+
const getVisible = (provider, items, minLineY, maxLineY, focusedIndex) => {
|
|
3284
|
+
const visibleItems = [];
|
|
3285
|
+
const setSize = items.length;
|
|
3286
|
+
const max = Math.min(setSize, maxLineY);
|
|
3287
|
+
for (let i = minLineY; i < max; i++) {
|
|
3288
|
+
const item = items[i];
|
|
3289
|
+
const pick = item.pick;
|
|
3290
|
+
const label = provider.getPickLabel(pick);
|
|
3291
|
+
const description = getPickDescription(provider, pick);
|
|
3292
|
+
const icon = provider.getPickIcon(pick);
|
|
3293
|
+
const fileIcon = getFileIcon(provider, pick);
|
|
3294
|
+
visibleItems.push({
|
|
3295
|
+
label,
|
|
3296
|
+
description,
|
|
3297
|
+
icon,
|
|
3298
|
+
fileIcon,
|
|
3299
|
+
posInSet: i + 1,
|
|
3300
|
+
setSize,
|
|
3301
|
+
isActive: i === focusedIndex,
|
|
3302
|
+
matches: item.matches
|
|
3303
|
+
});
|
|
3304
|
+
}
|
|
3305
|
+
return visibleItems;
|
|
3306
|
+
};
|
|
3307
|
+
|
|
3308
|
+
const SetCursorOffset = 'setCursorOffset';
|
|
3309
|
+
const SetFocusedIndex = 'setFocusedIndex';
|
|
3310
|
+
const SetItemsHeight = 'setItemsHeight';
|
|
3311
|
+
const SetValue = 'setValue';
|
|
3312
|
+
|
|
3313
|
+
const renderValue = (oldState, newState) => {
|
|
3314
|
+
return [/* method */SetValue, /* value */newState.value];
|
|
3315
|
+
};
|
|
3316
|
+
const renderCursorOffset = (oldState, newState) => {
|
|
3317
|
+
return [/* method */SetCursorOffset, /* cursorOffset */newState.cursorOffset];
|
|
3318
|
+
};
|
|
3319
|
+
const renderItems = (oldState, newState) => {
|
|
3320
|
+
const visibleItems = getVisible(newState.provider, newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex);
|
|
3321
|
+
const dom = getQuickPickItemsVirtualDom(visibleItems);
|
|
3322
|
+
return [/* method */'setItemsDom', dom];
|
|
3323
|
+
};
|
|
3324
|
+
const renderFocusedIndex = (oldState, newState) => {
|
|
3325
|
+
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
3326
|
+
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
3327
|
+
return [/* method */SetFocusedIndex, /* oldFocusedIndex */oldFocusedIndex, /* newFocusedIndex */newFocusedIndex];
|
|
3328
|
+
};
|
|
3329
|
+
const renderHeight = (oldState, newState) => {
|
|
3330
|
+
if (newState.items.length === 0) {
|
|
3331
|
+
return [/* method */SetItemsHeight, /* height */newState.itemHeight];
|
|
3332
|
+
}
|
|
3333
|
+
const maxLineY = Math.min(newState.maxLineY, newState.items.length);
|
|
3334
|
+
const itemCount = maxLineY - newState.minLineY;
|
|
3335
|
+
const height = itemCount * newState.itemHeight;
|
|
3336
|
+
return [/* method */SetItemsHeight, /* height */height];
|
|
3337
|
+
};
|
|
3338
|
+
const renderFocus = (oldState, newState) => {
|
|
3339
|
+
const selector = newState.focused ? '.InputBox' : '';
|
|
3340
|
+
return ['Viewlet.focusSelector', selector];
|
|
3341
|
+
};
|
|
3342
|
+
const getRenderer = diffType => {
|
|
3343
|
+
switch (diffType) {
|
|
3344
|
+
case RenderValue:
|
|
3345
|
+
return renderValue;
|
|
3346
|
+
case RenderCursorOffset:
|
|
3347
|
+
return renderCursorOffset;
|
|
3348
|
+
case RenderItems:
|
|
3349
|
+
return renderItems;
|
|
3350
|
+
case RenderFocusedIndex:
|
|
3351
|
+
return renderFocusedIndex;
|
|
3352
|
+
case Height:
|
|
3353
|
+
return renderHeight;
|
|
3354
|
+
case RenderFocus:
|
|
3355
|
+
return renderFocus;
|
|
3356
|
+
default:
|
|
3357
|
+
throw new Error('unknown renderer');
|
|
3358
|
+
}
|
|
3359
|
+
};
|
|
3360
|
+
|
|
3361
|
+
const applyRender = (oldState, newState, diffResult) => {
|
|
3362
|
+
const commands = [];
|
|
3363
|
+
for (const item of diffResult) {
|
|
3364
|
+
const fn = getRenderer(item);
|
|
3365
|
+
commands.push(fn(oldState, newState));
|
|
3366
|
+
}
|
|
3367
|
+
return commands;
|
|
3368
|
+
};
|
|
3369
|
+
|
|
3370
|
+
const diffType$4 = RenderFocus;
|
|
3371
|
+
const isEqual$4 = (oldState, newState) => {
|
|
3372
|
+
return oldState.focused === newState.focused;
|
|
3373
|
+
};
|
|
3374
|
+
|
|
3375
|
+
const DiffFocus = {
|
|
3376
|
+
__proto__: null,
|
|
3377
|
+
diffType: diffType$4,
|
|
3378
|
+
isEqual: isEqual$4
|
|
3379
|
+
};
|
|
3380
|
+
|
|
3381
|
+
const diffType$3 = RenderFocusedIndex;
|
|
3382
|
+
const isEqual$3 = (oldState, newState) => {
|
|
3383
|
+
return oldState.focusedIndex === newState.focusedIndex;
|
|
3384
|
+
};
|
|
3385
|
+
|
|
3386
|
+
const DiffFocusedIndex = {
|
|
3387
|
+
__proto__: null,
|
|
3388
|
+
diffType: diffType$3,
|
|
3389
|
+
isEqual: isEqual$3
|
|
3390
|
+
};
|
|
3391
|
+
|
|
3392
|
+
const diffType$2 = Height;
|
|
3393
|
+
const isEqual$2 = (oldState, newState) => {
|
|
3394
|
+
return oldState.items.length === newState.items.length;
|
|
3395
|
+
};
|
|
3396
|
+
|
|
3397
|
+
const DiffHeight = {
|
|
3398
|
+
__proto__: null,
|
|
3399
|
+
diffType: diffType$2,
|
|
3400
|
+
isEqual: isEqual$2
|
|
3401
|
+
};
|
|
3402
|
+
|
|
3403
|
+
const diffType$1 = RenderItems;
|
|
3404
|
+
const isEqual$1 = (oldState, newState) => {
|
|
3405
|
+
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
|
|
3406
|
+
};
|
|
3407
|
+
|
|
3408
|
+
const DiffItems = {
|
|
3409
|
+
__proto__: null,
|
|
3410
|
+
diffType: diffType$1,
|
|
3411
|
+
isEqual: isEqual$1
|
|
3412
|
+
};
|
|
3413
|
+
|
|
3414
|
+
const diffType = RenderValue;
|
|
3415
|
+
const isEqual = (oldState, newState) => {
|
|
3416
|
+
return newState.inputSource === User || oldState.value === newState.value;
|
|
3417
|
+
};
|
|
3418
|
+
|
|
3419
|
+
const DiffValue = {
|
|
3420
|
+
__proto__: null,
|
|
3421
|
+
diffType,
|
|
3422
|
+
isEqual
|
|
3423
|
+
};
|
|
3424
|
+
|
|
3425
|
+
const modules = [DiffHeight, DiffItems, DiffFocus, DiffFocus, DiffValue, DiffFocusedIndex];
|
|
3426
|
+
|
|
3427
|
+
const diff = (oldState, newState) => {
|
|
3428
|
+
const diffResult = [];
|
|
3429
|
+
for (const module of modules) {
|
|
3430
|
+
if (!module.isEqual(oldState, newState)) {
|
|
3431
|
+
diffResult.push(module.diffType);
|
|
3432
|
+
}
|
|
3433
|
+
}
|
|
3434
|
+
return diffResult;
|
|
3435
|
+
};
|
|
3436
|
+
|
|
3437
|
+
const doRender = uid => {
|
|
3438
|
+
const {
|
|
3439
|
+
oldState,
|
|
3440
|
+
newState
|
|
3441
|
+
} = get(uid);
|
|
3442
|
+
const diffResult = diff(oldState, newState);
|
|
3443
|
+
return applyRender(oldState, newState, diffResult);
|
|
3444
|
+
};
|
|
3445
|
+
|
|
3446
|
+
const wrapCommand = fn => {
|
|
3447
|
+
const wrapped = async (uid, ...args) => {
|
|
3448
|
+
const {
|
|
3449
|
+
newState
|
|
3450
|
+
} = get(uid);
|
|
3451
|
+
const newerState = await fn(newState, ...args);
|
|
3452
|
+
set(uid, newState, newerState);
|
|
3453
|
+
};
|
|
3454
|
+
return wrapped;
|
|
3455
|
+
};
|
|
3456
|
+
|
|
2989
3457
|
const commandMap = {
|
|
3458
|
+
'QuickPick.create': create,
|
|
3459
|
+
'QuickPick.create2': create$1,
|
|
3460
|
+
'QuickPick.focusIndex': wrapCommand(focusIndex),
|
|
3461
|
+
'QuickPick.focusNext': wrapCommand(focusNext),
|
|
3462
|
+
'QuickPick.getKeyBindings': getKeyBindings,
|
|
3463
|
+
'QuickPick.handleBlur': wrapCommand(handleBlur),
|
|
3464
|
+
'QuickPick.handleWheel': wrapCommand(handleWheel),
|
|
3465
|
+
'QuickPick.setDeltaY': wrapCommand(setDeltaY),
|
|
3466
|
+
'QuickPick.loadContent': wrapCommand(loadContent),
|
|
3467
|
+
'QuickPick.loadEntries2': load,
|
|
3468
|
+
'QuickPick.render': doRender,
|
|
3469
|
+
'SearchFile.filter': filterQuickPickItems,
|
|
3470
|
+
'SearchFile.searchFile': searchFile,
|
|
3471
|
+
'SearchFile.searchFileWithFetch': searchFile$3,
|
|
3472
|
+
'SearchFile.searchFileWithHtml': searchFile$2,
|
|
3473
|
+
'SearchFile.searchFileWithRipGrep': searchFile$1,
|
|
3474
|
+
// deprecated
|
|
3475
|
+
'QuickPick.loadEntries': loadQuickPickEntries,
|
|
2990
3476
|
'FileSystemFetch.chmod': chmod,
|
|
2991
3477
|
'FileSystemFetch.getBlob': getBlob,
|
|
2992
3478
|
'FileSystemFetch.mkdir': mkdir,
|
|
@@ -3002,17 +3488,7 @@ const commandMap = {
|
|
|
3002
3488
|
'FileSystemMemory.readDirWithFileTypes': readDirWithFileTypes$1,
|
|
3003
3489
|
'FileSystemMemory.readFile': readFile$1,
|
|
3004
3490
|
'FileSystemMemory.remove': remove$1,
|
|
3005
|
-
'FileSystemMemory.writeFile': writeFile$1
|
|
3006
|
-
'QuickPick.create': create,
|
|
3007
|
-
'QuickPick.getKeyBindings': getKeyBindings,
|
|
3008
|
-
'QuickPick.loadContent': loadContent,
|
|
3009
|
-
'QuickPick.loadEntries': loadQuickPickEntries,
|
|
3010
|
-
'QuickPick.loadEntries2': load,
|
|
3011
|
-
'SearchFile.filter': filterQuickPickItems,
|
|
3012
|
-
'SearchFile.searchFile': searchFile,
|
|
3013
|
-
'SearchFile.searchFileWithFetch': searchFile$3,
|
|
3014
|
-
'SearchFile.searchFileWithHtml': searchFile$2,
|
|
3015
|
-
'SearchFile.searchFileWithRipGrep': searchFile$1
|
|
3491
|
+
'FileSystemMemory.writeFile': writeFile$1
|
|
3016
3492
|
};
|
|
3017
3493
|
|
|
3018
3494
|
const listen = async () => {
|