@lvce-editor/quick-pick-worker 4.2.0 → 4.3.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/quickPickWorkerMain.js +251 -128
- package/package.json +1 -1
|
@@ -1088,7 +1088,7 @@ const createMockRpc = ({
|
|
|
1088
1088
|
};
|
|
1089
1089
|
|
|
1090
1090
|
const rpcs = Object.create(null);
|
|
1091
|
-
const set$
|
|
1091
|
+
const set$6 = (id, rpc) => {
|
|
1092
1092
|
rpcs[id] = rpc;
|
|
1093
1093
|
};
|
|
1094
1094
|
const get$2 = id => {
|
|
@@ -1121,7 +1121,7 @@ const create$4 = rpcId => {
|
|
|
1121
1121
|
const mockRpc = createMockRpc({
|
|
1122
1122
|
commandMap
|
|
1123
1123
|
});
|
|
1124
|
-
set$
|
|
1124
|
+
set$6(rpcId, mockRpc);
|
|
1125
1125
|
// @ts-ignore
|
|
1126
1126
|
mockRpc[Symbol.dispose] = () => {
|
|
1127
1127
|
remove$1(rpcId);
|
|
@@ -1130,7 +1130,7 @@ const create$4 = rpcId => {
|
|
|
1130
1130
|
return mockRpc;
|
|
1131
1131
|
},
|
|
1132
1132
|
set(rpc) {
|
|
1133
|
-
set$
|
|
1133
|
+
set$6(rpcId, rpc);
|
|
1134
1134
|
}
|
|
1135
1135
|
};
|
|
1136
1136
|
};
|
|
@@ -1143,6 +1143,7 @@ const Img = 17;
|
|
|
1143
1143
|
const Reference = 100;
|
|
1144
1144
|
|
|
1145
1145
|
const EditorWorker = 99;
|
|
1146
|
+
const ExtensionManagementWorker = 9006;
|
|
1146
1147
|
const RendererWorker = 1;
|
|
1147
1148
|
|
|
1148
1149
|
const SetDom2 = 'Viewlet.setDom2';
|
|
@@ -1151,14 +1152,22 @@ const SetPatches = 'Viewlet.setPatches';
|
|
|
1151
1152
|
const FocusQuickPickInput = 20;
|
|
1152
1153
|
|
|
1153
1154
|
const {
|
|
1154
|
-
invoke: invoke$
|
|
1155
|
-
set: set$
|
|
1155
|
+
invoke: invoke$4,
|
|
1156
|
+
set: set$5
|
|
1156
1157
|
} = create$4(EditorWorker);
|
|
1157
1158
|
const getLines = async editorUid => {
|
|
1158
|
-
const lines = await invoke$
|
|
1159
|
+
const lines = await invoke$4('Editor.getLines2', editorUid);
|
|
1159
1160
|
return lines;
|
|
1160
1161
|
};
|
|
1161
1162
|
|
|
1163
|
+
const {
|
|
1164
|
+
invoke: invoke$3,
|
|
1165
|
+
set: set$4
|
|
1166
|
+
} = create$4(ExtensionManagementWorker);
|
|
1167
|
+
const getLanguages = (platform, assetDir) => {
|
|
1168
|
+
return invoke$3('Extensions.getLanguages', platform, assetDir);
|
|
1169
|
+
};
|
|
1170
|
+
|
|
1162
1171
|
const {
|
|
1163
1172
|
invoke: invoke$2,
|
|
1164
1173
|
set: set$3
|
|
@@ -1192,6 +1201,10 @@ const sendMessagePortToFileSearchWorker2 = async (port, rpcId = 0) => {
|
|
|
1192
1201
|
const getActiveEditorId = () => {
|
|
1193
1202
|
return invoke$1('GetActiveEditor.getActiveEditorId');
|
|
1194
1203
|
};
|
|
1204
|
+
const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
1205
|
+
const command = 'Extensions.handleMessagePort';
|
|
1206
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1207
|
+
};
|
|
1195
1208
|
const openUri$1 = async (uri, focus, options) => {
|
|
1196
1209
|
await invoke$1('Main.openUri', uri, focus, options);
|
|
1197
1210
|
};
|
|
@@ -1239,6 +1252,7 @@ const Recent$1 = 7;
|
|
|
1239
1252
|
const Symbol$3 = 8;
|
|
1240
1253
|
const View$3 = 9;
|
|
1241
1254
|
const WorkspaceSymbol$2 = 10;
|
|
1255
|
+
const LanguageMode$1 = 11;
|
|
1242
1256
|
const EveryThing$1 = 100;
|
|
1243
1257
|
|
|
1244
1258
|
const getCancelResult$1 = args => {
|
|
@@ -2345,7 +2359,7 @@ const getColorThemeNames = async (assetDir, platform) => {
|
|
|
2345
2359
|
return invoke$1('ColorTheme.getColorThemeNames', assetDir, platform);
|
|
2346
2360
|
};
|
|
2347
2361
|
|
|
2348
|
-
const toProtoVisibleItem$
|
|
2362
|
+
const toProtoVisibleItem$4 = name => {
|
|
2349
2363
|
const pick = {
|
|
2350
2364
|
description: '',
|
|
2351
2365
|
direntType: 0,
|
|
@@ -2357,15 +2371,41 @@ const toProtoVisibleItem$3 = name => {
|
|
|
2357
2371
|
};
|
|
2358
2372
|
return pick;
|
|
2359
2373
|
};
|
|
2360
|
-
const getPicks$
|
|
2374
|
+
const getPicks$d = async (searchValue, args, {
|
|
2361
2375
|
assetDir = '',
|
|
2362
2376
|
platform = 0
|
|
2363
2377
|
} = {}) => {
|
|
2364
2378
|
const colorThemeNames = await getColorThemeNames(assetDir, platform);
|
|
2365
|
-
const picks = colorThemeNames.map(toProtoVisibleItem$
|
|
2379
|
+
const picks = colorThemeNames.map(toProtoVisibleItem$4);
|
|
2366
2380
|
return picks;
|
|
2367
2381
|
};
|
|
2368
2382
|
|
|
2383
|
+
const getCommandName = (item, property) => {
|
|
2384
|
+
const value = item[property];
|
|
2385
|
+
return typeof value === 'string' && value ? value : '<unknown>';
|
|
2386
|
+
};
|
|
2387
|
+
const getWarning = (items, property, nameProperty) => {
|
|
2388
|
+
const commandName = getCommandName(items[0], nameProperty);
|
|
2389
|
+
if (items.length === 1) {
|
|
2390
|
+
return `command ${commandName} has missing ${property}`;
|
|
2391
|
+
}
|
|
2392
|
+
const otherCount = items.length - 1;
|
|
2393
|
+
const otherCommands = otherCount === 1 ? 'command' : 'commands';
|
|
2394
|
+
return `command ${commandName} and ${otherCount} other ${otherCommands} have missing ${property}`;
|
|
2395
|
+
};
|
|
2396
|
+
const collectWarnings = items => {
|
|
2397
|
+
const warnings = [];
|
|
2398
|
+
const missingLabels = items.filter(item => !item.label);
|
|
2399
|
+
const missingIds = items.filter(item => !item.id);
|
|
2400
|
+
if (missingLabels.length > 0) {
|
|
2401
|
+
warnings.push(getWarning(missingLabels, 'label', 'id'));
|
|
2402
|
+
}
|
|
2403
|
+
if (missingIds.length > 0) {
|
|
2404
|
+
warnings.push(getWarning(missingIds, 'id', 'label'));
|
|
2405
|
+
}
|
|
2406
|
+
return warnings;
|
|
2407
|
+
};
|
|
2408
|
+
|
|
2369
2409
|
const handleError = async (error, notify = true, prefix = '') => {
|
|
2370
2410
|
console.error(error);
|
|
2371
2411
|
};
|
|
@@ -2411,18 +2451,17 @@ const add$1 = menuEntries => {
|
|
|
2411
2451
|
state$1.menuEntries = [...state$1.menuEntries, ...menuEntries];
|
|
2412
2452
|
};
|
|
2413
2453
|
|
|
2454
|
+
const changeLanguageModePick = {
|
|
2455
|
+
id: 'QuickPick.changeLanguageMode',
|
|
2456
|
+
label: 'Change Language Mode'
|
|
2457
|
+
};
|
|
2458
|
+
|
|
2414
2459
|
// TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
|
|
2415
2460
|
const getBuiltinPicks = async () => {
|
|
2416
2461
|
const builtinPicks = await getAll();
|
|
2417
|
-
return builtinPicks;
|
|
2462
|
+
return [...builtinPicks, changeLanguageModePick];
|
|
2418
2463
|
};
|
|
2419
2464
|
const prefixIdWithExt = item => {
|
|
2420
|
-
if (!item.label) {
|
|
2421
|
-
warn('[QuickPick] item has missing label', item);
|
|
2422
|
-
}
|
|
2423
|
-
if (!item.id) {
|
|
2424
|
-
warn('[QuickPick] item has missing id', item);
|
|
2425
|
-
}
|
|
2426
2465
|
return {
|
|
2427
2466
|
...item,
|
|
2428
2467
|
id: `ext.${item.id}`,
|
|
@@ -2440,6 +2479,10 @@ const getExtensionPicks = async (assetDir, platform) => {
|
|
|
2440
2479
|
if (!extensionPicks) {
|
|
2441
2480
|
return [];
|
|
2442
2481
|
}
|
|
2482
|
+
const warnings = collectWarnings(extensionPicks);
|
|
2483
|
+
for (const warning of warnings) {
|
|
2484
|
+
warn(`[QuickPick] ${warning}`);
|
|
2485
|
+
}
|
|
2443
2486
|
const mappedPicks = extensionPicks.map(prefixIdWithExt);
|
|
2444
2487
|
return mappedPicks;
|
|
2445
2488
|
} catch (error) {
|
|
@@ -2447,7 +2490,7 @@ const getExtensionPicks = async (assetDir, platform) => {
|
|
|
2447
2490
|
return [];
|
|
2448
2491
|
}
|
|
2449
2492
|
};
|
|
2450
|
-
const toProtoVisibleItem$
|
|
2493
|
+
const toProtoVisibleItem$3 = item => {
|
|
2451
2494
|
const pick = {
|
|
2452
2495
|
// @ts-ignore
|
|
2453
2496
|
args: item.args,
|
|
@@ -2464,7 +2507,7 @@ const toProtoVisibleItem$2 = item => {
|
|
|
2464
2507
|
// @ts-ignore
|
|
2465
2508
|
return pick;
|
|
2466
2509
|
};
|
|
2467
|
-
const getPicks$
|
|
2510
|
+
const getPicks$c = async (value, args, {
|
|
2468
2511
|
assetDir = '',
|
|
2469
2512
|
platform = 0
|
|
2470
2513
|
} = {}) => {
|
|
@@ -2472,7 +2515,7 @@ const getPicks$b = async (value, args, {
|
|
|
2472
2515
|
const builtinPicks = await getBuiltinPicks();
|
|
2473
2516
|
const extensionPicks = await getExtensionPicks(assetDir, platform);
|
|
2474
2517
|
const allPicks = [...builtinPicks, ...extensionPicks];
|
|
2475
|
-
const converted = allPicks.map(toProtoVisibleItem$
|
|
2518
|
+
const converted = allPicks.map(toProtoVisibleItem$3);
|
|
2476
2519
|
return converted;
|
|
2477
2520
|
};
|
|
2478
2521
|
|
|
@@ -2502,7 +2545,7 @@ const invoke = (method, ...args) => {
|
|
|
2502
2545
|
return rpc.invoke(method, ...args);
|
|
2503
2546
|
};
|
|
2504
2547
|
|
|
2505
|
-
const toProtoVisibleItem$
|
|
2548
|
+
const toProtoVisibleItem$2 = item => {
|
|
2506
2549
|
const {
|
|
2507
2550
|
description = '',
|
|
2508
2551
|
label,
|
|
@@ -2519,11 +2562,11 @@ const toProtoVisibleItem$1 = item => {
|
|
|
2519
2562
|
value
|
|
2520
2563
|
};
|
|
2521
2564
|
};
|
|
2522
|
-
const getPicks$
|
|
2565
|
+
const getPicks$b = async (searchValue, args) => {
|
|
2523
2566
|
state.args = args;
|
|
2524
2567
|
const options = args.at(-1);
|
|
2525
2568
|
const items = options?.mode === 'quickInput' ? searchValue === '' && options?.customItemsId ? get(options.customItemsId) : await invoke('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue) : options?.customItemsId ? get(options.customItemsId) : args[1] || [];
|
|
2526
|
-
const mapped = items.map(toProtoVisibleItem$
|
|
2569
|
+
const mapped = items.map(toProtoVisibleItem$2);
|
|
2527
2570
|
return mapped;
|
|
2528
2571
|
};
|
|
2529
2572
|
|
|
@@ -2576,7 +2619,7 @@ const convertToPick = uri => {
|
|
|
2576
2619
|
// e.g. when there are many files, don't need
|
|
2577
2620
|
// to compute the fileIcon for all files
|
|
2578
2621
|
|
|
2579
|
-
const getPicks$
|
|
2622
|
+
const getPicks$a = async searchValue => {
|
|
2580
2623
|
// TODO cache workspace path
|
|
2581
2624
|
const workspace = await getWorkspacePath();
|
|
2582
2625
|
if (!workspace) {
|
|
@@ -2740,7 +2783,7 @@ const parseGotoline = value => {
|
|
|
2740
2783
|
return wantedLine;
|
|
2741
2784
|
};
|
|
2742
2785
|
|
|
2743
|
-
const getPicks$
|
|
2786
|
+
const getPicks$9 = async value => {
|
|
2744
2787
|
if (value === GoToLine$1) {
|
|
2745
2788
|
return getPicksGoToLineBase();
|
|
2746
2789
|
}
|
|
@@ -2770,7 +2813,7 @@ const Percent = '%';
|
|
|
2770
2813
|
const AngleBracket = '>';
|
|
2771
2814
|
const View$1 = 'view';
|
|
2772
2815
|
|
|
2773
|
-
const getPicks$
|
|
2816
|
+
const getPicks$8 = async () => {
|
|
2774
2817
|
return [{
|
|
2775
2818
|
description: goToFile(),
|
|
2776
2819
|
direntType: None$2,
|
|
@@ -2822,6 +2865,43 @@ const getPicks$7 = async () => {
|
|
|
2822
2865
|
}];
|
|
2823
2866
|
};
|
|
2824
2867
|
|
|
2868
|
+
const toProtoVisibleItem$1 = language => {
|
|
2869
|
+
const value = {
|
|
2870
|
+
languageId: language.id,
|
|
2871
|
+
tokenizePath: language.tokenize || ''
|
|
2872
|
+
};
|
|
2873
|
+
return {
|
|
2874
|
+
description: '',
|
|
2875
|
+
direntType: 0,
|
|
2876
|
+
fileIcon: '',
|
|
2877
|
+
icon: '',
|
|
2878
|
+
label: language.id,
|
|
2879
|
+
matches: [],
|
|
2880
|
+
uri: '',
|
|
2881
|
+
value
|
|
2882
|
+
};
|
|
2883
|
+
};
|
|
2884
|
+
const getUniqueLanguages = languages => {
|
|
2885
|
+
const seen = new Set();
|
|
2886
|
+
const uniqueLanguages = [];
|
|
2887
|
+
for (const language of languages) {
|
|
2888
|
+
if (!language || typeof language.id !== 'string' || seen.has(language.id)) {
|
|
2889
|
+
continue;
|
|
2890
|
+
}
|
|
2891
|
+
seen.add(language.id);
|
|
2892
|
+
uniqueLanguages.push(language);
|
|
2893
|
+
}
|
|
2894
|
+
uniqueLanguages.sort((a, b) => a.id.localeCompare(b.id));
|
|
2895
|
+
return uniqueLanguages;
|
|
2896
|
+
};
|
|
2897
|
+
const getPicks$7 = async (_searchValue, _args, {
|
|
2898
|
+
assetDir = '',
|
|
2899
|
+
platform = 0
|
|
2900
|
+
} = {}) => {
|
|
2901
|
+
const languages = await getLanguages(platform, assetDir);
|
|
2902
|
+
return getUniqueLanguages(languages).map(toProtoVisibleItem$1);
|
|
2903
|
+
};
|
|
2904
|
+
|
|
2825
2905
|
const uniq = array => {
|
|
2826
2906
|
return [...new Set(array)];
|
|
2827
2907
|
};
|
|
@@ -2883,8 +2963,9 @@ const getPicks$3 = async () => {
|
|
|
2883
2963
|
|
|
2884
2964
|
const Hide = 'hide';
|
|
2885
2965
|
const KeepOpen = '';
|
|
2966
|
+
const OpenLanguageMode = 'open-language-mode';
|
|
2886
2967
|
|
|
2887
|
-
const selectPick$
|
|
2968
|
+
const selectPick$a = async pick => {
|
|
2888
2969
|
const id = pick.label;
|
|
2889
2970
|
await setColorTheme(id);
|
|
2890
2971
|
return {
|
|
@@ -2904,6 +2985,11 @@ const shouldHide = item => {
|
|
|
2904
2985
|
};
|
|
2905
2986
|
|
|
2906
2987
|
const selectPickBuiltin = async item => {
|
|
2988
|
+
if (item.id === 'QuickPick.changeLanguageMode') {
|
|
2989
|
+
return {
|
|
2990
|
+
command: OpenLanguageMode
|
|
2991
|
+
};
|
|
2992
|
+
}
|
|
2907
2993
|
const args = item.args || [];
|
|
2908
2994
|
// TODO ids should be all numbers for efficiency -> also directly can call command
|
|
2909
2995
|
await invoke$1(item.id, ...args);
|
|
@@ -2931,7 +3017,7 @@ const selectPickExtension = async item => {
|
|
|
2931
3017
|
command: KeepOpen
|
|
2932
3018
|
};
|
|
2933
3019
|
};
|
|
2934
|
-
const selectPick$
|
|
3020
|
+
const selectPick$9 = async item => {
|
|
2935
3021
|
// @ts-ignore
|
|
2936
3022
|
const {
|
|
2937
3023
|
id
|
|
@@ -2949,7 +3035,7 @@ const getOptions = args => {
|
|
|
2949
3035
|
}
|
|
2950
3036
|
return last;
|
|
2951
3037
|
};
|
|
2952
|
-
const selectPick$
|
|
3038
|
+
const selectPick$8 = async (_pick, value) => {
|
|
2953
3039
|
const {
|
|
2954
3040
|
args
|
|
2955
3041
|
} = state;
|
|
@@ -2976,7 +3062,7 @@ const openUri = async uri => {
|
|
|
2976
3062
|
await openUri$1(uri);
|
|
2977
3063
|
};
|
|
2978
3064
|
|
|
2979
|
-
const selectPick$
|
|
3065
|
+
const selectPick$7 = async pick => {
|
|
2980
3066
|
const {
|
|
2981
3067
|
description
|
|
2982
3068
|
} = pick;
|
|
@@ -3014,7 +3100,7 @@ const selectPickGoToColumn = async (item, value) => {
|
|
|
3014
3100
|
};
|
|
3015
3101
|
};
|
|
3016
3102
|
|
|
3017
|
-
const selectPick$
|
|
3103
|
+
const selectPick$6 = async (item, value) => {
|
|
3018
3104
|
if (value.startsWith(GoToLine$1)) {
|
|
3019
3105
|
const lineString = value.slice(GoToLine$1.length);
|
|
3020
3106
|
const wantedLine = Number.parseInt(lineString, 10);
|
|
@@ -3030,13 +3116,22 @@ const selectPick$5 = async (item, value) => {
|
|
|
3030
3116
|
};
|
|
3031
3117
|
};
|
|
3032
3118
|
|
|
3033
|
-
const selectPick$
|
|
3119
|
+
const selectPick$5 = async item => {
|
|
3034
3120
|
// Command.execute(/* openView */ 549, /* viewName */ item.label)
|
|
3035
3121
|
return {
|
|
3036
3122
|
command: Hide
|
|
3037
3123
|
};
|
|
3038
3124
|
};
|
|
3039
3125
|
|
|
3126
|
+
const selectPick$4 = async pick => {
|
|
3127
|
+
const editorId = await getActiveEditorId();
|
|
3128
|
+
const value = pick.value;
|
|
3129
|
+
await invoke$1('Viewlet.executeViewletCommand', editorId, 'setLanguageId', value.languageId, value.tokenizePath);
|
|
3130
|
+
return {
|
|
3131
|
+
command: Hide
|
|
3132
|
+
};
|
|
3133
|
+
};
|
|
3134
|
+
|
|
3040
3135
|
const openWorkspaceFolder = uri => {
|
|
3041
3136
|
return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
|
|
3042
3137
|
};
|
|
@@ -3071,8 +3166,8 @@ const selectPick = async item => {
|
|
|
3071
3166
|
};
|
|
3072
3167
|
};
|
|
3073
3168
|
|
|
3074
|
-
const selectPicks = [selectPick$
|
|
3075
|
-
const getPicks$2 = [getPicks$
|
|
3169
|
+
const selectPicks = [selectPick$a, selectPick$9, selectPick$8, selectPick$7, selectPickGoToColumn, selectPick$6, selectPick$5, selectPick$3, selectPick$2, selectPick$1, selectPick, selectPick$4];
|
|
3170
|
+
const getPicks$2 = [getPicks$d, getPicks$c, getPicks$b, getPicks$a, getPicksGoToColumn, getPicks$9, getPicks$8, getPicks$6, getPicks$5, getPicks$4, getPicks$3, getPicks$7];
|
|
3076
3171
|
|
|
3077
3172
|
const select = selectPicks;
|
|
3078
3173
|
const getPick$1 = getPicks$2;
|
|
@@ -3148,7 +3243,7 @@ const setValue = async (state, newValue) => {
|
|
|
3148
3243
|
}
|
|
3149
3244
|
const prefix = getQuickPickPrefix(newValue);
|
|
3150
3245
|
const subId = getQuickPickSubProviderId(providerId, prefix);
|
|
3151
|
-
const newPicks = await getPicks(subId, newValue, args, {
|
|
3246
|
+
const newPicks = subId === LanguageMode$1 ? state.picks : await getPicks(subId, newValue, args, {
|
|
3152
3247
|
assetDir,
|
|
3153
3248
|
platform
|
|
3154
3249
|
});
|
|
@@ -3296,102 +3391,11 @@ const getPick = (items, index) => {
|
|
|
3296
3391
|
return undefined;
|
|
3297
3392
|
};
|
|
3298
3393
|
|
|
3299
|
-
const createCustomPick = value => {
|
|
3300
|
-
return {
|
|
3301
|
-
description: '',
|
|
3302
|
-
direntType: 0,
|
|
3303
|
-
fileIcon: '',
|
|
3304
|
-
icon: '',
|
|
3305
|
-
label: value,
|
|
3306
|
-
matches: [],
|
|
3307
|
-
uri: ''
|
|
3308
|
-
};
|
|
3309
|
-
};
|
|
3310
|
-
const selectIndex = async (state, index, button = /* left */0) => {
|
|
3311
|
-
const {
|
|
3312
|
-
items,
|
|
3313
|
-
minLineY,
|
|
3314
|
-
providerId,
|
|
3315
|
-
value
|
|
3316
|
-
} = state;
|
|
3317
|
-
const actualIndex = index + minLineY;
|
|
3318
|
-
const prefix = getQuickPickPrefix(value);
|
|
3319
|
-
const subId = getQuickPickSubProviderId(providerId, prefix);
|
|
3320
|
-
const pick = getPick(items, actualIndex) || (subId === Custom$1 ? createCustomPick(value) : undefined);
|
|
3321
|
-
if (!pick) {
|
|
3322
|
-
return state;
|
|
3323
|
-
}
|
|
3324
|
-
const fn = getSelect(subId);
|
|
3325
|
-
const selectPickResult = await fn(pick, value);
|
|
3326
|
-
object(selectPickResult);
|
|
3327
|
-
string(selectPickResult.command);
|
|
3328
|
-
const {
|
|
3329
|
-
command
|
|
3330
|
-
} = selectPickResult;
|
|
3331
|
-
switch (command) {
|
|
3332
|
-
case Hide:
|
|
3333
|
-
await closeWidget(state.uid);
|
|
3334
|
-
return state;
|
|
3335
|
-
default:
|
|
3336
|
-
return state;
|
|
3337
|
-
}
|
|
3338
|
-
|
|
3339
|
-
// TODO recent picks should be per provider
|
|
3340
|
-
// if (!state.recentPickIds.has(pick.id)) {
|
|
3341
|
-
// state.recentPicks.unshift(pick)
|
|
3342
|
-
// state.recentPickIds.add(pick.id)
|
|
3343
|
-
// }
|
|
3344
|
-
// if (state.recentPicks.length > RECENT_PICKS_MAX_SIZE) {
|
|
3345
|
-
// const last = state.recentPicks.pop()
|
|
3346
|
-
// state.recentPickIds.delete(last.id)
|
|
3347
|
-
// }
|
|
3348
|
-
};
|
|
3349
|
-
|
|
3350
|
-
const handleClickAt = (state, x, y) => {
|
|
3351
|
-
const {
|
|
3352
|
-
headerHeight,
|
|
3353
|
-
itemHeight,
|
|
3354
|
-
top
|
|
3355
|
-
} = state;
|
|
3356
|
-
const index = getIndex(top, headerHeight, itemHeight, y);
|
|
3357
|
-
return selectIndex(state, index);
|
|
3358
|
-
};
|
|
3359
|
-
|
|
3360
|
-
const handleFocus = async state => {
|
|
3361
|
-
// TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
|
|
3362
|
-
await setFocus(FocusQuickPickInput);
|
|
3363
|
-
// await CloseWidget.closeWidget(state.uid)
|
|
3364
|
-
return state;
|
|
3365
|
-
};
|
|
3366
|
-
|
|
3367
|
-
const commandMapRef = {};
|
|
3368
|
-
|
|
3369
|
-
const handleMessagePort = async port => {
|
|
3370
|
-
const rpc = await create$8({
|
|
3371
|
-
commandMap: commandMapRef,
|
|
3372
|
-
isMessagePortOpen: true,
|
|
3373
|
-
messagePort: port
|
|
3374
|
-
});
|
|
3375
|
-
set(rpc);
|
|
3376
|
-
};
|
|
3377
|
-
|
|
3378
|
-
const initialize = async () => {
|
|
3379
|
-
// not needed anymore
|
|
3380
|
-
};
|
|
3381
|
-
|
|
3382
|
-
const getDefaultValue = id => {
|
|
3383
|
-
switch (id) {
|
|
3384
|
-
case EveryThing$1:
|
|
3385
|
-
return Command;
|
|
3386
|
-
default:
|
|
3387
|
-
return '';
|
|
3388
|
-
}
|
|
3389
|
-
};
|
|
3390
|
-
|
|
3391
3394
|
const Commands = 'quickPick://commands';
|
|
3392
3395
|
const EveryThing = 'quickPick://everything';
|
|
3393
3396
|
const Recent = 'quickPick://recent';
|
|
3394
3397
|
const ColorTheme = 'quickPick://color-theme';
|
|
3398
|
+
const LanguageMode = 'quickPick://language-mode';
|
|
3395
3399
|
const Symbol$1 = 'quickPick://symbol';
|
|
3396
3400
|
const View = 'quickPick://view';
|
|
3397
3401
|
const Help = 'quickPick://help';
|
|
@@ -3399,6 +3403,18 @@ const WorkspaceSymbol = 'quickPick://workspace-symbol';
|
|
|
3399
3403
|
const Custom = 'quickPick://custom';
|
|
3400
3404
|
const GoToLine = 'quickPick://go-to-line';
|
|
3401
3405
|
|
|
3406
|
+
const getDefaultValue = (id, uri = '') => {
|
|
3407
|
+
if (uri === WorkspaceSymbol) {
|
|
3408
|
+
return WorkspaceSymbol$1;
|
|
3409
|
+
}
|
|
3410
|
+
switch (id) {
|
|
3411
|
+
case EveryThing$1:
|
|
3412
|
+
return Command;
|
|
3413
|
+
default:
|
|
3414
|
+
return '';
|
|
3415
|
+
}
|
|
3416
|
+
};
|
|
3417
|
+
|
|
3402
3418
|
const getQuickPickProviderId = prefix => {
|
|
3403
3419
|
switch (prefix) {
|
|
3404
3420
|
case ColorTheme:
|
|
@@ -3413,6 +3429,8 @@ const getQuickPickProviderId = prefix => {
|
|
|
3413
3429
|
return EveryThing$1;
|
|
3414
3430
|
case Custom:
|
|
3415
3431
|
return Custom$1;
|
|
3432
|
+
case LanguageMode:
|
|
3433
|
+
return LanguageMode$1;
|
|
3416
3434
|
case Recent:
|
|
3417
3435
|
return Recent$1;
|
|
3418
3436
|
default:
|
|
@@ -3473,7 +3491,7 @@ const getLoadedState = async state => {
|
|
|
3473
3491
|
uri
|
|
3474
3492
|
} = state;
|
|
3475
3493
|
const id = getQuickPickProviderId(uri);
|
|
3476
|
-
const value = getDefaultValue(id);
|
|
3494
|
+
const value = getDefaultValue(id, uri);
|
|
3477
3495
|
const prefix = getQuickPickPrefix(value);
|
|
3478
3496
|
const subId = getQuickPickSubProviderId(id, prefix);
|
|
3479
3497
|
const newPicks = await getPicks(subId, value, args, {
|
|
@@ -3515,6 +3533,11 @@ const getLoadedState = async state => {
|
|
|
3515
3533
|
value: finalValue
|
|
3516
3534
|
};
|
|
3517
3535
|
};
|
|
3536
|
+
const loadContent = async state => {
|
|
3537
|
+
const newState = await getLoadedState(state);
|
|
3538
|
+
notifyVisible();
|
|
3539
|
+
return newState;
|
|
3540
|
+
};
|
|
3518
3541
|
const loadContentWithContext = async context => {
|
|
3519
3542
|
const state = context.getState();
|
|
3520
3543
|
const loadedState = await getLoadedState(state);
|
|
@@ -3540,6 +3563,96 @@ const loadContentWithContext = async context => {
|
|
|
3540
3563
|
notifyVisible();
|
|
3541
3564
|
};
|
|
3542
3565
|
|
|
3566
|
+
const createCustomPick = value => {
|
|
3567
|
+
return {
|
|
3568
|
+
description: '',
|
|
3569
|
+
direntType: 0,
|
|
3570
|
+
fileIcon: '',
|
|
3571
|
+
icon: '',
|
|
3572
|
+
label: value,
|
|
3573
|
+
matches: [],
|
|
3574
|
+
uri: ''
|
|
3575
|
+
};
|
|
3576
|
+
};
|
|
3577
|
+
const selectIndex = async (state, index, button = /* left */0) => {
|
|
3578
|
+
const {
|
|
3579
|
+
items,
|
|
3580
|
+
minLineY,
|
|
3581
|
+
providerId,
|
|
3582
|
+
value
|
|
3583
|
+
} = state;
|
|
3584
|
+
const actualIndex = index + minLineY;
|
|
3585
|
+
const prefix = getQuickPickPrefix(value);
|
|
3586
|
+
const subId = getQuickPickSubProviderId(providerId, prefix);
|
|
3587
|
+
const pick = getPick(items, actualIndex) || (subId === Custom$1 ? createCustomPick(value) : undefined);
|
|
3588
|
+
if (!pick) {
|
|
3589
|
+
return state;
|
|
3590
|
+
}
|
|
3591
|
+
const fn = getSelect(subId);
|
|
3592
|
+
const selectPickResult = await fn(pick, value);
|
|
3593
|
+
object(selectPickResult);
|
|
3594
|
+
string(selectPickResult.command);
|
|
3595
|
+
const {
|
|
3596
|
+
command
|
|
3597
|
+
} = selectPickResult;
|
|
3598
|
+
switch (command) {
|
|
3599
|
+
case Hide:
|
|
3600
|
+
await closeWidget(state.uid);
|
|
3601
|
+
return state;
|
|
3602
|
+
case OpenLanguageMode:
|
|
3603
|
+
return loadContent({
|
|
3604
|
+
...state,
|
|
3605
|
+
args: [],
|
|
3606
|
+
uri: LanguageMode,
|
|
3607
|
+
value: ''
|
|
3608
|
+
});
|
|
3609
|
+
default:
|
|
3610
|
+
return state;
|
|
3611
|
+
}
|
|
3612
|
+
|
|
3613
|
+
// TODO recent picks should be per provider
|
|
3614
|
+
// if (!state.recentPickIds.has(pick.id)) {
|
|
3615
|
+
// state.recentPicks.unshift(pick)
|
|
3616
|
+
// state.recentPickIds.add(pick.id)
|
|
3617
|
+
// }
|
|
3618
|
+
// if (state.recentPicks.length > RECENT_PICKS_MAX_SIZE) {
|
|
3619
|
+
// const last = state.recentPicks.pop()
|
|
3620
|
+
// state.recentPickIds.delete(last.id)
|
|
3621
|
+
// }
|
|
3622
|
+
};
|
|
3623
|
+
|
|
3624
|
+
const handleClickAt = (state, x, y) => {
|
|
3625
|
+
const {
|
|
3626
|
+
headerHeight,
|
|
3627
|
+
itemHeight,
|
|
3628
|
+
top
|
|
3629
|
+
} = state;
|
|
3630
|
+
const index = getIndex(top, headerHeight, itemHeight, y);
|
|
3631
|
+
return selectIndex(state, index);
|
|
3632
|
+
};
|
|
3633
|
+
|
|
3634
|
+
const handleFocus = async state => {
|
|
3635
|
+
// TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
|
|
3636
|
+
await setFocus(FocusQuickPickInput);
|
|
3637
|
+
// await CloseWidget.closeWidget(state.uid)
|
|
3638
|
+
return state;
|
|
3639
|
+
};
|
|
3640
|
+
|
|
3641
|
+
const commandMapRef = {};
|
|
3642
|
+
|
|
3643
|
+
const handleMessagePort = async port => {
|
|
3644
|
+
const rpc = await create$8({
|
|
3645
|
+
commandMap: commandMapRef,
|
|
3646
|
+
isMessagePortOpen: true,
|
|
3647
|
+
messagePort: port
|
|
3648
|
+
});
|
|
3649
|
+
set(rpc);
|
|
3650
|
+
};
|
|
3651
|
+
|
|
3652
|
+
const initialize = async () => {
|
|
3653
|
+
// not needed anymore
|
|
3654
|
+
};
|
|
3655
|
+
|
|
3543
3656
|
const SetCursorOffset = 'setCursorOffset';
|
|
3544
3657
|
const SetFocusedIndex = 'setFocusedIndex';
|
|
3545
3658
|
const SetItemsHeight = 'setItemsHeight';
|
|
@@ -4459,6 +4572,16 @@ const initializeEditorWorker = async () => {
|
|
|
4459
4572
|
await sendMessagePortToEditorWorker(port, 0);
|
|
4460
4573
|
}
|
|
4461
4574
|
});
|
|
4575
|
+
set$5(rpc);
|
|
4576
|
+
};
|
|
4577
|
+
|
|
4578
|
+
const initializeExtensionManagementWorker = async () => {
|
|
4579
|
+
const rpc = await create$6({
|
|
4580
|
+
commandMap: {},
|
|
4581
|
+
async send(port) {
|
|
4582
|
+
await sendMessagePortToExtensionManagementWorker(port, 0);
|
|
4583
|
+
}
|
|
4584
|
+
});
|
|
4462
4585
|
set$4(rpc);
|
|
4463
4586
|
};
|
|
4464
4587
|
|
|
@@ -4482,7 +4605,7 @@ const initializeRendererWorker = async () => {
|
|
|
4482
4605
|
const listen = async () => {
|
|
4483
4606
|
Object.assign(commandMapRef, commandMap);
|
|
4484
4607
|
registerCommands(commandMap);
|
|
4485
|
-
await Promise.all([initializeRendererWorker(), initializeEditorWorker(), initializeFileSearchWorker()]);
|
|
4608
|
+
await Promise.all([initializeRendererWorker(), initializeEditorWorker(), initializeExtensionManagementWorker(), initializeFileSearchWorker()]);
|
|
4486
4609
|
};
|
|
4487
4610
|
|
|
4488
4611
|
const main = async () => {
|