@lvce-editor/file-search-worker 7.6.0 → 8.1.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/README.md +12 -3
- package/dist/fileSearchWorkerMain.js +259 -3158
- package/package.json +5 -2
|
@@ -54,2064 +54,6 @@ class VError extends Error {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
class AssertionError extends Error {
|
|
58
|
-
constructor(message) {
|
|
59
|
-
super(message);
|
|
60
|
-
this.name = 'AssertionError';
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
const Object$1 = 1;
|
|
64
|
-
const Number$1 = 2;
|
|
65
|
-
const Array$1 = 3;
|
|
66
|
-
const String$1 = 4;
|
|
67
|
-
const Boolean$1 = 5;
|
|
68
|
-
const Function = 6;
|
|
69
|
-
const Null = 7;
|
|
70
|
-
const Unknown = 8;
|
|
71
|
-
const getType = value => {
|
|
72
|
-
switch (typeof value) {
|
|
73
|
-
case 'number':
|
|
74
|
-
return Number$1;
|
|
75
|
-
case 'function':
|
|
76
|
-
return Function;
|
|
77
|
-
case 'string':
|
|
78
|
-
return String$1;
|
|
79
|
-
case 'object':
|
|
80
|
-
if (value === null) {
|
|
81
|
-
return Null;
|
|
82
|
-
}
|
|
83
|
-
if (Array.isArray(value)) {
|
|
84
|
-
return Array$1;
|
|
85
|
-
}
|
|
86
|
-
return Object$1;
|
|
87
|
-
case 'boolean':
|
|
88
|
-
return Boolean$1;
|
|
89
|
-
default:
|
|
90
|
-
return Unknown;
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const object = value => {
|
|
94
|
-
const type = getType(value);
|
|
95
|
-
if (type !== Object$1) {
|
|
96
|
-
throw new AssertionError('expected value to be of type object');
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
const number = value => {
|
|
100
|
-
const type = getType(value);
|
|
101
|
-
if (type !== Number$1) {
|
|
102
|
-
throw new AssertionError('expected value to be of type number');
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
const array = value => {
|
|
106
|
-
const type = getType(value);
|
|
107
|
-
if (type !== Array$1) {
|
|
108
|
-
throw new AssertionError('expected value to be of type array');
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
const string = value => {
|
|
112
|
-
const type = getType(value);
|
|
113
|
-
if (type !== String$1) {
|
|
114
|
-
throw new AssertionError('expected value to be of type string');
|
|
115
|
-
}
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
class CommandNotFoundError extends Error {
|
|
119
|
-
constructor(command) {
|
|
120
|
-
super(`Command not found ${command}`);
|
|
121
|
-
this.name = 'CommandNotFoundError';
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
const commands = Object.create(null);
|
|
125
|
-
const register$1 = commandMap => {
|
|
126
|
-
Object.assign(commands, commandMap);
|
|
127
|
-
};
|
|
128
|
-
const getCommand = key => {
|
|
129
|
-
return commands[key];
|
|
130
|
-
};
|
|
131
|
-
const execute = (command, ...args) => {
|
|
132
|
-
const fn = getCommand(command);
|
|
133
|
-
if (!fn) {
|
|
134
|
-
throw new CommandNotFoundError(command);
|
|
135
|
-
}
|
|
136
|
-
return fn(...args);
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
const createMockRpc = ({
|
|
140
|
-
commandMap
|
|
141
|
-
}) => {
|
|
142
|
-
const invocations = [];
|
|
143
|
-
const invoke = (method, ...params) => {
|
|
144
|
-
invocations.push([method, ...params]);
|
|
145
|
-
const command = commandMap[method];
|
|
146
|
-
if (!command) {
|
|
147
|
-
throw new Error(`command ${method} not found`);
|
|
148
|
-
}
|
|
149
|
-
return command(...params);
|
|
150
|
-
};
|
|
151
|
-
const mockRpc = {
|
|
152
|
-
invocations,
|
|
153
|
-
invoke,
|
|
154
|
-
invokeAndTransfer: invoke
|
|
155
|
-
};
|
|
156
|
-
return mockRpc;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
const rpcs = Object.create(null);
|
|
160
|
-
const set$3 = (id, rpc) => {
|
|
161
|
-
rpcs[id] = rpc;
|
|
162
|
-
};
|
|
163
|
-
const get$2 = id => {
|
|
164
|
-
return rpcs[id];
|
|
165
|
-
};
|
|
166
|
-
const remove$1 = id => {
|
|
167
|
-
delete rpcs[id];
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
171
|
-
const create$b = rpcId => {
|
|
172
|
-
return {
|
|
173
|
-
async dispose() {
|
|
174
|
-
const rpc = get$2(rpcId);
|
|
175
|
-
await rpc.dispose();
|
|
176
|
-
},
|
|
177
|
-
// @ts-ignore
|
|
178
|
-
invoke(method, ...params) {
|
|
179
|
-
const rpc = get$2(rpcId);
|
|
180
|
-
// @ts-ignore
|
|
181
|
-
return rpc.invoke(method, ...params);
|
|
182
|
-
},
|
|
183
|
-
// @ts-ignore
|
|
184
|
-
invokeAndTransfer(method, ...params) {
|
|
185
|
-
const rpc = get$2(rpcId);
|
|
186
|
-
// @ts-ignore
|
|
187
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
188
|
-
},
|
|
189
|
-
registerMockRpc(commandMap) {
|
|
190
|
-
const mockRpc = createMockRpc({
|
|
191
|
-
commandMap
|
|
192
|
-
});
|
|
193
|
-
set$3(rpcId, mockRpc);
|
|
194
|
-
// @ts-ignore
|
|
195
|
-
mockRpc[Symbol.dispose] = () => {
|
|
196
|
-
remove$1(rpcId);
|
|
197
|
-
};
|
|
198
|
-
// @ts-ignore
|
|
199
|
-
return mockRpc;
|
|
200
|
-
},
|
|
201
|
-
set(rpc) {
|
|
202
|
-
set$3(rpcId, rpc);
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
const EditorWorker = 99;
|
|
208
|
-
const RendererWorker = 1;
|
|
209
|
-
|
|
210
|
-
const SetDom2 = 'Viewlet.setDom2';
|
|
211
|
-
const SetPatches = 'Viewlet.setPatches';
|
|
212
|
-
|
|
213
|
-
const FocusQuickPickInput = 20;
|
|
214
|
-
|
|
215
|
-
const {
|
|
216
|
-
invoke: invoke$2,
|
|
217
|
-
set: set$2
|
|
218
|
-
} = create$b(EditorWorker);
|
|
219
|
-
const getLines = async editorUid => {
|
|
220
|
-
const lines = await invoke$2('Editor.getLines2', editorUid);
|
|
221
|
-
return lines;
|
|
222
|
-
};
|
|
223
|
-
|
|
224
|
-
const {
|
|
225
|
-
invoke: invoke$1,
|
|
226
|
-
invokeAndTransfer,
|
|
227
|
-
set: set$1
|
|
228
|
-
} = create$b(RendererWorker);
|
|
229
|
-
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
230
|
-
const command = 'HandleMessagePort.handleMessagePort';
|
|
231
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
232
|
-
};
|
|
233
|
-
const setFocus = key => {
|
|
234
|
-
return invoke$1('Focus.setFocus', key);
|
|
235
|
-
};
|
|
236
|
-
const getFileIcon = async options => {
|
|
237
|
-
return invoke$1('IconTheme.getFileIcon', options);
|
|
238
|
-
};
|
|
239
|
-
const getFolderIcon = async options => {
|
|
240
|
-
return invoke$1('IconTheme.getFolderIcon', options);
|
|
241
|
-
};
|
|
242
|
-
const closeWidget$1 = async widgetId => {
|
|
243
|
-
return invoke$1('Viewlet.closeWidget', widgetId);
|
|
244
|
-
};
|
|
245
|
-
const getActiveEditorId = () => {
|
|
246
|
-
return invoke$1('GetActiveEditor.getActiveEditorId');
|
|
247
|
-
};
|
|
248
|
-
const openUri$1 = async (uri, focus, options) => {
|
|
249
|
-
await invoke$1('Main.openUri', uri, focus, options);
|
|
250
|
-
};
|
|
251
|
-
const showErrorDialog$1 = async errorInfo => {
|
|
252
|
-
await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
|
|
253
|
-
};
|
|
254
|
-
|
|
255
|
-
const closeWidget = async id => {
|
|
256
|
-
// @ts-ignore
|
|
257
|
-
await closeWidget$1(id);
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const close = async state => {
|
|
261
|
-
await closeWidget(state.uid);
|
|
262
|
-
return state;
|
|
263
|
-
};
|
|
264
|
-
|
|
265
|
-
const User = 1;
|
|
266
|
-
const Script = 2;
|
|
267
|
-
|
|
268
|
-
const minimumSliderSize = 20;
|
|
269
|
-
|
|
270
|
-
const Default$1 = 0;
|
|
271
|
-
const Finished = 2;
|
|
272
|
-
|
|
273
|
-
const toCommandId = key => {
|
|
274
|
-
const dotIndex = key.indexOf('.');
|
|
275
|
-
return key.slice(dotIndex + 1);
|
|
276
|
-
};
|
|
277
|
-
const create$a = () => {
|
|
278
|
-
const states = Object.create(null);
|
|
279
|
-
const commandMapRef = {};
|
|
280
|
-
return {
|
|
281
|
-
clear() {
|
|
282
|
-
for (const key of Object.keys(states)) {
|
|
283
|
-
delete states[key];
|
|
284
|
-
}
|
|
285
|
-
},
|
|
286
|
-
diff(uid, modules, numbers) {
|
|
287
|
-
const {
|
|
288
|
-
newState,
|
|
289
|
-
oldState
|
|
290
|
-
} = states[uid];
|
|
291
|
-
const diffResult = [];
|
|
292
|
-
for (let i = 0; i < modules.length; i++) {
|
|
293
|
-
const fn = modules[i];
|
|
294
|
-
if (!fn(oldState, newState)) {
|
|
295
|
-
diffResult.push(numbers[i]);
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
return diffResult;
|
|
299
|
-
},
|
|
300
|
-
dispose(uid) {
|
|
301
|
-
delete states[uid];
|
|
302
|
-
},
|
|
303
|
-
get(uid) {
|
|
304
|
-
return states[uid];
|
|
305
|
-
},
|
|
306
|
-
getCommandIds() {
|
|
307
|
-
const keys = Object.keys(commandMapRef);
|
|
308
|
-
const ids = keys.map(toCommandId);
|
|
309
|
-
return ids;
|
|
310
|
-
},
|
|
311
|
-
getKeys() {
|
|
312
|
-
return Object.keys(states).map(key => {
|
|
313
|
-
return Number.parseFloat(key);
|
|
314
|
-
});
|
|
315
|
-
},
|
|
316
|
-
registerCommands(commandMap) {
|
|
317
|
-
Object.assign(commandMapRef, commandMap);
|
|
318
|
-
},
|
|
319
|
-
set(uid, oldState, newState) {
|
|
320
|
-
states[uid] = {
|
|
321
|
-
newState,
|
|
322
|
-
oldState
|
|
323
|
-
};
|
|
324
|
-
},
|
|
325
|
-
wrapCommand(fn) {
|
|
326
|
-
const wrapped = async (uid, ...args) => {
|
|
327
|
-
const {
|
|
328
|
-
newState,
|
|
329
|
-
oldState
|
|
330
|
-
} = states[uid];
|
|
331
|
-
const newerState = await fn(newState, ...args);
|
|
332
|
-
if (oldState === newerState || newState === newerState) {
|
|
333
|
-
return;
|
|
334
|
-
}
|
|
335
|
-
const latestOld = states[uid];
|
|
336
|
-
const latestNew = {
|
|
337
|
-
...latestOld.newState,
|
|
338
|
-
...newerState
|
|
339
|
-
};
|
|
340
|
-
states[uid] = {
|
|
341
|
-
newState: latestNew,
|
|
342
|
-
oldState: latestOld.oldState
|
|
343
|
-
};
|
|
344
|
-
};
|
|
345
|
-
return wrapped;
|
|
346
|
-
},
|
|
347
|
-
wrapGetter(fn) {
|
|
348
|
-
const wrapped = (uid, ...args) => {
|
|
349
|
-
const {
|
|
350
|
-
newState
|
|
351
|
-
} = states[uid];
|
|
352
|
-
return fn(newState, ...args);
|
|
353
|
-
};
|
|
354
|
-
return wrapped;
|
|
355
|
-
},
|
|
356
|
-
wrapLoadContent(fn) {
|
|
357
|
-
const wrapped = async (uid, ...args) => {
|
|
358
|
-
const {
|
|
359
|
-
newState,
|
|
360
|
-
oldState
|
|
361
|
-
} = states[uid];
|
|
362
|
-
const result = await fn(newState, ...args);
|
|
363
|
-
const {
|
|
364
|
-
error,
|
|
365
|
-
state
|
|
366
|
-
} = result;
|
|
367
|
-
if (oldState === state || newState === state) {
|
|
368
|
-
return {
|
|
369
|
-
error
|
|
370
|
-
};
|
|
371
|
-
}
|
|
372
|
-
const latestOld = states[uid];
|
|
373
|
-
const latestNew = {
|
|
374
|
-
...latestOld.newState,
|
|
375
|
-
...state
|
|
376
|
-
};
|
|
377
|
-
states[uid] = {
|
|
378
|
-
newState: latestNew,
|
|
379
|
-
oldState: latestOld.oldState
|
|
380
|
-
};
|
|
381
|
-
return {
|
|
382
|
-
error
|
|
383
|
-
};
|
|
384
|
-
};
|
|
385
|
-
return wrapped;
|
|
386
|
-
}
|
|
387
|
-
};
|
|
388
|
-
};
|
|
389
|
-
|
|
390
|
-
const {
|
|
391
|
-
dispose: dispose$1,
|
|
392
|
-
get: get$1,
|
|
393
|
-
getCommandIds,
|
|
394
|
-
registerCommands,
|
|
395
|
-
set,
|
|
396
|
-
wrapCommand
|
|
397
|
-
} = create$a();
|
|
398
|
-
|
|
399
|
-
const create$9 = ({
|
|
400
|
-
headerHeight = 0,
|
|
401
|
-
itemHeight,
|
|
402
|
-
minimumSliderSize = 20
|
|
403
|
-
}) => {
|
|
404
|
-
return {
|
|
405
|
-
deltaY: 0,
|
|
406
|
-
finalDeltaY: 0,
|
|
407
|
-
focusedIndex: -1,
|
|
408
|
-
headerHeight,
|
|
409
|
-
itemHeight,
|
|
410
|
-
items: [],
|
|
411
|
-
maxLineY: 0,
|
|
412
|
-
minimumSliderSize,
|
|
413
|
-
minLineY: 0,
|
|
414
|
-
scrollBarActive: false,
|
|
415
|
-
scrollBarHeight: 0,
|
|
416
|
-
touchDifference: 0,
|
|
417
|
-
touchOffsetY: 0,
|
|
418
|
-
touchTimeStamp: 0
|
|
419
|
-
};
|
|
420
|
-
};
|
|
421
|
-
const getListHeight$1 = (height, headerHeight) => {
|
|
422
|
-
if (headerHeight) {
|
|
423
|
-
return height - headerHeight;
|
|
424
|
-
}
|
|
425
|
-
return headerHeight;
|
|
426
|
-
};
|
|
427
|
-
const setDeltaY = (state, deltaY) => {
|
|
428
|
-
object(state);
|
|
429
|
-
number(deltaY);
|
|
430
|
-
const {
|
|
431
|
-
headerHeight,
|
|
432
|
-
height,
|
|
433
|
-
itemHeight,
|
|
434
|
-
items
|
|
435
|
-
} = state;
|
|
436
|
-
const listHeight = getListHeight$1(height, headerHeight);
|
|
437
|
-
const itemsLength = items.length;
|
|
438
|
-
const finalDeltaY = itemsLength * itemHeight - listHeight;
|
|
439
|
-
if (deltaY < 0) {
|
|
440
|
-
deltaY = 0;
|
|
441
|
-
} else if (deltaY > finalDeltaY) {
|
|
442
|
-
deltaY = Math.max(finalDeltaY, 0);
|
|
443
|
-
}
|
|
444
|
-
if (state.deltaY === deltaY) {
|
|
445
|
-
return state;
|
|
446
|
-
}
|
|
447
|
-
const minLineY = Math.round(deltaY / itemHeight);
|
|
448
|
-
const maxLineY = minLineY + Math.round(listHeight / itemHeight);
|
|
449
|
-
number(minLineY);
|
|
450
|
-
number(maxLineY);
|
|
451
|
-
return {
|
|
452
|
-
...state,
|
|
453
|
-
deltaY,
|
|
454
|
-
maxLineY,
|
|
455
|
-
minLineY
|
|
456
|
-
};
|
|
457
|
-
};
|
|
458
|
-
const handleWheel = (state, deltaMode, deltaY) => {
|
|
459
|
-
object(state);
|
|
460
|
-
number(deltaMode);
|
|
461
|
-
number(deltaY);
|
|
462
|
-
return setDeltaY(state, state.deltaY + deltaY);
|
|
463
|
-
};
|
|
464
|
-
|
|
465
|
-
const create$8 = (uid, uri, listItemHeight, x, y, width, height, platform, args, workspaceUri, assetDir) => {
|
|
466
|
-
const state = {
|
|
467
|
-
allowEmptyResult: false,
|
|
468
|
-
cursorOffset: 0,
|
|
469
|
-
height: 300,
|
|
470
|
-
icons: [],
|
|
471
|
-
initial: true,
|
|
472
|
-
maxVisibleItems: 12,
|
|
473
|
-
picks: [],
|
|
474
|
-
recentPickIds: Object.create(null),
|
|
475
|
-
recentPicks: [],
|
|
476
|
-
state: Default$1,
|
|
477
|
-
top: 50,
|
|
478
|
-
uid,
|
|
479
|
-
uri,
|
|
480
|
-
versionId: 0,
|
|
481
|
-
warned: [],
|
|
482
|
-
width: 600,
|
|
483
|
-
workspaceUri,
|
|
484
|
-
...create$9({
|
|
485
|
-
headerHeight: 38,
|
|
486
|
-
itemHeight: listItemHeight,
|
|
487
|
-
minimumSliderSize: minimumSliderSize
|
|
488
|
-
}),
|
|
489
|
-
args,
|
|
490
|
-
assetDir,
|
|
491
|
-
fileIconCache: Object.create(null),
|
|
492
|
-
focused: false,
|
|
493
|
-
inputSource: User,
|
|
494
|
-
placeholder: '',
|
|
495
|
-
platform,
|
|
496
|
-
value: ''
|
|
497
|
-
};
|
|
498
|
-
set(uid, state, state);
|
|
499
|
-
};
|
|
500
|
-
|
|
501
|
-
const RenderItems = 1;
|
|
502
|
-
const RenderIncremental = 10;
|
|
503
|
-
const RenderFocus = 2;
|
|
504
|
-
const RenderValue = 3;
|
|
505
|
-
const RenderCursorOffset = 7;
|
|
506
|
-
const RenderFocusedIndex = 8;
|
|
507
|
-
const Height = 9;
|
|
508
|
-
|
|
509
|
-
const isEqual$4 = (oldState, newState) => {
|
|
510
|
-
return oldState.focused === newState.focused;
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
const isEqual$3 = (oldState, newState) => {
|
|
514
|
-
return oldState.focusedIndex === newState.focusedIndex;
|
|
515
|
-
};
|
|
516
|
-
|
|
517
|
-
const isEqual$2 = (oldState, newState) => {
|
|
518
|
-
return oldState.items.length === newState.items.length;
|
|
519
|
-
};
|
|
520
|
-
|
|
521
|
-
const isEqual$1 = (oldState, newState) => {
|
|
522
|
-
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
const diffType = RenderValue;
|
|
526
|
-
const isEqual = (oldState, newState) => {
|
|
527
|
-
return newState.inputSource === User || oldState.value === newState.value;
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
const modules = [isEqual$2, isEqual$1, isEqual, isEqual$3, isEqual$4];
|
|
531
|
-
const numbers = [Height, RenderItems, diffType, RenderFocusedIndex, RenderFocus];
|
|
532
|
-
|
|
533
|
-
const diff = (oldState, newState) => {
|
|
534
|
-
const diffResult = [];
|
|
535
|
-
for (let i = 0; i < modules.length; i++) {
|
|
536
|
-
const fn = modules[i];
|
|
537
|
-
if (!fn(oldState, newState)) {
|
|
538
|
-
diffResult.push(numbers[i]);
|
|
539
|
-
}
|
|
540
|
-
}
|
|
541
|
-
return diffResult;
|
|
542
|
-
};
|
|
543
|
-
|
|
544
|
-
const diff2 = uid => {
|
|
545
|
-
const {
|
|
546
|
-
newState,
|
|
547
|
-
oldState
|
|
548
|
-
} = get$1(uid);
|
|
549
|
-
return diff(oldState, newState);
|
|
550
|
-
};
|
|
551
|
-
|
|
552
|
-
const dispose = uid => {
|
|
553
|
-
dispose$1(uid);
|
|
554
|
-
};
|
|
555
|
-
|
|
556
|
-
const setColorTheme = id => {
|
|
557
|
-
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
558
|
-
};
|
|
559
|
-
|
|
560
|
-
const focusPick$1 = async pick => {
|
|
561
|
-
const {
|
|
562
|
-
label
|
|
563
|
-
} = pick;
|
|
564
|
-
await setColorTheme(label);
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
const ColorTheme$1 = 0;
|
|
568
|
-
const Commands$1 = 1;
|
|
569
|
-
const Custom$2 = 2;
|
|
570
|
-
const File$2 = 3;
|
|
571
|
-
const GoToColumn$1 = 4;
|
|
572
|
-
const GoToLine$2 = 5;
|
|
573
|
-
const Help$2 = 6;
|
|
574
|
-
const Recent$1 = 7;
|
|
575
|
-
const Symbol$3 = 8;
|
|
576
|
-
const View$3 = 9;
|
|
577
|
-
const WorkspaceSymbol$2 = 10;
|
|
578
|
-
const EveryThing$1 = 100;
|
|
579
|
-
|
|
580
|
-
const noop$1 = async () => {};
|
|
581
|
-
const getFn$2 = id => {
|
|
582
|
-
switch (id) {
|
|
583
|
-
case ColorTheme$1:
|
|
584
|
-
return focusPick$1;
|
|
585
|
-
default:
|
|
586
|
-
return noop$1;
|
|
587
|
-
}
|
|
588
|
-
};
|
|
589
|
-
const focusPick = (id, pick) => {
|
|
590
|
-
const fn = getFn$2(id);
|
|
591
|
-
return fn(pick);
|
|
592
|
-
};
|
|
593
|
-
|
|
594
|
-
const getIconsCached = (paths, fileIconCache) => {
|
|
595
|
-
return paths.map(path => fileIconCache[path]);
|
|
596
|
-
};
|
|
597
|
-
|
|
598
|
-
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
599
|
-
const missingRequests = [];
|
|
600
|
-
for (const dirent of dirents) {
|
|
601
|
-
if (!dirent.path) {
|
|
602
|
-
continue;
|
|
603
|
-
}
|
|
604
|
-
if (!(dirent.path in fileIconCache)) {
|
|
605
|
-
missingRequests.push({
|
|
606
|
-
name: dirent.name,
|
|
607
|
-
path: dirent.path,
|
|
608
|
-
type: dirent.type
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
return missingRequests;
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
const None$2 = 0;
|
|
616
|
-
const Directory = 3;
|
|
617
|
-
const File$1 = 7;
|
|
618
|
-
|
|
619
|
-
const requestFileIcon = async request => {
|
|
620
|
-
if (!request.name) {
|
|
621
|
-
return '';
|
|
622
|
-
}
|
|
623
|
-
return request.type === File$1 ? getFileIcon({
|
|
624
|
-
name: request.name
|
|
625
|
-
}) : getFolderIcon({
|
|
626
|
-
name: request.name
|
|
627
|
-
});
|
|
628
|
-
};
|
|
629
|
-
const requestFileIcons = async requests => {
|
|
630
|
-
const promises = requests.map(requestFileIcon);
|
|
631
|
-
return Promise.all(promises);
|
|
632
|
-
};
|
|
633
|
-
|
|
634
|
-
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
635
|
-
if (missingRequests.length === 0) {
|
|
636
|
-
return iconCache;
|
|
637
|
-
}
|
|
638
|
-
const newFileIconCache = {
|
|
639
|
-
...iconCache
|
|
640
|
-
};
|
|
641
|
-
for (let i = 0; i < missingRequests.length; i++) {
|
|
642
|
-
const request = missingRequests[i];
|
|
643
|
-
const icon = newIcons[i];
|
|
644
|
-
newFileIconCache[request.path] = icon;
|
|
645
|
-
}
|
|
646
|
-
return newFileIconCache;
|
|
647
|
-
};
|
|
648
|
-
|
|
649
|
-
const getPath = dirent => {
|
|
650
|
-
return dirent.path;
|
|
651
|
-
};
|
|
652
|
-
const toDirent = pick => {
|
|
653
|
-
const dirent = {
|
|
654
|
-
name: pick.label,
|
|
655
|
-
path: pick.uri,
|
|
656
|
-
type: pick.direntType
|
|
657
|
-
};
|
|
658
|
-
return dirent;
|
|
659
|
-
};
|
|
660
|
-
const getQuickPickFileIcons = async (items, fileIconCache) => {
|
|
661
|
-
const dirents = items.map(toDirent);
|
|
662
|
-
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
663
|
-
const newIcons = await requestFileIcons(missingRequests);
|
|
664
|
-
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
665
|
-
const paths = dirents.map(getPath);
|
|
666
|
-
const icons = getIconsCached(paths, newFileIconCache);
|
|
667
|
-
return {
|
|
668
|
-
icons,
|
|
669
|
-
newFileIconCache
|
|
670
|
-
};
|
|
671
|
-
};
|
|
672
|
-
|
|
673
|
-
const focusIndex = async (state, index) => {
|
|
674
|
-
const {
|
|
675
|
-
fileIconCache,
|
|
676
|
-
items,
|
|
677
|
-
maxLineY,
|
|
678
|
-
maxVisibleItems,
|
|
679
|
-
minLineY,
|
|
680
|
-
providerId
|
|
681
|
-
} = state;
|
|
682
|
-
await focusPick(providerId, items[index]);
|
|
683
|
-
if (index < minLineY + 1) {
|
|
684
|
-
const minLineY = index;
|
|
685
|
-
const maxLineY = Math.min(index + maxVisibleItems, items.length - 1);
|
|
686
|
-
const sliced = items.slice(minLineY, maxLineY);
|
|
687
|
-
const {
|
|
688
|
-
icons,
|
|
689
|
-
newFileIconCache
|
|
690
|
-
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
691
|
-
|
|
692
|
-
// TODO need to scroll up
|
|
693
|
-
return {
|
|
694
|
-
...state,
|
|
695
|
-
fileIconCache: newFileIconCache,
|
|
696
|
-
focusedIndex: index,
|
|
697
|
-
icons,
|
|
698
|
-
maxLineY,
|
|
699
|
-
minLineY
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
if (index >= maxLineY - 1) {
|
|
703
|
-
// TODO need to scroll down
|
|
704
|
-
const maxLineY = index + 1;
|
|
705
|
-
const minLineY = Math.max(maxLineY - maxVisibleItems, 0);
|
|
706
|
-
const sliced = items.slice(minLineY, maxLineY);
|
|
707
|
-
const {
|
|
708
|
-
icons,
|
|
709
|
-
newFileIconCache
|
|
710
|
-
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
711
|
-
return {
|
|
712
|
-
...state,
|
|
713
|
-
fileIconCache: newFileIconCache,
|
|
714
|
-
focusedIndex: index,
|
|
715
|
-
icons,
|
|
716
|
-
maxLineY,
|
|
717
|
-
minLineY
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
const sliced = items.slice(minLineY, maxLineY);
|
|
721
|
-
const {
|
|
722
|
-
icons,
|
|
723
|
-
newFileIconCache
|
|
724
|
-
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
725
|
-
return {
|
|
726
|
-
...state,
|
|
727
|
-
fileIconCache: newFileIconCache,
|
|
728
|
-
focusedIndex: index,
|
|
729
|
-
icons
|
|
730
|
-
};
|
|
731
|
-
};
|
|
732
|
-
|
|
733
|
-
const first = () => {
|
|
734
|
-
return 0;
|
|
735
|
-
};
|
|
736
|
-
const last = items => {
|
|
737
|
-
return items.length - 1;
|
|
738
|
-
};
|
|
739
|
-
const next = (items, index) => {
|
|
740
|
-
return (index + 1) % items.length;
|
|
741
|
-
};
|
|
742
|
-
const previous = (items, index) => {
|
|
743
|
-
return index === 0 ? items.length - 1 : index - 1;
|
|
744
|
-
};
|
|
745
|
-
|
|
746
|
-
const focusFirst = state => {
|
|
747
|
-
return focusIndex(state, first());
|
|
748
|
-
};
|
|
749
|
-
|
|
750
|
-
const focusLast = state => {
|
|
751
|
-
const {
|
|
752
|
-
items
|
|
753
|
-
} = state;
|
|
754
|
-
return focusIndex(state, last(items));
|
|
755
|
-
};
|
|
756
|
-
|
|
757
|
-
const focusNext = state => {
|
|
758
|
-
const {
|
|
759
|
-
focusedIndex,
|
|
760
|
-
items
|
|
761
|
-
} = state;
|
|
762
|
-
const nextIndex = next(items, focusedIndex);
|
|
763
|
-
return focusIndex(state, nextIndex);
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
const focusPrevious = state => {
|
|
767
|
-
const {
|
|
768
|
-
focusedIndex,
|
|
769
|
-
items
|
|
770
|
-
} = state;
|
|
771
|
-
const previousIndex = previous(items, focusedIndex);
|
|
772
|
-
return focusIndex(state, previousIndex);
|
|
773
|
-
};
|
|
774
|
-
|
|
775
|
-
const Enter = 3;
|
|
776
|
-
const Escape = 8;
|
|
777
|
-
const PageUp = 10;
|
|
778
|
-
const PageDown = 11;
|
|
779
|
-
const UpArrow = 14;
|
|
780
|
-
const DownArrow = 16;
|
|
781
|
-
|
|
782
|
-
const getKeyBindings = () => {
|
|
783
|
-
return [{
|
|
784
|
-
args: ['QuickPick'],
|
|
785
|
-
command: 'Viewlet.closeWidget',
|
|
786
|
-
key: Escape,
|
|
787
|
-
when: FocusQuickPickInput
|
|
788
|
-
}, {
|
|
789
|
-
command: 'QuickPick.focusPrevious',
|
|
790
|
-
key: UpArrow,
|
|
791
|
-
when: FocusQuickPickInput
|
|
792
|
-
}, {
|
|
793
|
-
command: 'QuickPick.focusNext',
|
|
794
|
-
key: DownArrow,
|
|
795
|
-
when: FocusQuickPickInput
|
|
796
|
-
}, {
|
|
797
|
-
command: 'QuickPick.focusFirst',
|
|
798
|
-
key: PageUp,
|
|
799
|
-
when: FocusQuickPickInput
|
|
800
|
-
}, {
|
|
801
|
-
command: 'QuickPick.focusLast',
|
|
802
|
-
key: PageDown,
|
|
803
|
-
when: FocusQuickPickInput
|
|
804
|
-
}, {
|
|
805
|
-
command: 'QuickPick.selectCurrentIndex',
|
|
806
|
-
key: Enter,
|
|
807
|
-
when: FocusQuickPickInput
|
|
808
|
-
}];
|
|
809
|
-
};
|
|
810
|
-
|
|
811
|
-
const getNewValueDeleteContentBackward = (value, selectionStart, selectionEnd, data) => {
|
|
812
|
-
const after = value.slice(selectionEnd);
|
|
813
|
-
if (selectionStart === selectionEnd) {
|
|
814
|
-
const before = value.slice(0, selectionStart - 1);
|
|
815
|
-
const newValue = before + after;
|
|
816
|
-
return {
|
|
817
|
-
cursorOffset: before.length,
|
|
818
|
-
newValue
|
|
819
|
-
};
|
|
820
|
-
}
|
|
821
|
-
const before = value.slice(0, selectionStart);
|
|
822
|
-
const newValue = before + after;
|
|
823
|
-
return {
|
|
824
|
-
cursorOffset: selectionStart,
|
|
825
|
-
newValue
|
|
826
|
-
};
|
|
827
|
-
};
|
|
828
|
-
|
|
829
|
-
const getNewValueDeleteContentForward = (value, selectionStart, selectionEnd, data) => {
|
|
830
|
-
const before = value.slice(0, selectionStart);
|
|
831
|
-
if (selectionStart === selectionEnd) {
|
|
832
|
-
const after = value.slice(selectionEnd + 1);
|
|
833
|
-
const newValue = before + after;
|
|
834
|
-
return {
|
|
835
|
-
cursorOffset: selectionStart,
|
|
836
|
-
newValue
|
|
837
|
-
};
|
|
838
|
-
}
|
|
839
|
-
const after = value.slice(selectionEnd);
|
|
840
|
-
const newValue = before + after;
|
|
841
|
-
return {
|
|
842
|
-
cursorOffset: selectionStart,
|
|
843
|
-
newValue
|
|
844
|
-
};
|
|
845
|
-
};
|
|
846
|
-
|
|
847
|
-
const RE_ALPHA_NUMERIC = /[a-z\d]/i;
|
|
848
|
-
const isAlphaNumeric = character => {
|
|
849
|
-
return RE_ALPHA_NUMERIC.test(character);
|
|
850
|
-
};
|
|
851
|
-
|
|
852
|
-
const getNewValueDeleteWordBackward = (value, selectionStart, selectionEnd, data) => {
|
|
853
|
-
const after = value.slice(selectionEnd);
|
|
854
|
-
if (selectionStart === selectionEnd) {
|
|
855
|
-
let startIndex = Math.max(selectionStart - 1, 0);
|
|
856
|
-
while (startIndex > 0 && isAlphaNumeric(value[startIndex])) {
|
|
857
|
-
startIndex--;
|
|
858
|
-
}
|
|
859
|
-
const before = value.slice(0, startIndex);
|
|
860
|
-
const newValue = before + after;
|
|
861
|
-
return {
|
|
862
|
-
cursorOffset: before.length,
|
|
863
|
-
newValue
|
|
864
|
-
};
|
|
865
|
-
}
|
|
866
|
-
const before = value.slice(0, selectionStart);
|
|
867
|
-
const newValue = before + after;
|
|
868
|
-
return {
|
|
869
|
-
cursorOffset: selectionStart,
|
|
870
|
-
newValue
|
|
871
|
-
};
|
|
872
|
-
};
|
|
873
|
-
|
|
874
|
-
const getNewValueDeleteWordForward = (value, selectionStart, selectionEnd, data) => {
|
|
875
|
-
const before = value.slice(0, selectionStart);
|
|
876
|
-
if (selectionStart === selectionEnd) {
|
|
877
|
-
let startIndex = Math.min(selectionStart + 1, value.length - 1);
|
|
878
|
-
while (startIndex < value.length && isAlphaNumeric(value[startIndex])) {
|
|
879
|
-
startIndex++;
|
|
880
|
-
}
|
|
881
|
-
const after = value.slice(startIndex);
|
|
882
|
-
const newValue = before + after;
|
|
883
|
-
return {
|
|
884
|
-
cursorOffset: before.length,
|
|
885
|
-
newValue
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
const after = value.slice(selectionEnd);
|
|
889
|
-
const newValue = before + after;
|
|
890
|
-
return {
|
|
891
|
-
cursorOffset: selectionStart,
|
|
892
|
-
newValue
|
|
893
|
-
};
|
|
894
|
-
};
|
|
895
|
-
|
|
896
|
-
const getNewValueInsertText = (value, selectionStart, selectionEnd, data) => {
|
|
897
|
-
if (selectionStart === value.length) {
|
|
898
|
-
const newValue = value + data;
|
|
899
|
-
return {
|
|
900
|
-
cursorOffset: newValue.length,
|
|
901
|
-
newValue
|
|
902
|
-
};
|
|
903
|
-
}
|
|
904
|
-
const before = value.slice(0, selectionStart);
|
|
905
|
-
const after = value.slice(selectionEnd);
|
|
906
|
-
const newValue = before + data + after;
|
|
907
|
-
return {
|
|
908
|
-
cursorOffset: selectionStart + data.length,
|
|
909
|
-
newValue
|
|
910
|
-
};
|
|
911
|
-
};
|
|
912
|
-
|
|
913
|
-
const getNewValueInsertCompositionText = (value, selectionStart, selectionEnd, data) => {
|
|
914
|
-
return getNewValueInsertText(value, selectionStart, selectionEnd, data);
|
|
915
|
-
};
|
|
916
|
-
|
|
917
|
-
const getNewValueInsertLineBreak = (value, selectionStart, selectionEnd, data) => {
|
|
918
|
-
return {
|
|
919
|
-
cursorOffset: selectionEnd,
|
|
920
|
-
newValue: value
|
|
921
|
-
};
|
|
922
|
-
};
|
|
923
|
-
|
|
924
|
-
const InsertText = 'insertText';
|
|
925
|
-
const DeleteContentBackward = 'deleteContentBackward';
|
|
926
|
-
const DeleteContentForward = 'deleteContentForward';
|
|
927
|
-
const DeleteWordForward = 'deleteWordForward';
|
|
928
|
-
const DeleteWordBackward = 'deleteWordBackward';
|
|
929
|
-
const InsertLineBreak = 'insertLineBreak';
|
|
930
|
-
const InsertCompositionText = 'insertCompositionText';
|
|
931
|
-
const InsertFromPaste = 'insertFromPaste';
|
|
932
|
-
|
|
933
|
-
const getNewValueFunction = inputType => {
|
|
934
|
-
switch (inputType) {
|
|
935
|
-
case DeleteContentBackward:
|
|
936
|
-
return getNewValueDeleteContentBackward;
|
|
937
|
-
case DeleteContentForward:
|
|
938
|
-
return getNewValueDeleteContentForward;
|
|
939
|
-
case DeleteWordBackward:
|
|
940
|
-
return getNewValueDeleteWordBackward;
|
|
941
|
-
case DeleteWordForward:
|
|
942
|
-
return getNewValueDeleteWordForward;
|
|
943
|
-
case InsertCompositionText:
|
|
944
|
-
return getNewValueInsertCompositionText;
|
|
945
|
-
case InsertFromPaste:
|
|
946
|
-
case InsertText:
|
|
947
|
-
return getNewValueInsertText;
|
|
948
|
-
case InsertLineBreak:
|
|
949
|
-
return getNewValueInsertLineBreak;
|
|
950
|
-
default:
|
|
951
|
-
throw new Error(`unsupported input type ${inputType}`);
|
|
952
|
-
}
|
|
953
|
-
};
|
|
954
|
-
|
|
955
|
-
const getNewValue = (value, inputType, data, selectionStart, selectionEnd) => {
|
|
956
|
-
const fn = getNewValueFunction(inputType);
|
|
957
|
-
return fn(value, selectionStart, selectionEnd, data);
|
|
958
|
-
};
|
|
959
|
-
|
|
960
|
-
const Diagonal = 1;
|
|
961
|
-
const Left = 2;
|
|
962
|
-
|
|
963
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
964
|
-
|
|
965
|
-
const createTable = size => {
|
|
966
|
-
const table = [];
|
|
967
|
-
for (let i = 0; i < size; i++) {
|
|
968
|
-
const row = new Uint8Array(size);
|
|
969
|
-
table.push(row);
|
|
970
|
-
}
|
|
971
|
-
return table;
|
|
972
|
-
};
|
|
973
|
-
const EmptyMatches = [];
|
|
974
|
-
const Dash = '-';
|
|
975
|
-
const Dot = '.';
|
|
976
|
-
const EmptyString = '';
|
|
977
|
-
const Space = ' ';
|
|
978
|
-
const Underline = '_';
|
|
979
|
-
const T = 't';
|
|
980
|
-
const isLowerCase = char => {
|
|
981
|
-
return char === char.toLowerCase();
|
|
982
|
-
};
|
|
983
|
-
const isUpperCase = char => {
|
|
984
|
-
return char === char.toUpperCase();
|
|
985
|
-
};
|
|
986
|
-
|
|
987
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
988
|
-
const isGap = (columnCharBefore, columnChar) => {
|
|
989
|
-
switch (columnCharBefore) {
|
|
990
|
-
case Dash:
|
|
991
|
-
case Underline:
|
|
992
|
-
case EmptyString:
|
|
993
|
-
case T:
|
|
994
|
-
case Space:
|
|
995
|
-
case Dot:
|
|
996
|
-
return true;
|
|
997
|
-
}
|
|
998
|
-
if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
|
|
999
|
-
return true;
|
|
1000
|
-
}
|
|
1001
|
-
return false;
|
|
1002
|
-
};
|
|
1003
|
-
|
|
1004
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1005
|
-
const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
|
|
1006
|
-
if (rowCharLow !== columnCharLow) {
|
|
1007
|
-
return -1;
|
|
1008
|
-
}
|
|
1009
|
-
const isMatch = rowChar === columnChar;
|
|
1010
|
-
if (isMatch) {
|
|
1011
|
-
if (isDiagonalMatch) {
|
|
1012
|
-
return 8;
|
|
1013
|
-
}
|
|
1014
|
-
if (isGap(columnCharBefore, columnChar)) {
|
|
1015
|
-
return 8;
|
|
1016
|
-
}
|
|
1017
|
-
return 5;
|
|
1018
|
-
}
|
|
1019
|
-
if (isGap(columnCharBefore, columnChar)) {
|
|
1020
|
-
return 8;
|
|
1021
|
-
}
|
|
1022
|
-
return 5;
|
|
1023
|
-
};
|
|
1024
|
-
|
|
1025
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1026
|
-
|
|
1027
|
-
const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
|
|
1028
|
-
while (patternPos < patternLen && wordPos < wordLen) {
|
|
1029
|
-
if (patternLow[patternPos] === wordLow[wordPos]) {
|
|
1030
|
-
patternPos += 1;
|
|
1031
|
-
}
|
|
1032
|
-
wordPos += 1;
|
|
1033
|
-
}
|
|
1034
|
-
return patternPos === patternLen; // pattern must be exhausted
|
|
1035
|
-
};
|
|
1036
|
-
|
|
1037
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1038
|
-
const traceHighlights = (table, arrows, patternLength, wordLength) => {
|
|
1039
|
-
let row = patternLength;
|
|
1040
|
-
let column = wordLength;
|
|
1041
|
-
const matches = [];
|
|
1042
|
-
while (row >= 1 && column >= 1) {
|
|
1043
|
-
const arrow = arrows[row][column];
|
|
1044
|
-
if (arrow === Left) {
|
|
1045
|
-
column--;
|
|
1046
|
-
} else if (arrow === Diagonal) {
|
|
1047
|
-
row--;
|
|
1048
|
-
column--;
|
|
1049
|
-
const start = column + 1;
|
|
1050
|
-
while (row >= 1 && column >= 1) {
|
|
1051
|
-
const arrow = arrows[row][column];
|
|
1052
|
-
if (arrow === Left) {
|
|
1053
|
-
break;
|
|
1054
|
-
}
|
|
1055
|
-
if (arrow === Diagonal) {
|
|
1056
|
-
row--;
|
|
1057
|
-
column--;
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
const end = column;
|
|
1061
|
-
matches.unshift(end, start);
|
|
1062
|
-
}
|
|
1063
|
-
}
|
|
1064
|
-
matches.unshift(table[patternLength][wordLength - 1]);
|
|
1065
|
-
return matches;
|
|
1066
|
-
};
|
|
1067
|
-
|
|
1068
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1069
|
-
const gridSize = 128;
|
|
1070
|
-
const table = createTable(gridSize);
|
|
1071
|
-
const arrows = createTable(gridSize);
|
|
1072
|
-
const fuzzySearch = (pattern, word) => {
|
|
1073
|
-
const patternLength = Math.min(pattern.length, gridSize - 1);
|
|
1074
|
-
const wordLength = Math.min(word.length, gridSize - 1);
|
|
1075
|
-
const patternLower = pattern.toLowerCase();
|
|
1076
|
-
const wordLower = word.toLowerCase();
|
|
1077
|
-
if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
|
|
1078
|
-
return EmptyMatches;
|
|
1079
|
-
}
|
|
1080
|
-
let strongMatch = false;
|
|
1081
|
-
for (let row = 1; row < patternLength + 1; row++) {
|
|
1082
|
-
const rowChar = pattern[row - 1];
|
|
1083
|
-
const rowCharLow = patternLower[row - 1];
|
|
1084
|
-
for (let column = 1; column < wordLength + 1; column++) {
|
|
1085
|
-
const columnChar = word[column - 1];
|
|
1086
|
-
const columnCharLow = wordLower[column - 1];
|
|
1087
|
-
const columnCharBefore = word[column - 2] || '';
|
|
1088
|
-
const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
|
|
1089
|
-
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
|
|
1090
|
-
if (row === 1 && score > 5) {
|
|
1091
|
-
strongMatch = true;
|
|
1092
|
-
}
|
|
1093
|
-
let diagonalScore = score + table[row - 1][column - 1];
|
|
1094
|
-
if (isDiagonalMatch && score !== -1) {
|
|
1095
|
-
diagonalScore += 2;
|
|
1096
|
-
}
|
|
1097
|
-
const leftScore = table[row][column - 1];
|
|
1098
|
-
if (leftScore > diagonalScore) {
|
|
1099
|
-
table[row][column] = leftScore;
|
|
1100
|
-
arrows[row][column] = Left;
|
|
1101
|
-
} else {
|
|
1102
|
-
table[row][column] = diagonalScore;
|
|
1103
|
-
arrows[row][column] = Diagonal;
|
|
1104
|
-
}
|
|
1105
|
-
}
|
|
1106
|
-
}
|
|
1107
|
-
if (!strongMatch) {
|
|
1108
|
-
return EmptyMatches;
|
|
1109
|
-
}
|
|
1110
|
-
const highlights = traceHighlights(table, arrows, patternLength, wordLength);
|
|
1111
|
-
return highlights;
|
|
1112
|
-
};
|
|
1113
|
-
|
|
1114
|
-
const filterQuickPickItem = (pattern, word) => {
|
|
1115
|
-
const matches = fuzzySearch(pattern, word);
|
|
1116
|
-
return matches;
|
|
1117
|
-
};
|
|
1118
|
-
|
|
1119
|
-
const filterQuickPickItems = (items, value) => {
|
|
1120
|
-
if (!value) {
|
|
1121
|
-
return items;
|
|
1122
|
-
}
|
|
1123
|
-
const results = [];
|
|
1124
|
-
for (const item of items) {
|
|
1125
|
-
const filterValue = item.label;
|
|
1126
|
-
const matches = filterQuickPickItem(value, filterValue);
|
|
1127
|
-
if (matches.length > 0) {
|
|
1128
|
-
results.push({
|
|
1129
|
-
...item,
|
|
1130
|
-
matches
|
|
1131
|
-
});
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
return results;
|
|
1135
|
-
};
|
|
1136
|
-
|
|
1137
|
-
const Command = '>';
|
|
1138
|
-
const Symbol$2 = '@';
|
|
1139
|
-
const WorkspaceSymbol$1 = '#';
|
|
1140
|
-
const GoToLine$1 = ':';
|
|
1141
|
-
const View$2 = 'view ';
|
|
1142
|
-
const None$1 = '';
|
|
1143
|
-
const Help$1 = '?';
|
|
1144
|
-
const GoToColumn = '::';
|
|
1145
|
-
|
|
1146
|
-
const getQuickPickPrefix = value => {
|
|
1147
|
-
if (value.startsWith(Command)) {
|
|
1148
|
-
return Command;
|
|
1149
|
-
}
|
|
1150
|
-
if (value.startsWith(Symbol$2)) {
|
|
1151
|
-
return Symbol$2;
|
|
1152
|
-
}
|
|
1153
|
-
if (value.startsWith(WorkspaceSymbol$1)) {
|
|
1154
|
-
return WorkspaceSymbol$1;
|
|
1155
|
-
}
|
|
1156
|
-
if (value.startsWith(GoToColumn)) {
|
|
1157
|
-
return GoToColumn;
|
|
1158
|
-
}
|
|
1159
|
-
if (value.startsWith(GoToLine$1)) {
|
|
1160
|
-
return GoToLine$1;
|
|
1161
|
-
}
|
|
1162
|
-
if (value.startsWith(View$2)) {
|
|
1163
|
-
return View$2;
|
|
1164
|
-
}
|
|
1165
|
-
return None$1;
|
|
1166
|
-
};
|
|
1167
|
-
|
|
1168
|
-
const noop = value => {
|
|
1169
|
-
return value;
|
|
1170
|
-
};
|
|
1171
|
-
const getFilterValueEverything = value => {
|
|
1172
|
-
const prefix = getQuickPickPrefix(value);
|
|
1173
|
-
const prefixLength = prefix.length;
|
|
1174
|
-
return value.slice(prefixLength).trim();
|
|
1175
|
-
};
|
|
1176
|
-
const getValueGoToColumn = value => {
|
|
1177
|
-
return '';
|
|
1178
|
-
};
|
|
1179
|
-
const getValueGoToLine = value => {
|
|
1180
|
-
return '';
|
|
1181
|
-
};
|
|
1182
|
-
const getFn$1 = id => {
|
|
1183
|
-
switch (id) {
|
|
1184
|
-
case EveryThing$1:
|
|
1185
|
-
return getFilterValueEverything;
|
|
1186
|
-
case GoToColumn$1:
|
|
1187
|
-
return getValueGoToColumn;
|
|
1188
|
-
case GoToLine$2:
|
|
1189
|
-
return getValueGoToLine;
|
|
1190
|
-
default:
|
|
1191
|
-
return noop;
|
|
1192
|
-
}
|
|
1193
|
-
};
|
|
1194
|
-
const getFilterValue = (id, subId, value) => {
|
|
1195
|
-
if (subId === GoToColumn$1) {
|
|
1196
|
-
return getValueGoToColumn();
|
|
1197
|
-
}
|
|
1198
|
-
if (subId === GoToLine$2) {
|
|
1199
|
-
return getValueGoToLine();
|
|
1200
|
-
}
|
|
1201
|
-
const fn = getFn$1(id);
|
|
1202
|
-
const filterValue = fn(value);
|
|
1203
|
-
return filterValue;
|
|
1204
|
-
};
|
|
1205
|
-
|
|
1206
|
-
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
1207
|
-
const contentHeight = itemsLength * itemHeight;
|
|
1208
|
-
const finalDeltaY = Math.max(contentHeight - height, 0);
|
|
1209
|
-
return finalDeltaY;
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
1213
|
-
number(itemsLength);
|
|
1214
|
-
number(itemHeight);
|
|
1215
|
-
number(maxHeight);
|
|
1216
|
-
if (itemsLength === 0) {
|
|
1217
|
-
return itemHeight;
|
|
1218
|
-
}
|
|
1219
|
-
const totalHeight = itemsLength * itemHeight;
|
|
1220
|
-
return Math.min(totalHeight, maxHeight);
|
|
1221
|
-
};
|
|
1222
|
-
|
|
1223
|
-
const getColorThemeNames = async (assetDir, platform) => {
|
|
1224
|
-
return invoke$1('ColorTheme.getColorThemeNames', assetDir, platform);
|
|
1225
|
-
};
|
|
1226
|
-
|
|
1227
|
-
const toProtoVisibleItem$3 = name => {
|
|
1228
|
-
const pick = {
|
|
1229
|
-
description: '',
|
|
1230
|
-
direntType: 0,
|
|
1231
|
-
fileIcon: '',
|
|
1232
|
-
icon: '',
|
|
1233
|
-
label: name,
|
|
1234
|
-
matches: [],
|
|
1235
|
-
uri: ''
|
|
1236
|
-
};
|
|
1237
|
-
return pick;
|
|
1238
|
-
};
|
|
1239
|
-
const getPicks$c = async (searchValue, args, {
|
|
1240
|
-
assetDir = '',
|
|
1241
|
-
platform = 0
|
|
1242
|
-
} = {}) => {
|
|
1243
|
-
const colorThemeNames = await getColorThemeNames(assetDir, platform);
|
|
1244
|
-
const picks = colorThemeNames.map(toProtoVisibleItem$3);
|
|
1245
|
-
return picks;
|
|
1246
|
-
};
|
|
1247
|
-
|
|
1248
|
-
const handleError = async (error, notify = true, prefix = '') => {
|
|
1249
|
-
console.error(error);
|
|
1250
|
-
};
|
|
1251
|
-
const showErrorDialog = async error => {
|
|
1252
|
-
const {
|
|
1253
|
-
code
|
|
1254
|
-
} = error;
|
|
1255
|
-
const {
|
|
1256
|
-
message
|
|
1257
|
-
} = error;
|
|
1258
|
-
const {
|
|
1259
|
-
stack
|
|
1260
|
-
} = error;
|
|
1261
|
-
const {
|
|
1262
|
-
name
|
|
1263
|
-
} = error;
|
|
1264
|
-
const errorInfo = {
|
|
1265
|
-
code,
|
|
1266
|
-
message,
|
|
1267
|
-
name,
|
|
1268
|
-
stack
|
|
1269
|
-
};
|
|
1270
|
-
await showErrorDialog$1(errorInfo);
|
|
1271
|
-
};
|
|
1272
|
-
const warn$1 = (...args) => {
|
|
1273
|
-
console.warn(...args);
|
|
1274
|
-
};
|
|
1275
|
-
|
|
1276
|
-
const state$2 = {
|
|
1277
|
-
menuEntries: []
|
|
1278
|
-
};
|
|
1279
|
-
const getAll = async () => {
|
|
1280
|
-
try {
|
|
1281
|
-
// @ts-ignore
|
|
1282
|
-
const entries = await invoke$1('Layout.getAllQuickPickMenuEntries');
|
|
1283
|
-
return entries || [];
|
|
1284
|
-
} catch {
|
|
1285
|
-
// ignore
|
|
1286
|
-
}
|
|
1287
|
-
return state$2.menuEntries;
|
|
1288
|
-
};
|
|
1289
|
-
const add = menuEntries => {
|
|
1290
|
-
state$2.menuEntries = [...state$2.menuEntries, ...menuEntries];
|
|
1291
|
-
};
|
|
1292
|
-
|
|
1293
|
-
// TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
|
|
1294
|
-
const getBuiltinPicks = async () => {
|
|
1295
|
-
const builtinPicks = await getAll();
|
|
1296
|
-
return builtinPicks;
|
|
1297
|
-
};
|
|
1298
|
-
const prefixIdWithExt = item => {
|
|
1299
|
-
if (!item.label) {
|
|
1300
|
-
warn$1('[QuickPick] item has missing label', item);
|
|
1301
|
-
}
|
|
1302
|
-
if (!item.id) {
|
|
1303
|
-
warn$1('[QuickPick] item has missing id', item);
|
|
1304
|
-
}
|
|
1305
|
-
return {
|
|
1306
|
-
...item,
|
|
1307
|
-
id: `ext.${item.id}`,
|
|
1308
|
-
label: item.label || item.id
|
|
1309
|
-
};
|
|
1310
|
-
};
|
|
1311
|
-
const getExtensionPicks = async (assetDir, platform) => {
|
|
1312
|
-
try {
|
|
1313
|
-
// TODO
|
|
1314
|
-
// Assert.string(assetDir)
|
|
1315
|
-
// Assert.number(platform)
|
|
1316
|
-
// TODO ask extension management worker directly
|
|
1317
|
-
// TODO don't call this every time, cache the results
|
|
1318
|
-
const extensionPicks = await invoke$1('ExtensionHost.getCommands', assetDir, platform);
|
|
1319
|
-
if (!extensionPicks) {
|
|
1320
|
-
return [];
|
|
1321
|
-
}
|
|
1322
|
-
const mappedPicks = extensionPicks.map(prefixIdWithExt);
|
|
1323
|
-
return mappedPicks;
|
|
1324
|
-
} catch (error) {
|
|
1325
|
-
console.error(`Failed to get extension picks: ${error}`);
|
|
1326
|
-
return [];
|
|
1327
|
-
}
|
|
1328
|
-
};
|
|
1329
|
-
const toProtoVisibleItem$2 = item => {
|
|
1330
|
-
const pick = {
|
|
1331
|
-
// @ts-ignore
|
|
1332
|
-
args: item.args,
|
|
1333
|
-
description: '',
|
|
1334
|
-
direntType: 0,
|
|
1335
|
-
fileIcon: '',
|
|
1336
|
-
icon: '',
|
|
1337
|
-
// @ts-ignore
|
|
1338
|
-
id: item.id,
|
|
1339
|
-
label: item.label,
|
|
1340
|
-
matches: [],
|
|
1341
|
-
uri: ''
|
|
1342
|
-
};
|
|
1343
|
-
// @ts-ignore
|
|
1344
|
-
return pick;
|
|
1345
|
-
};
|
|
1346
|
-
const getPicks$b = async (value, args, {
|
|
1347
|
-
assetDir = '',
|
|
1348
|
-
platform = 0
|
|
1349
|
-
} = {}) => {
|
|
1350
|
-
// TODO get picks in parallel
|
|
1351
|
-
const builtinPicks = await getBuiltinPicks();
|
|
1352
|
-
const extensionPicks = await getExtensionPicks(assetDir, platform);
|
|
1353
|
-
const allPicks = [...builtinPicks, ...extensionPicks];
|
|
1354
|
-
const converted = allPicks.map(toProtoVisibleItem$2);
|
|
1355
|
-
return converted;
|
|
1356
|
-
};
|
|
1357
|
-
|
|
1358
|
-
const toProtoVisibleItem$1 = item => {
|
|
1359
|
-
const {
|
|
1360
|
-
label
|
|
1361
|
-
} = item;
|
|
1362
|
-
return {
|
|
1363
|
-
description: '',
|
|
1364
|
-
direntType: 0,
|
|
1365
|
-
fileIcon: '',
|
|
1366
|
-
icon: '',
|
|
1367
|
-
label,
|
|
1368
|
-
matches: [],
|
|
1369
|
-
uri: ''
|
|
1370
|
-
};
|
|
1371
|
-
};
|
|
1372
|
-
const getPicks$a = async (searchValue, args) => {
|
|
1373
|
-
const items = args[1] || [];
|
|
1374
|
-
const mapped = items.map(toProtoVisibleItem$1);
|
|
1375
|
-
return mapped;
|
|
1376
|
-
};
|
|
1377
|
-
|
|
1378
|
-
const emptyMatches = [];
|
|
1379
|
-
|
|
1380
|
-
const getWorkspacePath = async () => {
|
|
1381
|
-
return invoke$1('Workspace.getPath');
|
|
1382
|
-
};
|
|
1383
|
-
|
|
1384
|
-
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1385
|
-
const getProtocol = uri => {
|
|
1386
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1387
|
-
if (protocolMatch) {
|
|
1388
|
-
return protocolMatch[1];
|
|
1389
|
-
}
|
|
1390
|
-
return '';
|
|
1391
|
-
};
|
|
1392
|
-
|
|
1393
|
-
const state$1 = Object.create(null);
|
|
1394
|
-
const register = modules => {
|
|
1395
|
-
Object.assign(state$1, modules);
|
|
1396
|
-
};
|
|
1397
|
-
const getFn = protocol => {
|
|
1398
|
-
return state$1[protocol];
|
|
1399
|
-
};
|
|
1400
|
-
|
|
1401
|
-
const searchFile$5 = async (path, value, prepare, assetDir) => {
|
|
1402
|
-
const protocol = getProtocol(path);
|
|
1403
|
-
// TODO call different providers depending on protocol
|
|
1404
|
-
const fn = getFn(protocol);
|
|
1405
|
-
if (!fn) {
|
|
1406
|
-
throw new Error(`No search handler registered for protocol: ${protocol}`);
|
|
1407
|
-
}
|
|
1408
|
-
const result = await fn(path, value, prepare, assetDir);
|
|
1409
|
-
return result;
|
|
1410
|
-
};
|
|
1411
|
-
|
|
1412
|
-
// TODO this should be in FileSystem module
|
|
1413
|
-
const pathBaseName = path => {
|
|
1414
|
-
return path.slice(path.lastIndexOf('/') + 1);
|
|
1415
|
-
};
|
|
1416
|
-
|
|
1417
|
-
// TODO this should be in FileSystem module
|
|
1418
|
-
const pathDirName = path => {
|
|
1419
|
-
const pathSeparator = '/';
|
|
1420
|
-
const index = path.lastIndexOf(pathSeparator);
|
|
1421
|
-
if (index === -1) {
|
|
1422
|
-
return '';
|
|
1423
|
-
}
|
|
1424
|
-
return path.slice(0, index);
|
|
1425
|
-
};
|
|
1426
|
-
|
|
1427
|
-
const searchFile$4 = async (path, value) => {
|
|
1428
|
-
const prepare = true;
|
|
1429
|
-
const files = await searchFile$5(/* path */path, /* searchTerm */value, prepare, '');
|
|
1430
|
-
return files;
|
|
1431
|
-
};
|
|
1432
|
-
const convertToPick = uri => {
|
|
1433
|
-
const baseName = pathBaseName(uri);
|
|
1434
|
-
const dirName = pathDirName(uri);
|
|
1435
|
-
return {
|
|
1436
|
-
description: dirName,
|
|
1437
|
-
direntType: File$1,
|
|
1438
|
-
fileIcon: '',
|
|
1439
|
-
icon: '',
|
|
1440
|
-
label: baseName,
|
|
1441
|
-
matches: emptyMatches,
|
|
1442
|
-
uri
|
|
1443
|
-
};
|
|
1444
|
-
};
|
|
1445
|
-
|
|
1446
|
-
// TODO handle files differently
|
|
1447
|
-
// e.g. when there are many files, don't need
|
|
1448
|
-
// to compute the fileIcon for all files
|
|
1449
|
-
|
|
1450
|
-
const getPicks$9 = async searchValue => {
|
|
1451
|
-
// TODO cache workspace path
|
|
1452
|
-
const workspace = await getWorkspacePath();
|
|
1453
|
-
if (!workspace) {
|
|
1454
|
-
return [];
|
|
1455
|
-
}
|
|
1456
|
-
const files = await searchFile$4(workspace, searchValue);
|
|
1457
|
-
const picks = files.map(convertToPick);
|
|
1458
|
-
return picks;
|
|
1459
|
-
};
|
|
1460
|
-
|
|
1461
|
-
const getText = async () => {
|
|
1462
|
-
// TODO
|
|
1463
|
-
const id = await getActiveEditorId();
|
|
1464
|
-
const lines = await getLines(id);
|
|
1465
|
-
return lines.join('\n');
|
|
1466
|
-
};
|
|
1467
|
-
|
|
1468
|
-
const getPicksGoToColumnBase = async () => {
|
|
1469
|
-
const text = await getText();
|
|
1470
|
-
return [{
|
|
1471
|
-
description: '',
|
|
1472
|
-
direntType: 0,
|
|
1473
|
-
fileIcon: '',
|
|
1474
|
-
icon: '',
|
|
1475
|
-
label: `Type a character position to go to (from 1 to ${text.length})`,
|
|
1476
|
-
matches: [],
|
|
1477
|
-
uri: ''
|
|
1478
|
-
}];
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
|
-
const getPosition = (text, wantedColumn) => {
|
|
1482
|
-
let row = 0;
|
|
1483
|
-
let column = 0;
|
|
1484
|
-
for (let i = 0; i < wantedColumn; i++) {
|
|
1485
|
-
if (text[i] === '\n') {
|
|
1486
|
-
row++;
|
|
1487
|
-
column = 0;
|
|
1488
|
-
} else {
|
|
1489
|
-
column++;
|
|
1490
|
-
}
|
|
1491
|
-
}
|
|
1492
|
-
return {
|
|
1493
|
-
column,
|
|
1494
|
-
row
|
|
1495
|
-
};
|
|
1496
|
-
};
|
|
1497
|
-
|
|
1498
|
-
const emptyObject = {};
|
|
1499
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1500
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1501
|
-
if (placeholders === emptyObject) {
|
|
1502
|
-
return key;
|
|
1503
|
-
}
|
|
1504
|
-
const replacer = (match, rest) => {
|
|
1505
|
-
return placeholders[rest];
|
|
1506
|
-
};
|
|
1507
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1508
|
-
};
|
|
1509
|
-
|
|
1510
|
-
const GoToFile = 'Go to file';
|
|
1511
|
-
const GoToLineColumn = 'Go to Line / Column';
|
|
1512
|
-
const GoToSymbolInEditor = 'Go to Symbol in Editor';
|
|
1513
|
-
const NoResults = 'No Results';
|
|
1514
|
-
const OpenView = 'Open View';
|
|
1515
|
-
const QuickOpen = 'Quick open';
|
|
1516
|
-
const SearchForText = 'Search for text';
|
|
1517
|
-
const ShowAndRunCommands = 'Show And Run Commands';
|
|
1518
|
-
const TypeNameOfCommandToRun = 'Type the name of a command to run.';
|
|
1519
|
-
const PressEnterToGoToLine = `Press 'Enter' to go to line {PH1} column {PH2}`;
|
|
1520
|
-
|
|
1521
|
-
const pressEnterToGoToLine = (row, column) => {
|
|
1522
|
-
return i18nString(PressEnterToGoToLine, {
|
|
1523
|
-
PH1: row,
|
|
1524
|
-
PH2: column
|
|
1525
|
-
});
|
|
1526
|
-
};
|
|
1527
|
-
const typeNameofCommandToRun = () => {
|
|
1528
|
-
return i18nString(TypeNameOfCommandToRun);
|
|
1529
|
-
};
|
|
1530
|
-
const showAndRunCommands = () => {
|
|
1531
|
-
return i18nString(ShowAndRunCommands);
|
|
1532
|
-
};
|
|
1533
|
-
const goToFile = () => {
|
|
1534
|
-
return i18nString(GoToFile);
|
|
1535
|
-
};
|
|
1536
|
-
const noResults = () => {
|
|
1537
|
-
return i18nString(NoResults);
|
|
1538
|
-
};
|
|
1539
|
-
const quickOpen = () => {
|
|
1540
|
-
return i18nString(QuickOpen);
|
|
1541
|
-
};
|
|
1542
|
-
const goToLineColumn = () => {
|
|
1543
|
-
return i18nString(GoToLineColumn);
|
|
1544
|
-
};
|
|
1545
|
-
const goToSymbolInEditor = () => {
|
|
1546
|
-
return i18nString(GoToSymbolInEditor);
|
|
1547
|
-
};
|
|
1548
|
-
const searchForText = () => {
|
|
1549
|
-
return i18nString(SearchForText);
|
|
1550
|
-
};
|
|
1551
|
-
const openView = () => {
|
|
1552
|
-
return i18nString(OpenView);
|
|
1553
|
-
};
|
|
1554
|
-
|
|
1555
|
-
const getPicksGoToColumn = async value => {
|
|
1556
|
-
if (value === GoToColumn) {
|
|
1557
|
-
return getPicksGoToColumnBase();
|
|
1558
|
-
}
|
|
1559
|
-
if (value.startsWith(GoToColumn)) {
|
|
1560
|
-
const columnString = value.slice(GoToColumn.length);
|
|
1561
|
-
const wantedColumn = Number.parseInt(columnString, 10);
|
|
1562
|
-
if (Number.isNaN(wantedColumn)) {
|
|
1563
|
-
return getPicksGoToColumnBase();
|
|
1564
|
-
}
|
|
1565
|
-
const text = await getText();
|
|
1566
|
-
const position = getPosition(text, wantedColumn);
|
|
1567
|
-
return [{
|
|
1568
|
-
description: '',
|
|
1569
|
-
direntType: 0,
|
|
1570
|
-
fileIcon: '',
|
|
1571
|
-
icon: '',
|
|
1572
|
-
label: pressEnterToGoToLine(position.row, position.column),
|
|
1573
|
-
matches: [],
|
|
1574
|
-
uri: ''
|
|
1575
|
-
}];
|
|
1576
|
-
}
|
|
1577
|
-
return [];
|
|
1578
|
-
};
|
|
1579
|
-
|
|
1580
|
-
const splitLines$2 = lines => {
|
|
1581
|
-
if (!lines) {
|
|
1582
|
-
return [];
|
|
1583
|
-
}
|
|
1584
|
-
return lines.split('\n');
|
|
1585
|
-
};
|
|
1586
|
-
|
|
1587
|
-
const getPicksGoToLineBase = async () => {
|
|
1588
|
-
const text = await getText();
|
|
1589
|
-
const lines = splitLines$2(text);
|
|
1590
|
-
const lineCount = lines.length;
|
|
1591
|
-
return [{
|
|
1592
|
-
description: '',
|
|
1593
|
-
direntType: 0,
|
|
1594
|
-
fileIcon: '',
|
|
1595
|
-
icon: '',
|
|
1596
|
-
label: `Type a line number to go to (from 1 to ${lineCount})`,
|
|
1597
|
-
matches: [],
|
|
1598
|
-
uri: ''
|
|
1599
|
-
}];
|
|
1600
|
-
};
|
|
1601
|
-
|
|
1602
|
-
const parseGotoline = value => {
|
|
1603
|
-
const lineString = value.slice(GoToLine$1.length);
|
|
1604
|
-
const wantedLine = Number.parseInt(lineString, 10);
|
|
1605
|
-
if (Number.isNaN(wantedLine)) {
|
|
1606
|
-
return -1;
|
|
1607
|
-
}
|
|
1608
|
-
return wantedLine;
|
|
1609
|
-
};
|
|
1610
|
-
|
|
1611
|
-
const getPicks$8 = async value => {
|
|
1612
|
-
if (value === GoToLine$1) {
|
|
1613
|
-
return getPicksGoToLineBase();
|
|
1614
|
-
}
|
|
1615
|
-
if (value.startsWith(GoToLine$1)) {
|
|
1616
|
-
const wantedLine = parseGotoline(value);
|
|
1617
|
-
if (wantedLine === -1) {
|
|
1618
|
-
return getPicksGoToLineBase();
|
|
1619
|
-
}
|
|
1620
|
-
const rowIndex = wantedLine - 1;
|
|
1621
|
-
const columnIndex = 0;
|
|
1622
|
-
return [{
|
|
1623
|
-
description: '',
|
|
1624
|
-
direntType: 0,
|
|
1625
|
-
fileIcon: '',
|
|
1626
|
-
icon: '',
|
|
1627
|
-
label: pressEnterToGoToLine(rowIndex, columnIndex),
|
|
1628
|
-
matches: [],
|
|
1629
|
-
uri: ''
|
|
1630
|
-
}];
|
|
1631
|
-
}
|
|
1632
|
-
return [];
|
|
1633
|
-
};
|
|
1634
|
-
|
|
1635
|
-
const DotDotDot = '...';
|
|
1636
|
-
const Colon = ':';
|
|
1637
|
-
const Percent = '%';
|
|
1638
|
-
const AngleBracket = '>';
|
|
1639
|
-
const View$1 = 'view';
|
|
1640
|
-
|
|
1641
|
-
const getPicks$7 = async () => {
|
|
1642
|
-
return [{
|
|
1643
|
-
description: goToFile(),
|
|
1644
|
-
direntType: None$2,
|
|
1645
|
-
fileIcon: '',
|
|
1646
|
-
icon: '',
|
|
1647
|
-
label: DotDotDot,
|
|
1648
|
-
matches: [],
|
|
1649
|
-
uri: ''
|
|
1650
|
-
}, {
|
|
1651
|
-
description: goToLineColumn(),
|
|
1652
|
-
direntType: None$2,
|
|
1653
|
-
fileIcon: '',
|
|
1654
|
-
icon: '',
|
|
1655
|
-
label: ':',
|
|
1656
|
-
matches: [],
|
|
1657
|
-
uri: ''
|
|
1658
|
-
}, {
|
|
1659
|
-
description: goToSymbolInEditor(),
|
|
1660
|
-
direntType: None$2,
|
|
1661
|
-
fileIcon: '',
|
|
1662
|
-
icon: '',
|
|
1663
|
-
label: Colon,
|
|
1664
|
-
matches: [],
|
|
1665
|
-
uri: ''
|
|
1666
|
-
}, {
|
|
1667
|
-
description: searchForText(),
|
|
1668
|
-
direntType: None$2,
|
|
1669
|
-
fileIcon: '',
|
|
1670
|
-
icon: '',
|
|
1671
|
-
label: Percent,
|
|
1672
|
-
matches: [],
|
|
1673
|
-
uri: ''
|
|
1674
|
-
}, {
|
|
1675
|
-
description: showAndRunCommands(),
|
|
1676
|
-
direntType: None$2,
|
|
1677
|
-
fileIcon: '',
|
|
1678
|
-
icon: '',
|
|
1679
|
-
label: AngleBracket,
|
|
1680
|
-
matches: [],
|
|
1681
|
-
uri: ''
|
|
1682
|
-
}, {
|
|
1683
|
-
description: openView(),
|
|
1684
|
-
direntType: None$2,
|
|
1685
|
-
fileIcon: '',
|
|
1686
|
-
icon: '',
|
|
1687
|
-
label: View$1,
|
|
1688
|
-
matches: [],
|
|
1689
|
-
uri: ''
|
|
1690
|
-
}];
|
|
1691
|
-
};
|
|
1692
|
-
|
|
1693
|
-
const getRecentlyOpened = () => {
|
|
1694
|
-
return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
1695
|
-
};
|
|
1696
|
-
|
|
1697
|
-
const getLabel = uri => {
|
|
1698
|
-
if (uri.startsWith('file://')) {
|
|
1699
|
-
return uri.slice('file://'.length);
|
|
1700
|
-
}
|
|
1701
|
-
return uri;
|
|
1702
|
-
};
|
|
1703
|
-
const toProtoVisibleItem = uri => {
|
|
1704
|
-
return {
|
|
1705
|
-
description: '',
|
|
1706
|
-
direntType: Directory,
|
|
1707
|
-
fileIcon: '',
|
|
1708
|
-
icon: '',
|
|
1709
|
-
label: getLabel(uri),
|
|
1710
|
-
matches: [],
|
|
1711
|
-
uri
|
|
1712
|
-
};
|
|
1713
|
-
};
|
|
1714
|
-
const getPicks$6 = async () => {
|
|
1715
|
-
const recentlyOpened = await getRecentlyOpened();
|
|
1716
|
-
const picks = recentlyOpened.map(toProtoVisibleItem);
|
|
1717
|
-
return picks;
|
|
1718
|
-
};
|
|
1719
|
-
|
|
1720
|
-
const getPicks$5 = async () => {
|
|
1721
|
-
const picks = [];
|
|
1722
|
-
return picks;
|
|
1723
|
-
};
|
|
1724
|
-
|
|
1725
|
-
const getPicks$4 = async () => {
|
|
1726
|
-
return [];
|
|
1727
|
-
};
|
|
1728
|
-
|
|
1729
|
-
const getPicks$3 = async () => {
|
|
1730
|
-
const picks = [];
|
|
1731
|
-
return picks;
|
|
1732
|
-
};
|
|
1733
|
-
|
|
1734
|
-
const Hide = 'hide';
|
|
1735
|
-
const KeepOpen = '';
|
|
1736
|
-
|
|
1737
|
-
const selectPick$9 = async pick => {
|
|
1738
|
-
const id = pick.label;
|
|
1739
|
-
await setColorTheme(id);
|
|
1740
|
-
return {
|
|
1741
|
-
command: Hide
|
|
1742
|
-
};
|
|
1743
|
-
};
|
|
1744
|
-
|
|
1745
|
-
const hideIds = ['AutoUpdater.checkForUpdates'];
|
|
1746
|
-
const shouldHide = item => {
|
|
1747
|
-
if (hideIds.includes(item.id)) {
|
|
1748
|
-
return false;
|
|
1749
|
-
}
|
|
1750
|
-
if (item.id === 'Viewlet.openWidget' && item.args?.[0] === 'QuickPick') {
|
|
1751
|
-
return false;
|
|
1752
|
-
}
|
|
1753
|
-
return true;
|
|
1754
|
-
};
|
|
1755
|
-
|
|
1756
|
-
const selectPickBuiltin = async item => {
|
|
1757
|
-
const args = item.args || [];
|
|
1758
|
-
// TODO ids should be all numbers for efficiency -> also directly can call command
|
|
1759
|
-
await invoke$1(item.id, ...args);
|
|
1760
|
-
if (shouldHide(item)) {
|
|
1761
|
-
return {
|
|
1762
|
-
command: Hide
|
|
1763
|
-
};
|
|
1764
|
-
}
|
|
1765
|
-
return {
|
|
1766
|
-
command: KeepOpen
|
|
1767
|
-
};
|
|
1768
|
-
};
|
|
1769
|
-
const selectPickExtension = async item => {
|
|
1770
|
-
const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
|
|
1771
|
-
try {
|
|
1772
|
-
await invoke$1('ExtensionHost.executeCommand', id);
|
|
1773
|
-
} catch (error) {
|
|
1774
|
-
await handleError(error, false);
|
|
1775
|
-
await showErrorDialog(error);
|
|
1776
|
-
}
|
|
1777
|
-
return {
|
|
1778
|
-
command: Hide
|
|
1779
|
-
};
|
|
1780
|
-
};
|
|
1781
|
-
const selectPick$8 = async item => {
|
|
1782
|
-
// @ts-ignore
|
|
1783
|
-
const {
|
|
1784
|
-
id
|
|
1785
|
-
} = item;
|
|
1786
|
-
if (id.startsWith('ext.')) {
|
|
1787
|
-
return selectPickExtension(item);
|
|
1788
|
-
}
|
|
1789
|
-
return selectPickBuiltin(item);
|
|
1790
|
-
};
|
|
1791
|
-
|
|
1792
|
-
const state = {
|
|
1793
|
-
args: []
|
|
1794
|
-
};
|
|
1795
|
-
|
|
1796
|
-
const selectPick$7 = async pick => {
|
|
1797
|
-
const {
|
|
1798
|
-
args
|
|
1799
|
-
} = state;
|
|
1800
|
-
const resolveId = args[2];
|
|
1801
|
-
await invoke$1(`QuickPick.executeCallback`, resolveId, pick);
|
|
1802
|
-
return {
|
|
1803
|
-
command: Hide
|
|
1804
|
-
};
|
|
1805
|
-
};
|
|
1806
|
-
|
|
1807
|
-
const openUri = async uri => {
|
|
1808
|
-
await openUri$1(uri);
|
|
1809
|
-
};
|
|
1810
|
-
|
|
1811
|
-
const selectPick$6 = async pick => {
|
|
1812
|
-
const {
|
|
1813
|
-
description
|
|
1814
|
-
} = pick;
|
|
1815
|
-
const fileName = pick.label;
|
|
1816
|
-
const workspace = await getWorkspacePath();
|
|
1817
|
-
const absolutePath = `${workspace}/${description}/${fileName}`;
|
|
1818
|
-
await openUri(absolutePath);
|
|
1819
|
-
return {
|
|
1820
|
-
command: Hide
|
|
1821
|
-
};
|
|
1822
|
-
};
|
|
1823
|
-
|
|
1824
|
-
const setCursor = async (rowIndex, columnIndex) => {
|
|
1825
|
-
await invoke$1('Editor.cursorSet', rowIndex, columnIndex);
|
|
1826
|
-
};
|
|
1827
|
-
|
|
1828
|
-
const goToPositionAndFocus = async (rowIndex, columnIndex) => {
|
|
1829
|
-
await setCursor(rowIndex, columnIndex);
|
|
1830
|
-
await invoke$1('Editor.handleFocus');
|
|
1831
|
-
};
|
|
1832
|
-
|
|
1833
|
-
const selectPickGoToColumn = async (item, value) => {
|
|
1834
|
-
if (value.startsWith(GoToColumn)) {
|
|
1835
|
-
const columnString = value.slice(2);
|
|
1836
|
-
const wantedColumn = Number.parseInt(columnString, 10);
|
|
1837
|
-
const text = await getText();
|
|
1838
|
-
const position = getPosition(text, wantedColumn);
|
|
1839
|
-
await goToPositionAndFocus(position.row, position.column);
|
|
1840
|
-
return {
|
|
1841
|
-
command: Hide
|
|
1842
|
-
};
|
|
1843
|
-
}
|
|
1844
|
-
return {
|
|
1845
|
-
command: Hide
|
|
1846
|
-
};
|
|
1847
|
-
};
|
|
1848
|
-
|
|
1849
|
-
const selectPick$5 = async (item, value) => {
|
|
1850
|
-
if (value.startsWith(GoToLine$1)) {
|
|
1851
|
-
const lineString = value.slice(GoToLine$1.length);
|
|
1852
|
-
const wantedLine = Number.parseInt(lineString, 10);
|
|
1853
|
-
const rowIndex = wantedLine - 1;
|
|
1854
|
-
const columnIndex = 0;
|
|
1855
|
-
await goToPositionAndFocus(rowIndex, columnIndex);
|
|
1856
|
-
return {
|
|
1857
|
-
command: Hide
|
|
1858
|
-
};
|
|
1859
|
-
}
|
|
1860
|
-
return {
|
|
1861
|
-
command: Hide
|
|
1862
|
-
};
|
|
1863
|
-
};
|
|
1864
|
-
|
|
1865
|
-
const selectPick$4 = async item => {
|
|
1866
|
-
// Command.execute(/* openView */ 549, /* viewName */ item.label)
|
|
1867
|
-
return {
|
|
1868
|
-
command: Hide
|
|
1869
|
-
};
|
|
1870
|
-
};
|
|
1871
|
-
|
|
1872
|
-
const openWorkspaceFolder = uri => {
|
|
1873
|
-
return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
|
|
1874
|
-
};
|
|
1875
|
-
|
|
1876
|
-
// TODO selectPick should be independent of show/hide
|
|
1877
|
-
const selectPick$3 = async pick => {
|
|
1878
|
-
const {
|
|
1879
|
-
uri
|
|
1880
|
-
} = pick;
|
|
1881
|
-
await openWorkspaceFolder(uri);
|
|
1882
|
-
return {
|
|
1883
|
-
command: Hide
|
|
1884
|
-
};
|
|
1885
|
-
};
|
|
1886
|
-
|
|
1887
|
-
const selectPick$2 = async item => {
|
|
1888
|
-
return {
|
|
1889
|
-
command: Hide
|
|
1890
|
-
};
|
|
1891
|
-
};
|
|
1892
|
-
|
|
1893
|
-
const selectPick$1 = async item => {
|
|
1894
|
-
// Command.execute(/* openView */ 549, /* viewName */ item.label)
|
|
1895
|
-
return {
|
|
1896
|
-
command: Hide
|
|
1897
|
-
};
|
|
1898
|
-
};
|
|
1899
|
-
|
|
1900
|
-
const selectPick = async item => {
|
|
1901
|
-
return {
|
|
1902
|
-
command: Hide
|
|
1903
|
-
};
|
|
1904
|
-
};
|
|
1905
|
-
|
|
1906
|
-
const selectPicks = [selectPick$9, selectPick$8, selectPick$7, selectPick$6, selectPickGoToColumn, selectPick$5, selectPick$4, selectPick$3, selectPick$2, selectPick$1, selectPick];
|
|
1907
|
-
const getPicks$2 = [getPicks$c, getPicks$b, getPicks$a, getPicks$9, getPicksGoToColumn, getPicks$8, getPicks$7, getPicks$6, getPicks$5, getPicks$4, getPicks$3];
|
|
1908
|
-
|
|
1909
|
-
const select = selectPicks;
|
|
1910
|
-
const getPick$1 = getPicks$2;
|
|
1911
|
-
const getPicks$1 = id => {
|
|
1912
|
-
const fn = getPick$1[id];
|
|
1913
|
-
return fn;
|
|
1914
|
-
};
|
|
1915
|
-
const getSelect = id => {
|
|
1916
|
-
const fn = select[id];
|
|
1917
|
-
return fn;
|
|
1918
|
-
};
|
|
1919
|
-
|
|
1920
|
-
const getPicks = (id, searchValue, args, {
|
|
1921
|
-
assetDir,
|
|
1922
|
-
platform
|
|
1923
|
-
}) => {
|
|
1924
|
-
const fn = getPicks$1(id);
|
|
1925
|
-
return fn(searchValue, args, {
|
|
1926
|
-
assetDir,
|
|
1927
|
-
platform
|
|
1928
|
-
});
|
|
1929
|
-
};
|
|
1930
|
-
|
|
1931
|
-
const getQuickPickSubProviderId = (id, prefix) => {
|
|
1932
|
-
if (id !== EveryThing$1) {
|
|
1933
|
-
return id;
|
|
1934
|
-
}
|
|
1935
|
-
switch (prefix) {
|
|
1936
|
-
case Command:
|
|
1937
|
-
return Commands$1;
|
|
1938
|
-
case GoToColumn:
|
|
1939
|
-
return GoToColumn$1;
|
|
1940
|
-
case GoToLine$1:
|
|
1941
|
-
return GoToLine$2;
|
|
1942
|
-
case Help$1:
|
|
1943
|
-
return Help$2;
|
|
1944
|
-
case Symbol$2:
|
|
1945
|
-
return Symbol$3;
|
|
1946
|
-
case View$2:
|
|
1947
|
-
return View$3;
|
|
1948
|
-
case WorkspaceSymbol$1:
|
|
1949
|
-
return WorkspaceSymbol$2;
|
|
1950
|
-
default:
|
|
1951
|
-
return File$2;
|
|
1952
|
-
}
|
|
1953
|
-
};
|
|
1954
|
-
|
|
1955
|
-
// TODO when user types letters -> no need to query provider again -> just filter existing results
|
|
1956
|
-
const setValue = async (state, newValue) => {
|
|
1957
|
-
const {
|
|
1958
|
-
args,
|
|
1959
|
-
assetDir,
|
|
1960
|
-
fileIconCache,
|
|
1961
|
-
height,
|
|
1962
|
-
itemHeight,
|
|
1963
|
-
maxLineY,
|
|
1964
|
-
minLineY,
|
|
1965
|
-
platform,
|
|
1966
|
-
providerId,
|
|
1967
|
-
value
|
|
1968
|
-
} = state;
|
|
1969
|
-
if (value === newValue) {
|
|
1970
|
-
return state;
|
|
1971
|
-
}
|
|
1972
|
-
const prefix = getQuickPickPrefix(newValue);
|
|
1973
|
-
const subId = getQuickPickSubProviderId(providerId, prefix);
|
|
1974
|
-
const newPicks = await getPicks(subId, newValue, args, {
|
|
1975
|
-
assetDir,
|
|
1976
|
-
platform
|
|
1977
|
-
});
|
|
1978
|
-
const filterValue = getFilterValue(providerId, subId, newValue);
|
|
1979
|
-
const items = filterQuickPickItems(newPicks, filterValue);
|
|
1980
|
-
const focusedIndex = items.length === 0 ? -1 : 0;
|
|
1981
|
-
const sliced = items.slice(minLineY, maxLineY);
|
|
1982
|
-
const {
|
|
1983
|
-
icons,
|
|
1984
|
-
newFileIconCache
|
|
1985
|
-
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
1986
|
-
const listHeight = getListHeight(items.length, itemHeight, height);
|
|
1987
|
-
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
1988
|
-
return {
|
|
1989
|
-
...state,
|
|
1990
|
-
fileIconCache: newFileIconCache,
|
|
1991
|
-
finalDeltaY,
|
|
1992
|
-
focusedIndex,
|
|
1993
|
-
icons,
|
|
1994
|
-
inputSource: Script,
|
|
1995
|
-
items,
|
|
1996
|
-
picks: newPicks,
|
|
1997
|
-
value: newValue
|
|
1998
|
-
};
|
|
1999
|
-
};
|
|
2000
|
-
|
|
2001
|
-
// TODO when user types letters -> no need to query provider again -> just filter existing results
|
|
2002
|
-
const handleInput = async (state, newValue, cursorOffset, inputSource = Script) => {
|
|
2003
|
-
if (state.value === newValue) {
|
|
2004
|
-
return {
|
|
2005
|
-
...state,
|
|
2006
|
-
cursorOffset,
|
|
2007
|
-
inputSource
|
|
2008
|
-
};
|
|
2009
|
-
}
|
|
2010
|
-
const newState = await setValue(state, newValue);
|
|
2011
|
-
return {
|
|
2012
|
-
...newState,
|
|
2013
|
-
cursorOffset,
|
|
2014
|
-
inputSource
|
|
2015
|
-
};
|
|
2016
|
-
};
|
|
2017
|
-
|
|
2018
|
-
const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd) => {
|
|
2019
|
-
string(inputType);
|
|
2020
|
-
number(selectionStart);
|
|
2021
|
-
number(selectionEnd);
|
|
2022
|
-
const {
|
|
2023
|
-
value
|
|
2024
|
-
} = state;
|
|
2025
|
-
const {
|
|
2026
|
-
cursorOffset,
|
|
2027
|
-
newValue
|
|
2028
|
-
} = getNewValue(value, inputType, data, selectionStart, selectionEnd);
|
|
2029
|
-
return handleInput(state, newValue, cursorOffset, User);
|
|
2030
|
-
};
|
|
2031
|
-
|
|
2032
|
-
const handleBlur = async state => {
|
|
2033
|
-
// TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
|
|
2034
|
-
// await CloseWidget.closeWidget(state.uid)
|
|
2035
|
-
return state;
|
|
2036
|
-
};
|
|
2037
|
-
|
|
2038
|
-
const getIndex = (top, headerHeight, itemHeight, y) => {
|
|
2039
|
-
const relativeY = y - top - headerHeight;
|
|
2040
|
-
const index = Math.floor(relativeY / itemHeight);
|
|
2041
|
-
return index;
|
|
2042
|
-
};
|
|
2043
|
-
|
|
2044
|
-
const getPick = (items, index) => {
|
|
2045
|
-
array(items);
|
|
2046
|
-
number(index);
|
|
2047
|
-
// if (index < state.recentPicks.length) {
|
|
2048
|
-
// return state.recentPicks[index]
|
|
2049
|
-
// }
|
|
2050
|
-
// index -= state.recentPicks.length
|
|
2051
|
-
if (index < items.length) {
|
|
2052
|
-
return items[index];
|
|
2053
|
-
}
|
|
2054
|
-
console.warn('no pick matching index', index);
|
|
2055
|
-
return undefined;
|
|
2056
|
-
};
|
|
2057
|
-
|
|
2058
|
-
const selectIndex = async (state, index, button = /* left */0) => {
|
|
2059
|
-
const {
|
|
2060
|
-
items,
|
|
2061
|
-
minLineY,
|
|
2062
|
-
providerId,
|
|
2063
|
-
value
|
|
2064
|
-
} = state;
|
|
2065
|
-
const actualIndex = index + minLineY;
|
|
2066
|
-
const pick = getPick(items, actualIndex);
|
|
2067
|
-
if (!pick) {
|
|
2068
|
-
return state;
|
|
2069
|
-
}
|
|
2070
|
-
const prefix = getQuickPickPrefix(value);
|
|
2071
|
-
const subId = getQuickPickSubProviderId(providerId, prefix);
|
|
2072
|
-
const fn = getSelect(subId);
|
|
2073
|
-
const selectPickResult = await fn(pick, value);
|
|
2074
|
-
object(selectPickResult);
|
|
2075
|
-
string(selectPickResult.command);
|
|
2076
|
-
const {
|
|
2077
|
-
command
|
|
2078
|
-
} = selectPickResult;
|
|
2079
|
-
switch (command) {
|
|
2080
|
-
case Hide:
|
|
2081
|
-
await closeWidget(state.uid);
|
|
2082
|
-
return state;
|
|
2083
|
-
default:
|
|
2084
|
-
return state;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
// TODO recent picks should be per provider
|
|
2088
|
-
// if (!state.recentPickIds.has(pick.id)) {
|
|
2089
|
-
// state.recentPicks.unshift(pick)
|
|
2090
|
-
// state.recentPickIds.add(pick.id)
|
|
2091
|
-
// }
|
|
2092
|
-
// if (state.recentPicks.length > RECENT_PICKS_MAX_SIZE) {
|
|
2093
|
-
// const last = state.recentPicks.pop()
|
|
2094
|
-
// state.recentPickIds.delete(last.id)
|
|
2095
|
-
// }
|
|
2096
|
-
};
|
|
2097
|
-
|
|
2098
|
-
const handleClickAt = (state, x, y) => {
|
|
2099
|
-
const {
|
|
2100
|
-
headerHeight,
|
|
2101
|
-
itemHeight,
|
|
2102
|
-
top
|
|
2103
|
-
} = state;
|
|
2104
|
-
const index = getIndex(top, headerHeight, itemHeight, y);
|
|
2105
|
-
return selectIndex(state, index);
|
|
2106
|
-
};
|
|
2107
|
-
|
|
2108
|
-
const handleFocus = async state => {
|
|
2109
|
-
// TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
|
|
2110
|
-
await setFocus(FocusQuickPickInput);
|
|
2111
|
-
// await CloseWidget.closeWidget(state.uid)
|
|
2112
|
-
return state;
|
|
2113
|
-
};
|
|
2114
|
-
|
|
2115
57
|
const isMessagePort = value => {
|
|
2116
58
|
return value && value instanceof MessagePort;
|
|
2117
59
|
};
|
|
@@ -2213,7 +155,7 @@ const getDetails = lines => {
|
|
|
2213
155
|
rest: lines.slice(index, lastIndex)
|
|
2214
156
|
};
|
|
2215
157
|
};
|
|
2216
|
-
const splitLines$
|
|
158
|
+
const splitLines$2 = lines => {
|
|
2217
159
|
return lines.split(NewLine$1);
|
|
2218
160
|
};
|
|
2219
161
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
@@ -2225,7 +167,7 @@ const isMessageCodeBlockEndIndex = line => {
|
|
|
2225
167
|
return RE_MESSAGE_CODE_BLOCK_END.test(line);
|
|
2226
168
|
};
|
|
2227
169
|
const getMessageCodeBlock = stderr => {
|
|
2228
|
-
const lines = splitLines$
|
|
170
|
+
const lines = splitLines$2(stderr);
|
|
2229
171
|
const startIndex = lines.findIndex(isMessageCodeBlockStartIndex);
|
|
2230
172
|
const endIndex = startIndex + lines.slice(startIndex).findIndex(isMessageCodeBlockEndIndex, startIndex);
|
|
2231
173
|
const relevantLines = lines.slice(startIndex, endIndex);
|
|
@@ -2236,7 +178,7 @@ const isModuleNotFoundMessage = line => {
|
|
|
2236
178
|
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
2237
179
|
};
|
|
2238
180
|
const getModuleNotFoundError = stderr => {
|
|
2239
|
-
const lines = splitLines$
|
|
181
|
+
const lines = splitLines$2(stderr);
|
|
2240
182
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
2241
183
|
const message = lines[messageIndex];
|
|
2242
184
|
return {
|
|
@@ -2284,7 +226,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
2284
226
|
if (isModuleNotFoundError(stderr)) {
|
|
2285
227
|
return getModuleNotFoundError(stderr);
|
|
2286
228
|
}
|
|
2287
|
-
const lines = splitLines$
|
|
229
|
+
const lines = splitLines$2(stderr);
|
|
2288
230
|
const {
|
|
2289
231
|
actualMessage,
|
|
2290
232
|
rest
|
|
@@ -2521,13 +463,34 @@ const IpcParentWithMessagePort$1 = {
|
|
|
2521
463
|
wrap: wrap$5
|
|
2522
464
|
};
|
|
2523
465
|
|
|
466
|
+
class CommandNotFoundError extends Error {
|
|
467
|
+
constructor(command) {
|
|
468
|
+
super(`Command not found ${command}`);
|
|
469
|
+
this.name = 'CommandNotFoundError';
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
const commands = Object.create(null);
|
|
473
|
+
const register$1 = commandMap => {
|
|
474
|
+
Object.assign(commands, commandMap);
|
|
475
|
+
};
|
|
476
|
+
const getCommand = key => {
|
|
477
|
+
return commands[key];
|
|
478
|
+
};
|
|
479
|
+
const execute = (command, ...args) => {
|
|
480
|
+
const fn = getCommand(command);
|
|
481
|
+
if (!fn) {
|
|
482
|
+
throw new CommandNotFoundError(command);
|
|
483
|
+
}
|
|
484
|
+
return fn(...args);
|
|
485
|
+
};
|
|
486
|
+
|
|
2524
487
|
const Two$1 = '2.0';
|
|
2525
|
-
const callbacks
|
|
2526
|
-
const get = id => {
|
|
2527
|
-
return callbacks
|
|
488
|
+
const callbacks = Object.create(null);
|
|
489
|
+
const get$1 = id => {
|
|
490
|
+
return callbacks[id];
|
|
2528
491
|
};
|
|
2529
|
-
const remove = id => {
|
|
2530
|
-
delete callbacks
|
|
492
|
+
const remove$1 = id => {
|
|
493
|
+
delete callbacks[id];
|
|
2531
494
|
};
|
|
2532
495
|
class JsonRpcError extends Error {
|
|
2533
496
|
constructor(message) {
|
|
@@ -2583,12 +546,12 @@ const constructError = (message, type, name) => {
|
|
|
2583
546
|
const joinLines = lines => {
|
|
2584
547
|
return lines.join(NewLine);
|
|
2585
548
|
};
|
|
2586
|
-
const splitLines = lines => {
|
|
549
|
+
const splitLines$1 = lines => {
|
|
2587
550
|
return lines.split(NewLine);
|
|
2588
551
|
};
|
|
2589
552
|
const getCurrentStack = () => {
|
|
2590
553
|
const stackLinesToSkip = 3;
|
|
2591
|
-
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
554
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
2592
555
|
return currentStack;
|
|
2593
556
|
};
|
|
2594
557
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
@@ -2602,7 +565,7 @@ const getParentStack = error => {
|
|
|
2602
565
|
return parentStack;
|
|
2603
566
|
};
|
|
2604
567
|
const MethodNotFound = -32601;
|
|
2605
|
-
const Custom
|
|
568
|
+
const Custom = -32001;
|
|
2606
569
|
const restoreJsonRpcError = error => {
|
|
2607
570
|
const currentStack = getCurrentStack();
|
|
2608
571
|
if (error && error instanceof Error) {
|
|
@@ -2672,14 +635,14 @@ const warn = (...args) => {
|
|
|
2672
635
|
console.warn(...args);
|
|
2673
636
|
};
|
|
2674
637
|
const resolve = (id, response) => {
|
|
2675
|
-
const fn = get(id);
|
|
638
|
+
const fn = get$1(id);
|
|
2676
639
|
if (!fn) {
|
|
2677
640
|
console.log(response);
|
|
2678
641
|
warn(`callback ${id} may already be disposed`);
|
|
2679
642
|
return;
|
|
2680
643
|
}
|
|
2681
644
|
fn(response);
|
|
2682
|
-
remove(id);
|
|
645
|
+
remove$1(id);
|
|
2683
646
|
};
|
|
2684
647
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
|
2685
648
|
const getErrorType = prettyError => {
|
|
@@ -2711,7 +674,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
2711
674
|
};
|
|
2712
675
|
}
|
|
2713
676
|
return {
|
|
2714
|
-
code: Custom
|
|
677
|
+
code: Custom,
|
|
2715
678
|
data: {
|
|
2716
679
|
code: prettyError.code,
|
|
2717
680
|
codeFrame: prettyError.codeFrame,
|
|
@@ -2735,7 +698,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
2735
698
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
2736
699
|
return create$1$1(id, errorProperty);
|
|
2737
700
|
};
|
|
2738
|
-
const create$
|
|
701
|
+
const create$8 = (message, result) => {
|
|
2739
702
|
return {
|
|
2740
703
|
id: message.id,
|
|
2741
704
|
jsonrpc: Two$1,
|
|
@@ -2744,12 +707,12 @@ const create$7 = (message, result) => {
|
|
|
2744
707
|
};
|
|
2745
708
|
const getSuccessResponse = (message, result) => {
|
|
2746
709
|
const resultProperty = result ?? null;
|
|
2747
|
-
return create$
|
|
710
|
+
return create$8(message, resultProperty);
|
|
2748
711
|
};
|
|
2749
712
|
const getErrorResponseSimple = (id, error) => {
|
|
2750
713
|
return {
|
|
2751
714
|
error: {
|
|
2752
|
-
code: Custom
|
|
715
|
+
code: Custom,
|
|
2753
716
|
data: error,
|
|
2754
717
|
// @ts-ignore
|
|
2755
718
|
message: error.message
|
|
@@ -2838,7 +801,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
2838
801
|
|
|
2839
802
|
const Two = '2.0';
|
|
2840
803
|
|
|
2841
|
-
const create$
|
|
804
|
+
const create$7 = (method, params) => {
|
|
2842
805
|
return {
|
|
2843
806
|
jsonrpc: Two,
|
|
2844
807
|
method,
|
|
@@ -2846,7 +809,7 @@ const create$6 = (method, params) => {
|
|
|
2846
809
|
};
|
|
2847
810
|
};
|
|
2848
811
|
|
|
2849
|
-
const create$
|
|
812
|
+
const create$6 = (id, method, params) => {
|
|
2850
813
|
const message = {
|
|
2851
814
|
id,
|
|
2852
815
|
jsonrpc: Two,
|
|
@@ -2857,12 +820,12 @@ const create$5 = (id, method, params) => {
|
|
|
2857
820
|
};
|
|
2858
821
|
|
|
2859
822
|
let id = 0;
|
|
2860
|
-
const create$
|
|
823
|
+
const create$5 = () => {
|
|
2861
824
|
return ++id;
|
|
2862
825
|
};
|
|
2863
826
|
|
|
2864
827
|
const registerPromise = map => {
|
|
2865
|
-
const id = create$
|
|
828
|
+
const id = create$5();
|
|
2866
829
|
const {
|
|
2867
830
|
promise,
|
|
2868
831
|
resolve
|
|
@@ -2879,7 +842,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
2879
842
|
id,
|
|
2880
843
|
promise
|
|
2881
844
|
} = registerPromise(callbacks);
|
|
2882
|
-
const message = create$
|
|
845
|
+
const message = create$6(id, method, params);
|
|
2883
846
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
2884
847
|
ipc.sendAndTransfer(message);
|
|
2885
848
|
} else {
|
|
@@ -2913,1147 +876,279 @@ const createRpc = ipc => {
|
|
|
2913
876
|
ipc,
|
|
2914
877
|
/**
|
|
2915
878
|
* @deprecated
|
|
2916
|
-
*/
|
|
2917
|
-
send(method, ...params) {
|
|
2918
|
-
const message = create$
|
|
2919
|
-
ipc.send(message);
|
|
2920
|
-
}
|
|
2921
|
-
};
|
|
2922
|
-
return rpc;
|
|
2923
|
-
};
|
|
2924
|
-
|
|
2925
|
-
const requiresSocket = () => {
|
|
2926
|
-
return false;
|
|
2927
|
-
};
|
|
2928
|
-
const preparePrettyError = error => {
|
|
2929
|
-
return error;
|
|
2930
|
-
};
|
|
2931
|
-
const logError = () => {
|
|
2932
|
-
// handled by renderer worker
|
|
2933
|
-
};
|
|
2934
|
-
const handleMessage = event => {
|
|
2935
|
-
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
2936
|
-
const actualExecute = event?.target?.execute || execute;
|
|
2937
|
-
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
2938
|
-
};
|
|
2939
|
-
|
|
2940
|
-
const handleIpc = ipc => {
|
|
2941
|
-
if ('addEventListener' in ipc) {
|
|
2942
|
-
ipc.addEventListener('message', handleMessage);
|
|
2943
|
-
} else if ('on' in ipc) {
|
|
2944
|
-
// deprecated
|
|
2945
|
-
ipc.on('message', handleMessage);
|
|
2946
|
-
}
|
|
2947
|
-
};
|
|
2948
|
-
|
|
2949
|
-
const listen$1 = async (module, options) => {
|
|
2950
|
-
const rawIpc = await module.listen(options);
|
|
2951
|
-
if (module.signal) {
|
|
2952
|
-
module.signal(rawIpc);
|
|
2953
|
-
}
|
|
2954
|
-
const ipc = module.wrap(rawIpc);
|
|
2955
|
-
return ipc;
|
|
2956
|
-
};
|
|
2957
|
-
|
|
2958
|
-
const create$3 = async ({
|
|
2959
|
-
commandMap,
|
|
2960
|
-
isMessagePortOpen = true,
|
|
2961
|
-
messagePort
|
|
2962
|
-
}) => {
|
|
2963
|
-
// TODO create a commandMap per rpc instance
|
|
2964
|
-
register$1(commandMap);
|
|
2965
|
-
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2966
|
-
isMessagePortOpen,
|
|
2967
|
-
messagePort
|
|
2968
|
-
});
|
|
2969
|
-
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2970
|
-
handleIpc(ipc);
|
|
2971
|
-
const rpc = createRpc(ipc);
|
|
2972
|
-
messagePort.start();
|
|
2973
|
-
return rpc;
|
|
2974
|
-
};
|
|
2975
|
-
|
|
2976
|
-
const create$2 = async ({
|
|
2977
|
-
commandMap,
|
|
2978
|
-
isMessagePortOpen,
|
|
2979
|
-
send
|
|
2980
|
-
}) => {
|
|
2981
|
-
const {
|
|
2982
|
-
port1,
|
|
2983
|
-
port2
|
|
2984
|
-
} = new MessageChannel();
|
|
2985
|
-
await send(port1);
|
|
2986
|
-
return create$3({
|
|
2987
|
-
commandMap,
|
|
2988
|
-
isMessagePortOpen,
|
|
2989
|
-
messagePort: port2
|
|
2990
|
-
});
|
|
2991
|
-
};
|
|
2992
|
-
|
|
2993
|
-
const createSharedLazyRpc = factory => {
|
|
2994
|
-
let rpcPromise;
|
|
2995
|
-
const getOrCreate = () => {
|
|
2996
|
-
if (!rpcPromise) {
|
|
2997
|
-
rpcPromise = factory();
|
|
2998
|
-
}
|
|
2999
|
-
return rpcPromise;
|
|
3000
|
-
};
|
|
3001
|
-
return {
|
|
3002
|
-
async dispose() {
|
|
3003
|
-
const rpc = await getOrCreate();
|
|
3004
|
-
await rpc.dispose();
|
|
3005
|
-
},
|
|
3006
|
-
async invoke(method, ...params) {
|
|
3007
|
-
const rpc = await getOrCreate();
|
|
3008
|
-
return rpc.invoke(method, ...params);
|
|
3009
|
-
},
|
|
3010
|
-
async invokeAndTransfer(method, ...params) {
|
|
3011
|
-
const rpc = await getOrCreate();
|
|
3012
|
-
return rpc.invokeAndTransfer(method, ...params);
|
|
3013
|
-
},
|
|
3014
|
-
async send(method, ...params) {
|
|
3015
|
-
const rpc = await getOrCreate();
|
|
3016
|
-
rpc.send(method, ...params);
|
|
3017
|
-
}
|
|
3018
|
-
};
|
|
3019
|
-
};
|
|
3020
|
-
|
|
3021
|
-
const create$1 = async ({
|
|
3022
|
-
commandMap,
|
|
3023
|
-
isMessagePortOpen,
|
|
3024
|
-
send
|
|
3025
|
-
}) => {
|
|
3026
|
-
return createSharedLazyRpc(() => {
|
|
3027
|
-
return create$2({
|
|
3028
|
-
commandMap,
|
|
3029
|
-
isMessagePortOpen,
|
|
3030
|
-
send
|
|
3031
|
-
});
|
|
3032
|
-
});
|
|
3033
|
-
};
|
|
3034
|
-
|
|
3035
|
-
const create = async ({
|
|
3036
|
-
commandMap
|
|
3037
|
-
}) => {
|
|
3038
|
-
// TODO create a commandMap per rpc instance
|
|
3039
|
-
register$1(commandMap);
|
|
3040
|
-
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
3041
|
-
handleIpc(ipc);
|
|
3042
|
-
const rpc = createRpc(ipc);
|
|
3043
|
-
return rpc;
|
|
3044
|
-
};
|
|
3045
|
-
|
|
3046
|
-
const commandMapRef = {};
|
|
3047
|
-
|
|
3048
|
-
const handleMessagePort = async port => {
|
|
3049
|
-
await create$3({
|
|
3050
|
-
commandMap: commandMapRef,
|
|
3051
|
-
isMessagePortOpen: true,
|
|
3052
|
-
messagePort: port
|
|
3053
|
-
});
|
|
3054
|
-
};
|
|
3055
|
-
|
|
3056
|
-
const initialize = async () => {
|
|
3057
|
-
// not needed anymore
|
|
3058
|
-
};
|
|
3059
|
-
|
|
3060
|
-
const getDefaultValue = id => {
|
|
3061
|
-
switch (id) {
|
|
3062
|
-
case EveryThing$1:
|
|
3063
|
-
return Command;
|
|
3064
|
-
default:
|
|
3065
|
-
return '';
|
|
3066
|
-
}
|
|
3067
|
-
};
|
|
3068
|
-
|
|
3069
|
-
const Commands = 'quickPick://commands';
|
|
3070
|
-
const EveryThing = 'quickPick://everything';
|
|
3071
|
-
const Recent = 'quickPick://recent';
|
|
3072
|
-
const ColorTheme = 'quickPick://color-theme';
|
|
3073
|
-
const Symbol$1 = 'quickPick://symbol';
|
|
3074
|
-
const View = 'quickPick://view';
|
|
3075
|
-
const Help = 'quickPick://help';
|
|
3076
|
-
const WorkspaceSymbol = 'quickPick://workspace-symbol';
|
|
3077
|
-
const Custom = 'quickPick://custom';
|
|
3078
|
-
const GoToLine = 'quickPick://go-to-line';
|
|
3079
|
-
|
|
3080
|
-
const getQuickPickProviderId = prefix => {
|
|
3081
|
-
switch (prefix) {
|
|
3082
|
-
case ColorTheme:
|
|
3083
|
-
return ColorTheme$1;
|
|
3084
|
-
case Commands:
|
|
3085
|
-
case EveryThing:
|
|
3086
|
-
case GoToLine:
|
|
3087
|
-
case Help:
|
|
3088
|
-
case Symbol$1:
|
|
3089
|
-
case View:
|
|
3090
|
-
case WorkspaceSymbol:
|
|
3091
|
-
return EveryThing$1;
|
|
3092
|
-
case Custom:
|
|
3093
|
-
return Custom$2;
|
|
3094
|
-
case Recent:
|
|
3095
|
-
return Recent$1;
|
|
3096
|
-
default:
|
|
3097
|
-
return File$2;
|
|
3098
|
-
}
|
|
3099
|
-
};
|
|
3100
|
-
|
|
3101
|
-
const parseArgs = (subId, args) => {
|
|
3102
|
-
if (subId !== Custom$2) {
|
|
3103
|
-
return {
|
|
3104
|
-
ignoreFocusOut: false,
|
|
3105
|
-
initialValue: ''
|
|
3106
|
-
};
|
|
3107
|
-
}
|
|
3108
|
-
const last = args.at(-1);
|
|
3109
|
-
if (!last || typeof last !== 'object') {
|
|
3110
|
-
return {
|
|
3111
|
-
ignoreFocusOut: false,
|
|
3112
|
-
initialValue: ''
|
|
3113
|
-
};
|
|
3114
|
-
}
|
|
3115
|
-
return {
|
|
3116
|
-
// @ts-ignore
|
|
3117
|
-
ignoreFocusOut: Boolean(last.ignoreFocusOut),
|
|
3118
|
-
// @ts-ignore
|
|
3119
|
-
initialValue: String(last.initialValue)
|
|
3120
|
-
};
|
|
3121
|
-
};
|
|
3122
|
-
const loadContent = async state => {
|
|
3123
|
-
const {
|
|
3124
|
-
args,
|
|
3125
|
-
assetDir,
|
|
3126
|
-
fileIconCache,
|
|
3127
|
-
height,
|
|
3128
|
-
itemHeight,
|
|
3129
|
-
maxVisibleItems,
|
|
3130
|
-
platform,
|
|
3131
|
-
uri
|
|
3132
|
-
} = state;
|
|
3133
|
-
const id = getQuickPickProviderId(uri);
|
|
3134
|
-
const value = getDefaultValue(id);
|
|
3135
|
-
const prefix = getQuickPickPrefix(value);
|
|
3136
|
-
const subId = getQuickPickSubProviderId(id, prefix);
|
|
3137
|
-
const newPicks = await getPicks(subId, value, args, {
|
|
3138
|
-
assetDir,
|
|
3139
|
-
platform
|
|
3140
|
-
});
|
|
3141
|
-
array(newPicks);
|
|
3142
|
-
const filterValue = getFilterValue(id, subId, value);
|
|
3143
|
-
const items = filterQuickPickItems(newPicks, filterValue);
|
|
3144
|
-
const minLineY = 0;
|
|
3145
|
-
const maxLineY = Math.min(minLineY + maxVisibleItems, newPicks.length);
|
|
3146
|
-
const sliced = newPicks.slice(minLineY, maxLineY);
|
|
3147
|
-
const {
|
|
3148
|
-
icons,
|
|
3149
|
-
newFileIconCache
|
|
3150
|
-
} = await getQuickPickFileIcons(sliced, fileIconCache);
|
|
3151
|
-
const listHeight = getListHeight(items.length, itemHeight, height);
|
|
3152
|
-
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
|
|
3153
|
-
const parsedArgs = parseArgs(subId, args);
|
|
3154
|
-
const finalValue = parsedArgs.initialValue || value;
|
|
3155
|
-
return {
|
|
3156
|
-
...state,
|
|
3157
|
-
args,
|
|
3158
|
-
cursorOffset: value.length,
|
|
3159
|
-
fileIconCache: newFileIconCache,
|
|
3160
|
-
finalDeltaY,
|
|
3161
|
-
focused: true,
|
|
3162
|
-
focusedIndex: 0,
|
|
3163
|
-
icons,
|
|
3164
|
-
initial: false,
|
|
3165
|
-
inputSource: Script,
|
|
3166
|
-
items,
|
|
3167
|
-
maxLineY,
|
|
3168
|
-
minLineY,
|
|
3169
|
-
picks: newPicks,
|
|
3170
|
-
placeholder: '',
|
|
3171
|
-
providerId: id,
|
|
3172
|
-
state: Finished,
|
|
3173
|
-
value: finalValue
|
|
3174
|
-
};
|
|
3175
|
-
};
|
|
3176
|
-
|
|
3177
|
-
const callbacks = Object.create(null);
|
|
3178
|
-
const executeCallback = id => {
|
|
3179
|
-
const fn = callbacks[id];
|
|
3180
|
-
delete callbacks[id];
|
|
3181
|
-
fn();
|
|
3182
|
-
};
|
|
3183
|
-
|
|
3184
|
-
const SetCursorOffset = 'setCursorOffset';
|
|
3185
|
-
const SetFocusedIndex = 'setFocusedIndex';
|
|
3186
|
-
const SetItemsHeight = 'setItemsHeight';
|
|
3187
|
-
|
|
3188
|
-
const renderCursorOffset = (_oldState, newState) => {
|
|
3189
|
-
return ['Viewlet.send', newState.uid, /* method */SetCursorOffset, /* cursorOffset */newState.cursorOffset];
|
|
3190
|
-
};
|
|
3191
|
-
|
|
3192
|
-
const QuickPickInput = 'QuickPickInput';
|
|
3193
|
-
|
|
3194
|
-
const renderFocus = (_oldState, _newState) => {
|
|
3195
|
-
return ['Viewlet.focusElementByName', QuickPickInput];
|
|
3196
|
-
};
|
|
3197
|
-
|
|
3198
|
-
const renderFocusedIndex = (oldState, newState) => {
|
|
3199
|
-
const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
|
|
3200
|
-
const newFocusedIndex = newState.focusedIndex - newState.minLineY;
|
|
3201
|
-
return ['Viewlet.send', newState.uid, /* method */SetFocusedIndex, /* oldFocusedIndex */oldFocusedIndex, /* newFocusedIndex */newFocusedIndex];
|
|
3202
|
-
};
|
|
3203
|
-
|
|
3204
|
-
const renderHeight = (_oldState, newState) => {
|
|
3205
|
-
const {
|
|
3206
|
-
height,
|
|
3207
|
-
uid
|
|
3208
|
-
} = newState;
|
|
3209
|
-
if (height === 0) {
|
|
3210
|
-
return ['Viewlet.send', uid, /* method */SetItemsHeight, /* height */20];
|
|
3211
|
-
}
|
|
3212
|
-
return ['Viewlet.send', uid, /* method */SetItemsHeight, /* height */height];
|
|
3213
|
-
};
|
|
3214
|
-
|
|
3215
|
-
const Div = 4;
|
|
3216
|
-
const Input = 6;
|
|
3217
|
-
const Span = 8;
|
|
3218
|
-
const Text = 12;
|
|
3219
|
-
const Img = 17;
|
|
3220
|
-
const Reference = 100;
|
|
3221
|
-
|
|
3222
|
-
const mergeClassNames = (...classNames) => {
|
|
3223
|
-
return classNames.filter(Boolean).join(' ');
|
|
3224
|
-
};
|
|
3225
|
-
|
|
3226
|
-
const px = value => {
|
|
3227
|
-
return `${value}px`;
|
|
3228
|
-
};
|
|
3229
|
-
const position = (x, y) => {
|
|
3230
|
-
return `${x}px ${y}px`;
|
|
3231
|
-
};
|
|
3232
|
-
|
|
3233
|
-
const text = data => {
|
|
3234
|
-
return {
|
|
3235
|
-
childCount: 0,
|
|
3236
|
-
text: data,
|
|
3237
|
-
type: Text
|
|
3238
|
-
};
|
|
3239
|
-
};
|
|
3240
|
-
|
|
3241
|
-
const SetText = 1;
|
|
3242
|
-
const Replace = 2;
|
|
3243
|
-
const SetAttribute = 3;
|
|
3244
|
-
const RemoveAttribute = 4;
|
|
3245
|
-
const Add = 6;
|
|
3246
|
-
const NavigateChild = 7;
|
|
3247
|
-
const NavigateParent = 8;
|
|
3248
|
-
const RemoveChild = 9;
|
|
3249
|
-
const NavigateSibling = 10;
|
|
3250
|
-
const SetReferenceNodeUid = 11;
|
|
3251
|
-
|
|
3252
|
-
const isKey = key => {
|
|
3253
|
-
return key !== 'type' && key !== 'childCount';
|
|
3254
|
-
};
|
|
3255
|
-
|
|
3256
|
-
const getKeys = node => {
|
|
3257
|
-
const keys = Object.keys(node).filter(isKey);
|
|
3258
|
-
return keys;
|
|
3259
|
-
};
|
|
3260
|
-
|
|
3261
|
-
const arrayToTree = nodes => {
|
|
3262
|
-
const result = [];
|
|
3263
|
-
let i = 0;
|
|
3264
|
-
while (i < nodes.length) {
|
|
3265
|
-
const node = nodes[i];
|
|
3266
|
-
const {
|
|
3267
|
-
children,
|
|
3268
|
-
nodesConsumed
|
|
3269
|
-
} = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
|
|
3270
|
-
result.push({
|
|
3271
|
-
node,
|
|
3272
|
-
children
|
|
3273
|
-
});
|
|
3274
|
-
i += 1 + nodesConsumed;
|
|
3275
|
-
}
|
|
3276
|
-
return result;
|
|
3277
|
-
};
|
|
3278
|
-
const getChildrenWithCount = (nodes, startIndex, childCount) => {
|
|
3279
|
-
if (childCount === 0) {
|
|
3280
|
-
return {
|
|
3281
|
-
children: [],
|
|
3282
|
-
nodesConsumed: 0
|
|
3283
|
-
};
|
|
3284
|
-
}
|
|
3285
|
-
const children = [];
|
|
3286
|
-
let i = startIndex;
|
|
3287
|
-
let remaining = childCount;
|
|
3288
|
-
let totalConsumed = 0;
|
|
3289
|
-
while (remaining > 0 && i < nodes.length) {
|
|
3290
|
-
const node = nodes[i];
|
|
3291
|
-
const nodeChildCount = node.childCount || 0;
|
|
3292
|
-
const {
|
|
3293
|
-
children: nodeChildren,
|
|
3294
|
-
nodesConsumed
|
|
3295
|
-
} = getChildrenWithCount(nodes, i + 1, nodeChildCount);
|
|
3296
|
-
children.push({
|
|
3297
|
-
node,
|
|
3298
|
-
children: nodeChildren
|
|
3299
|
-
});
|
|
3300
|
-
const nodeSize = 1 + nodesConsumed;
|
|
3301
|
-
i += nodeSize;
|
|
3302
|
-
totalConsumed += nodeSize;
|
|
3303
|
-
remaining--;
|
|
3304
|
-
}
|
|
3305
|
-
return {
|
|
3306
|
-
children,
|
|
3307
|
-
nodesConsumed: totalConsumed
|
|
3308
|
-
};
|
|
3309
|
-
};
|
|
3310
|
-
|
|
3311
|
-
const compareNodes = (oldNode, newNode) => {
|
|
3312
|
-
const patches = [];
|
|
3313
|
-
// Check if node type changed - return null to signal incompatible nodes
|
|
3314
|
-
// (caller should handle this with a Replace operation)
|
|
3315
|
-
if (oldNode.type !== newNode.type) {
|
|
3316
|
-
return null;
|
|
3317
|
-
}
|
|
3318
|
-
// Handle reference nodes - special handling for uid changes
|
|
3319
|
-
if (oldNode.type === Reference) {
|
|
3320
|
-
if (oldNode.uid !== newNode.uid) {
|
|
3321
|
-
patches.push({
|
|
3322
|
-
type: SetReferenceNodeUid,
|
|
3323
|
-
uid: newNode.uid
|
|
3324
|
-
});
|
|
3325
|
-
}
|
|
3326
|
-
return patches;
|
|
3327
|
-
}
|
|
3328
|
-
// Handle text nodes
|
|
3329
|
-
if (oldNode.type === Text && newNode.type === Text) {
|
|
3330
|
-
if (oldNode.text !== newNode.text) {
|
|
3331
|
-
patches.push({
|
|
3332
|
-
type: SetText,
|
|
3333
|
-
value: newNode.text
|
|
3334
|
-
});
|
|
3335
|
-
}
|
|
3336
|
-
return patches;
|
|
3337
|
-
}
|
|
3338
|
-
// Compare attributes
|
|
3339
|
-
const oldKeys = getKeys(oldNode);
|
|
3340
|
-
const newKeys = getKeys(newNode);
|
|
3341
|
-
// Check for attribute changes
|
|
3342
|
-
for (const key of newKeys) {
|
|
3343
|
-
if (oldNode[key] !== newNode[key]) {
|
|
3344
|
-
patches.push({
|
|
3345
|
-
type: SetAttribute,
|
|
3346
|
-
key,
|
|
3347
|
-
value: newNode[key]
|
|
3348
|
-
});
|
|
3349
|
-
}
|
|
3350
|
-
}
|
|
3351
|
-
// Check for removed attributes
|
|
3352
|
-
for (const key of oldKeys) {
|
|
3353
|
-
if (!(key in newNode)) {
|
|
3354
|
-
patches.push({
|
|
3355
|
-
type: RemoveAttribute,
|
|
3356
|
-
key
|
|
3357
|
-
});
|
|
3358
|
-
}
|
|
3359
|
-
}
|
|
3360
|
-
return patches;
|
|
3361
|
-
};
|
|
3362
|
-
|
|
3363
|
-
const treeToArray = node => {
|
|
3364
|
-
const result = [node.node];
|
|
3365
|
-
for (const child of node.children) {
|
|
3366
|
-
result.push(...treeToArray(child));
|
|
3367
|
-
}
|
|
3368
|
-
return result;
|
|
3369
|
-
};
|
|
3370
|
-
|
|
3371
|
-
const diffChildren = (oldChildren, newChildren, patches) => {
|
|
3372
|
-
const maxLength = Math.max(oldChildren.length, newChildren.length);
|
|
3373
|
-
// Track where we are: -1 means at parent, >= 0 means at child index
|
|
3374
|
-
let currentChildIndex = -1;
|
|
3375
|
-
// Collect indices of children to remove (we'll add these patches at the end in reverse order)
|
|
3376
|
-
const indicesToRemove = [];
|
|
3377
|
-
for (let i = 0; i < maxLength; i++) {
|
|
3378
|
-
const oldNode = oldChildren[i];
|
|
3379
|
-
const newNode = newChildren[i];
|
|
3380
|
-
if (!oldNode && !newNode) {
|
|
3381
|
-
continue;
|
|
3382
|
-
}
|
|
3383
|
-
if (!oldNode) {
|
|
3384
|
-
// Add new node - we should be at the parent
|
|
3385
|
-
if (currentChildIndex >= 0) {
|
|
3386
|
-
// Navigate back to parent
|
|
3387
|
-
patches.push({
|
|
3388
|
-
type: NavigateParent
|
|
3389
|
-
});
|
|
3390
|
-
currentChildIndex = -1;
|
|
3391
|
-
}
|
|
3392
|
-
// Flatten the entire subtree so renderInternal can handle it
|
|
3393
|
-
const flatNodes = treeToArray(newNode);
|
|
3394
|
-
patches.push({
|
|
3395
|
-
type: Add,
|
|
3396
|
-
nodes: flatNodes
|
|
3397
|
-
});
|
|
3398
|
-
} else if (newNode) {
|
|
3399
|
-
// Compare nodes to see if we need any patches
|
|
3400
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
3401
|
-
// If nodePatches is null, the node types are incompatible - need to replace
|
|
3402
|
-
if (nodePatches === null) {
|
|
3403
|
-
// Navigate to this child
|
|
3404
|
-
if (currentChildIndex === -1) {
|
|
3405
|
-
patches.push({
|
|
3406
|
-
type: NavigateChild,
|
|
3407
|
-
index: i
|
|
3408
|
-
});
|
|
3409
|
-
currentChildIndex = i;
|
|
3410
|
-
} else if (currentChildIndex !== i) {
|
|
3411
|
-
patches.push({
|
|
3412
|
-
type: NavigateSibling,
|
|
3413
|
-
index: i
|
|
3414
|
-
});
|
|
3415
|
-
currentChildIndex = i;
|
|
3416
|
-
}
|
|
3417
|
-
// Replace the entire subtree
|
|
3418
|
-
const flatNodes = treeToArray(newNode);
|
|
3419
|
-
patches.push({
|
|
3420
|
-
type: Replace,
|
|
3421
|
-
nodes: flatNodes
|
|
3422
|
-
});
|
|
3423
|
-
// After replace, we're at the new element (same position)
|
|
3424
|
-
continue;
|
|
3425
|
-
}
|
|
3426
|
-
// Check if we need to recurse into children
|
|
3427
|
-
const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
|
|
3428
|
-
// Only navigate to this element if we need to do something
|
|
3429
|
-
if (nodePatches.length > 0 || hasChildrenToCompare) {
|
|
3430
|
-
// Navigate to this child if not already there
|
|
3431
|
-
if (currentChildIndex === -1) {
|
|
3432
|
-
patches.push({
|
|
3433
|
-
type: NavigateChild,
|
|
3434
|
-
index: i
|
|
3435
|
-
});
|
|
3436
|
-
currentChildIndex = i;
|
|
3437
|
-
} else if (currentChildIndex !== i) {
|
|
3438
|
-
patches.push({
|
|
3439
|
-
type: NavigateSibling,
|
|
3440
|
-
index: i
|
|
3441
|
-
});
|
|
3442
|
-
currentChildIndex = i;
|
|
3443
|
-
}
|
|
3444
|
-
// Apply node patches (these apply to the current element, not children)
|
|
3445
|
-
if (nodePatches.length > 0) {
|
|
3446
|
-
patches.push(...nodePatches);
|
|
3447
|
-
}
|
|
3448
|
-
// Compare children recursively
|
|
3449
|
-
if (hasChildrenToCompare) {
|
|
3450
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
3451
|
-
}
|
|
3452
|
-
}
|
|
3453
|
-
} else {
|
|
3454
|
-
// Remove old node - collect the index for later removal
|
|
3455
|
-
indicesToRemove.push(i);
|
|
3456
|
-
}
|
|
3457
|
-
}
|
|
3458
|
-
// Navigate back to parent if we ended at a child
|
|
3459
|
-
if (currentChildIndex >= 0) {
|
|
3460
|
-
patches.push({
|
|
3461
|
-
type: NavigateParent
|
|
3462
|
-
});
|
|
3463
|
-
currentChildIndex = -1;
|
|
3464
|
-
}
|
|
3465
|
-
// Add remove patches in reverse order (highest index first)
|
|
3466
|
-
// This ensures indices remain valid as we remove
|
|
3467
|
-
for (let j = indicesToRemove.length - 1; j >= 0; j--) {
|
|
3468
|
-
patches.push({
|
|
3469
|
-
type: RemoveChild,
|
|
3470
|
-
index: indicesToRemove[j]
|
|
3471
|
-
});
|
|
3472
|
-
}
|
|
3473
|
-
};
|
|
3474
|
-
const diffTrees = (oldTree, newTree, patches, path) => {
|
|
3475
|
-
// At the root level (path.length === 0), we're already AT the element
|
|
3476
|
-
// So we compare the root node directly, then compare its children
|
|
3477
|
-
if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
|
|
3478
|
-
const oldNode = oldTree[0];
|
|
3479
|
-
const newNode = newTree[0];
|
|
3480
|
-
// Compare root nodes
|
|
3481
|
-
const nodePatches = compareNodes(oldNode.node, newNode.node);
|
|
3482
|
-
// If nodePatches is null, the root node types are incompatible - need to replace
|
|
3483
|
-
if (nodePatches === null) {
|
|
3484
|
-
const flatNodes = treeToArray(newNode);
|
|
3485
|
-
patches.push({
|
|
3486
|
-
type: Replace,
|
|
3487
|
-
nodes: flatNodes
|
|
3488
|
-
});
|
|
3489
|
-
return;
|
|
3490
|
-
}
|
|
3491
|
-
if (nodePatches.length > 0) {
|
|
3492
|
-
patches.push(...nodePatches);
|
|
3493
|
-
}
|
|
3494
|
-
// Compare children
|
|
3495
|
-
if (oldNode.children.length > 0 || newNode.children.length > 0) {
|
|
3496
|
-
diffChildren(oldNode.children, newNode.children, patches);
|
|
3497
|
-
}
|
|
3498
|
-
} else {
|
|
3499
|
-
// Non-root level or multiple root elements - use the regular comparison
|
|
3500
|
-
diffChildren(oldTree, newTree, patches);
|
|
3501
|
-
}
|
|
3502
|
-
};
|
|
3503
|
-
|
|
3504
|
-
const removeTrailingNavigationPatches = patches => {
|
|
3505
|
-
// Find the last non-navigation patch
|
|
3506
|
-
let lastNonNavigationIndex = -1;
|
|
3507
|
-
for (let i = patches.length - 1; i >= 0; i--) {
|
|
3508
|
-
const patch = patches[i];
|
|
3509
|
-
if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
|
|
3510
|
-
lastNonNavigationIndex = i;
|
|
3511
|
-
break;
|
|
879
|
+
*/
|
|
880
|
+
send(method, ...params) {
|
|
881
|
+
const message = create$7(method, params);
|
|
882
|
+
ipc.send(message);
|
|
3512
883
|
}
|
|
3513
|
-
}
|
|
3514
|
-
|
|
3515
|
-
return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
|
|
884
|
+
};
|
|
885
|
+
return rpc;
|
|
3516
886
|
};
|
|
3517
887
|
|
|
3518
|
-
const
|
|
3519
|
-
|
|
3520
|
-
const oldTree = arrayToTree(oldNodes);
|
|
3521
|
-
const newTree = arrayToTree(newNodes);
|
|
3522
|
-
// Step 3: Compare the trees
|
|
3523
|
-
const patches = [];
|
|
3524
|
-
diffTrees(oldTree, newTree, patches, []);
|
|
3525
|
-
// Remove trailing navigation patches since they serve no purpose
|
|
3526
|
-
return removeTrailingNavigationPatches(patches);
|
|
888
|
+
const requiresSocket = () => {
|
|
889
|
+
return false;
|
|
3527
890
|
};
|
|
3528
|
-
|
|
3529
|
-
|
|
3530
|
-
|
|
3531
|
-
|
|
3532
|
-
|
|
3533
|
-
|
|
3534
|
-
|
|
3535
|
-
|
|
3536
|
-
|
|
3537
|
-
return
|
|
891
|
+
const preparePrettyError = error => {
|
|
892
|
+
return error;
|
|
893
|
+
};
|
|
894
|
+
const logError = () => {
|
|
895
|
+
// handled by renderer worker
|
|
896
|
+
};
|
|
897
|
+
const handleMessage = event => {
|
|
898
|
+
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
899
|
+
const actualExecute = event?.target?.execute || execute;
|
|
900
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
3538
901
|
};
|
|
3539
902
|
|
|
3540
|
-
const
|
|
3541
|
-
if (
|
|
3542
|
-
|
|
903
|
+
const handleIpc = ipc => {
|
|
904
|
+
if ('addEventListener' in ipc) {
|
|
905
|
+
ipc.addEventListener('message', handleMessage);
|
|
906
|
+
} else if ('on' in ipc) {
|
|
907
|
+
// deprecated
|
|
908
|
+
ipc.on('message', handleMessage);
|
|
3543
909
|
}
|
|
3544
|
-
return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
|
|
3545
910
|
};
|
|
3546
911
|
|
|
3547
|
-
const
|
|
3548
|
-
|
|
3549
|
-
|
|
3550
|
-
|
|
3551
|
-
return emptyHighlightSections;
|
|
3552
|
-
}
|
|
3553
|
-
const sections = [];
|
|
3554
|
-
let position = 0;
|
|
3555
|
-
for (let i = 0; i < highlights.length; i += 2) {
|
|
3556
|
-
const highlightStart = highlights[i];
|
|
3557
|
-
const highlightEnd = highlights[i + 1];
|
|
3558
|
-
if (position < highlightStart) {
|
|
3559
|
-
const beforeText = label.slice(position, highlightStart);
|
|
3560
|
-
sections.push({
|
|
3561
|
-
highlighted: false,
|
|
3562
|
-
text: beforeText
|
|
3563
|
-
});
|
|
3564
|
-
}
|
|
3565
|
-
const highlightText = label.slice(highlightStart, highlightEnd);
|
|
3566
|
-
sections.push({
|
|
3567
|
-
highlighted: true,
|
|
3568
|
-
text: highlightText
|
|
3569
|
-
});
|
|
3570
|
-
position = highlightEnd;
|
|
3571
|
-
}
|
|
3572
|
-
if (position < label.length) {
|
|
3573
|
-
const afterText = label.slice(position);
|
|
3574
|
-
sections.push({
|
|
3575
|
-
highlighted: false,
|
|
3576
|
-
text: afterText
|
|
3577
|
-
});
|
|
912
|
+
const listen$1 = async (module, options) => {
|
|
913
|
+
const rawIpc = await module.listen(options);
|
|
914
|
+
if (module.signal) {
|
|
915
|
+
module.signal(rawIpc);
|
|
3578
916
|
}
|
|
3579
|
-
|
|
917
|
+
const ipc = module.wrap(rawIpc);
|
|
918
|
+
return ipc;
|
|
3580
919
|
};
|
|
3581
920
|
|
|
3582
|
-
const
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
|
|
3586
|
-
|
|
3587
|
-
|
|
3588
|
-
|
|
3589
|
-
|
|
3590
|
-
|
|
3591
|
-
|
|
3592
|
-
};
|
|
921
|
+
const create$4 = async ({
|
|
922
|
+
commandMap,
|
|
923
|
+
isMessagePortOpen = true,
|
|
924
|
+
messagePort
|
|
925
|
+
}) => {
|
|
926
|
+
// TODO create a commandMap per rpc instance
|
|
927
|
+
register$1(commandMap);
|
|
928
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
929
|
+
isMessagePortOpen,
|
|
930
|
+
messagePort
|
|
3593
931
|
});
|
|
3594
|
-
|
|
3595
|
-
|
|
3596
|
-
|
|
3597
|
-
|
|
3598
|
-
|
|
3599
|
-
return scrollBarOffset;
|
|
932
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
933
|
+
handleIpc(ipc);
|
|
934
|
+
const rpc = createRpc(ipc);
|
|
935
|
+
messagePort.start();
|
|
936
|
+
return rpc;
|
|
3600
937
|
};
|
|
3601
|
-
const getScrollBarY = getScrollBarOffset;
|
|
3602
938
|
|
|
3603
|
-
const
|
|
939
|
+
const create$3 = async ({
|
|
940
|
+
commandMap,
|
|
941
|
+
isMessagePortOpen,
|
|
942
|
+
send
|
|
943
|
+
}) => {
|
|
3604
944
|
const {
|
|
3605
|
-
|
|
3606
|
-
|
|
3607
|
-
|
|
3608
|
-
|
|
3609
|
-
|
|
3610
|
-
|
|
3611
|
-
|
|
3612
|
-
|
|
3613
|
-
|
|
3614
|
-
items,
|
|
3615
|
-
maxLineY,
|
|
3616
|
-
minimumSliderSize,
|
|
3617
|
-
minLineY,
|
|
3618
|
-
uid,
|
|
3619
|
-
value
|
|
3620
|
-
} = newState;
|
|
3621
|
-
const protoVisibleItems = getVisible$1(items, minLineY, maxLineY, icons);
|
|
3622
|
-
const visibleItems = getVisible(items.length, protoVisibleItems, minLineY, focusedIndex);
|
|
3623
|
-
const newFocusedIndex = focusedIndex - minLineY;
|
|
3624
|
-
const itemCount = items.length;
|
|
3625
|
-
const listHeight = getListHeight(itemCount, itemHeight, height);
|
|
3626
|
-
const contentHeight = itemCount * itemHeight;
|
|
3627
|
-
const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
|
|
3628
|
-
const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
|
|
3629
|
-
const roundedScrollBarY = Math.round(scrollBarY);
|
|
3630
|
-
return {
|
|
3631
|
-
cursorOffset,
|
|
3632
|
-
focused,
|
|
3633
|
-
height,
|
|
3634
|
-
newFocusedIndex,
|
|
3635
|
-
scrollBarHeight,
|
|
3636
|
-
scrollBarTop: roundedScrollBarY,
|
|
3637
|
-
uid,
|
|
3638
|
-
value,
|
|
3639
|
-
visibleItems
|
|
3640
|
-
};
|
|
945
|
+
port1,
|
|
946
|
+
port2
|
|
947
|
+
} = new MessageChannel();
|
|
948
|
+
await send(port1);
|
|
949
|
+
return create$4({
|
|
950
|
+
commandMap,
|
|
951
|
+
isMessagePortOpen,
|
|
952
|
+
messagePort: port2
|
|
953
|
+
});
|
|
3641
954
|
};
|
|
3642
955
|
|
|
3643
|
-
const
|
|
3644
|
-
|
|
3645
|
-
const
|
|
3646
|
-
|
|
3647
|
-
|
|
3648
|
-
|
|
3649
|
-
|
|
3650
|
-
const InputBox = 'InputBox';
|
|
3651
|
-
const Label = 'Label';
|
|
3652
|
-
const List = 'List';
|
|
3653
|
-
const ListItems = 'ListItems';
|
|
3654
|
-
const MaskIcon = 'MaskIcon';
|
|
3655
|
-
const QuickPick$1 = 'QuickPick';
|
|
3656
|
-
const QuickPickHeader = 'QuickPickHeader';
|
|
3657
|
-
const QuickPickHighlight = 'QuickPickHighlight';
|
|
3658
|
-
const QuickPickItem = 'QuickPickItem';
|
|
3659
|
-
const QuickPickItemActive$1 = 'QuickPickItemActive';
|
|
3660
|
-
const QuickPickItemDescription = 'QuickPickItemDescription';
|
|
3661
|
-
const QuickPickItemLabel = 'QuickPickItemLabel';
|
|
3662
|
-
const QuickPickMaskIcon = 'QuickPickMaskIcon';
|
|
3663
|
-
const QuickPickStatus = 'QuickPickStatus';
|
|
3664
|
-
const ScrollBar = 'ScrollBar';
|
|
3665
|
-
const ScrollBarSmall = 'ScrollBarSmall';
|
|
3666
|
-
const ScrollBarThumb = 'ScrollBarThumb';
|
|
3667
|
-
const Viewlet = 'Viewlet';
|
|
3668
|
-
|
|
3669
|
-
const HandleWheel = 'handleWheel';
|
|
3670
|
-
const HandlePointerDown = 'handlePointerDown';
|
|
3671
|
-
const HandleBeforeInput = 'handleBeforeInput';
|
|
3672
|
-
const HandleBlur = 'handleBlur';
|
|
3673
|
-
const HandleFocus = 'handleFocus';
|
|
3674
|
-
const HandleInput = 'handleInput';
|
|
3675
|
-
|
|
3676
|
-
const QuickPick = 'QuickPick';
|
|
3677
|
-
const QuickPickItems = 'QuickPickItems';
|
|
3678
|
-
const QuickPickItemActive = 'QuickPickItemActive';
|
|
3679
|
-
|
|
3680
|
-
const getQuickPickInputVirtualDom = () => {
|
|
3681
|
-
const ariaLabel = typeNameofCommandToRun();
|
|
3682
|
-
return {
|
|
3683
|
-
ariaAutoComplete: 'list',
|
|
3684
|
-
ariaExpanded: true,
|
|
3685
|
-
ariaLabel: ariaLabel,
|
|
3686
|
-
autocapitalize: 'off',
|
|
3687
|
-
autocomplete: 'off',
|
|
3688
|
-
childCount: 0,
|
|
3689
|
-
className: InputBox,
|
|
3690
|
-
inputType: 'text',
|
|
3691
|
-
name: QuickPickInput,
|
|
3692
|
-
onBeforeInput: HandleBeforeInput,
|
|
3693
|
-
onBlur: HandleBlur,
|
|
3694
|
-
onFocus: HandleFocus,
|
|
3695
|
-
onInput: HandleInput,
|
|
3696
|
-
role: ComboBox,
|
|
3697
|
-
spellcheck: false,
|
|
3698
|
-
type: Input
|
|
956
|
+
const createSharedLazyRpc = factory => {
|
|
957
|
+
let rpcPromise;
|
|
958
|
+
const getOrCreate = () => {
|
|
959
|
+
if (!rpcPromise) {
|
|
960
|
+
rpcPromise = factory();
|
|
961
|
+
}
|
|
962
|
+
return rpcPromise;
|
|
3699
963
|
};
|
|
3700
|
-
};
|
|
3701
|
-
|
|
3702
|
-
const getQuickPickHeaderVirtualDom = () => {
|
|
3703
|
-
return [{
|
|
3704
|
-
childCount: 1,
|
|
3705
|
-
className: QuickPickHeader,
|
|
3706
|
-
type: Div
|
|
3707
|
-
}, getQuickPickInputVirtualDom()];
|
|
3708
|
-
};
|
|
3709
|
-
|
|
3710
|
-
const getFileIconVirtualDom = icon => {
|
|
3711
964
|
return {
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
|
|
3715
|
-
|
|
3716
|
-
|
|
3717
|
-
|
|
3718
|
-
|
|
3719
|
-
|
|
3720
|
-
|
|
3721
|
-
|
|
3722
|
-
|
|
3723
|
-
|
|
3724
|
-
|
|
3725
|
-
const
|
|
3726
|
-
|
|
3727
|
-
childCount: 0,
|
|
3728
|
-
className: QuickPickItemLabel,
|
|
3729
|
-
type: Div
|
|
3730
|
-
};
|
|
3731
|
-
const nodes = [labelDom];
|
|
3732
|
-
if (sections.length === 0) {
|
|
3733
|
-
labelDom.childCount++;
|
|
3734
|
-
nodes.push(text(label));
|
|
3735
|
-
} else {
|
|
3736
|
-
for (const section of sections) {
|
|
3737
|
-
if (section.highlighted) {
|
|
3738
|
-
labelDom.childCount++;
|
|
3739
|
-
nodes.push(quickPickHighlight, text(section.text));
|
|
3740
|
-
} else {
|
|
3741
|
-
labelDom.childCount++;
|
|
3742
|
-
nodes.push(text(section.text));
|
|
3743
|
-
}
|
|
965
|
+
async dispose() {
|
|
966
|
+
const rpc = await getOrCreate();
|
|
967
|
+
await rpc.dispose();
|
|
968
|
+
},
|
|
969
|
+
async invoke(method, ...params) {
|
|
970
|
+
const rpc = await getOrCreate();
|
|
971
|
+
return rpc.invoke(method, ...params);
|
|
972
|
+
},
|
|
973
|
+
async invokeAndTransfer(method, ...params) {
|
|
974
|
+
const rpc = await getOrCreate();
|
|
975
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
976
|
+
},
|
|
977
|
+
async send(method, ...params) {
|
|
978
|
+
const rpc = await getOrCreate();
|
|
979
|
+
rpc.send(method, ...params);
|
|
3744
980
|
}
|
|
3745
|
-
}
|
|
3746
|
-
return nodes;
|
|
981
|
+
};
|
|
3747
982
|
};
|
|
3748
983
|
|
|
3749
|
-
const
|
|
3750
|
-
|
|
3751
|
-
|
|
3752
|
-
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
} = visibleItem;
|
|
3760
|
-
const dom = [{
|
|
3761
|
-
ariaPosInSet: posInSet,
|
|
3762
|
-
ariaSetSize: setSize,
|
|
3763
|
-
childCount: 1,
|
|
3764
|
-
className: QuickPickItem,
|
|
3765
|
-
role: Option,
|
|
3766
|
-
type: Div
|
|
3767
|
-
}];
|
|
3768
|
-
const parent = dom[0];
|
|
3769
|
-
if (isActive) {
|
|
3770
|
-
parent.id = QuickPickItemActive;
|
|
3771
|
-
parent.className += ' ' + QuickPickItemActive$1;
|
|
3772
|
-
}
|
|
3773
|
-
if (fileIcon) {
|
|
3774
|
-
parent.childCount++;
|
|
3775
|
-
dom.push(getFileIconVirtualDom(fileIcon));
|
|
3776
|
-
} else if (icon) {
|
|
3777
|
-
parent.childCount++;
|
|
3778
|
-
dom.push({
|
|
3779
|
-
childCount: 0,
|
|
3780
|
-
className: mergeClassNames(QuickPickMaskIcon, MaskIcon, `MaskIcon${icon}`),
|
|
3781
|
-
type: Div
|
|
984
|
+
const create$2 = async ({
|
|
985
|
+
commandMap,
|
|
986
|
+
isMessagePortOpen,
|
|
987
|
+
send
|
|
988
|
+
}) => {
|
|
989
|
+
return createSharedLazyRpc(() => {
|
|
990
|
+
return create$3({
|
|
991
|
+
commandMap,
|
|
992
|
+
isMessagePortOpen,
|
|
993
|
+
send
|
|
3782
994
|
});
|
|
3783
|
-
}
|
|
3784
|
-
const highlightDom = getHighlights(highlights, label);
|
|
3785
|
-
dom.push(...highlightDom);
|
|
3786
|
-
if (description) {
|
|
3787
|
-
parent.childCount++;
|
|
3788
|
-
dom.push({
|
|
3789
|
-
childCount: 1,
|
|
3790
|
-
className: QuickPickItemDescription,
|
|
3791
|
-
type: Div
|
|
3792
|
-
}, text(description));
|
|
3793
|
-
}
|
|
3794
|
-
return dom;
|
|
995
|
+
});
|
|
3795
996
|
};
|
|
3796
997
|
|
|
3797
|
-
const
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
type: Div
|
|
3807
|
-
}, text(noResults$1)];
|
|
998
|
+
const create$1 = async ({
|
|
999
|
+
commandMap
|
|
1000
|
+
}) => {
|
|
1001
|
+
// TODO create a commandMap per rpc instance
|
|
1002
|
+
register$1(commandMap);
|
|
1003
|
+
const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
|
|
1004
|
+
handleIpc(ipc);
|
|
1005
|
+
const rpc = createRpc(ipc);
|
|
1006
|
+
return rpc;
|
|
3808
1007
|
};
|
|
3809
1008
|
|
|
3810
|
-
const
|
|
3811
|
-
if (visibleItems.length === 0) {
|
|
3812
|
-
return getQuickPickNoResultsVirtualDom();
|
|
3813
|
-
}
|
|
3814
|
-
const dom = visibleItems.flatMap(getQuickPickItemVirtualDom);
|
|
3815
|
-
return dom;
|
|
3816
|
-
};
|
|
1009
|
+
const commandMapRef = {};
|
|
3817
1010
|
|
|
3818
|
-
const
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
|
|
3823
|
-
|
|
3824
|
-
const translateString = position(0, scrollBarTop);
|
|
3825
|
-
return [{
|
|
3826
|
-
childCount: 1,
|
|
3827
|
-
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
3828
|
-
type: Div
|
|
3829
|
-
}, {
|
|
3830
|
-
childCount: 0,
|
|
3831
|
-
className: ScrollBarThumb,
|
|
3832
|
-
height: heightString,
|
|
3833
|
-
translate: translateString,
|
|
3834
|
-
type: Div
|
|
3835
|
-
}];
|
|
1011
|
+
const handleMessagePort = async port => {
|
|
1012
|
+
await create$4({
|
|
1013
|
+
commandMap: commandMapRef,
|
|
1014
|
+
isMessagePortOpen: true,
|
|
1015
|
+
messagePort: port
|
|
1016
|
+
});
|
|
3836
1017
|
};
|
|
3837
1018
|
|
|
3838
|
-
const
|
|
3839
|
-
|
|
3840
|
-
const
|
|
3841
|
-
|
|
3842
|
-
|
|
3843
|
-
|
|
3844
|
-
|
|
3845
|
-
id: QuickPick,
|
|
3846
|
-
type: Div
|
|
3847
|
-
}, ...getQuickPickHeaderVirtualDom(), {
|
|
3848
|
-
ariaActivedescendant: QuickPickItemActive,
|
|
3849
|
-
childCount: shouldShowScrollbar ? 2 : 1,
|
|
3850
|
-
className: mergeClassNames(List, ContainContent),
|
|
3851
|
-
id: QuickPickItems,
|
|
3852
|
-
onPointerDown: HandlePointerDown,
|
|
3853
|
-
onWheel: HandleWheel,
|
|
3854
|
-
role: ListBox,
|
|
3855
|
-
type: Div
|
|
3856
|
-
}, {
|
|
3857
|
-
childCount: visibleItems.length,
|
|
3858
|
-
className: mergeClassNames(ListItems, ContainContent),
|
|
3859
|
-
type: Div
|
|
3860
|
-
}, ...getQuickPickItemsVirtualDom(visibleItems), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarTop)];
|
|
1019
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1020
|
+
const getProtocol = uri => {
|
|
1021
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1022
|
+
if (protocolMatch) {
|
|
1023
|
+
return protocolMatch[1];
|
|
1024
|
+
}
|
|
1025
|
+
return '';
|
|
3861
1026
|
};
|
|
3862
1027
|
|
|
3863
|
-
const
|
|
3864
|
-
|
|
3865
|
-
|
|
3866
|
-
scrollBarHeight,
|
|
3867
|
-
scrollBarTop,
|
|
3868
|
-
visibleItems
|
|
3869
|
-
} = viewModel;
|
|
3870
|
-
const dom = getQuickPickVirtualDom(visibleItems, scrollBarHeight, scrollBarTop);
|
|
3871
|
-
return dom;
|
|
1028
|
+
const state = Object.create(null);
|
|
1029
|
+
const register = modules => {
|
|
1030
|
+
Object.assign(state, modules);
|
|
3872
1031
|
};
|
|
3873
|
-
const
|
|
3874
|
-
|
|
3875
|
-
return [SetDom2, dom];
|
|
1032
|
+
const getFn = protocol => {
|
|
1033
|
+
return state[protocol];
|
|
3876
1034
|
};
|
|
3877
1035
|
|
|
3878
|
-
const
|
|
3879
|
-
const
|
|
3880
|
-
const
|
|
3881
|
-
if (
|
|
3882
|
-
|
|
1036
|
+
const searchFile$4 = async (path, value, prepare, assetDir) => {
|
|
1037
|
+
const protocol = getProtocol(path);
|
|
1038
|
+
const fn = getFn(protocol);
|
|
1039
|
+
if (!fn) {
|
|
1040
|
+
throw new Error(`No search handler registered for protocol: ${protocol}`);
|
|
3883
1041
|
}
|
|
3884
|
-
const
|
|
3885
|
-
return
|
|
3886
|
-
};
|
|
3887
|
-
|
|
3888
|
-
const renderValue = (_oldState, newState) => {
|
|
3889
|
-
return ['Viewlet.setValueByName', QuickPickInput, /* value */newState.value];
|
|
1042
|
+
const result = await fn(path, value, prepare, assetDir);
|
|
1043
|
+
return result;
|
|
3890
1044
|
};
|
|
3891
1045
|
|
|
3892
|
-
const
|
|
3893
|
-
|
|
3894
|
-
|
|
3895
|
-
|
|
3896
|
-
case RenderCursorOffset:
|
|
3897
|
-
return renderCursorOffset;
|
|
3898
|
-
case RenderFocus:
|
|
3899
|
-
return renderFocus;
|
|
3900
|
-
case RenderFocusedIndex:
|
|
3901
|
-
return renderFocusedIndex;
|
|
3902
|
-
case RenderIncremental:
|
|
3903
|
-
return renderIncremental;
|
|
3904
|
-
case RenderItems:
|
|
3905
|
-
return renderItems;
|
|
3906
|
-
case RenderValue:
|
|
3907
|
-
return renderValue;
|
|
3908
|
-
default:
|
|
3909
|
-
throw new Error('unknown renderer');
|
|
3910
|
-
}
|
|
1046
|
+
const commandMap = {
|
|
1047
|
+
'FileSearch.handleMessagePort': handleMessagePort,
|
|
1048
|
+
'FileSearch.searchFile': searchFile$4,
|
|
1049
|
+
'SearchFile.searchFile': searchFile$4
|
|
3911
1050
|
};
|
|
3912
1051
|
|
|
3913
|
-
const
|
|
3914
|
-
|
|
3915
|
-
|
|
3916
|
-
|
|
3917
|
-
|
|
3918
|
-
|
|
3919
|
-
|
|
3920
|
-
|
|
1052
|
+
const createMockRpc = ({
|
|
1053
|
+
commandMap
|
|
1054
|
+
}) => {
|
|
1055
|
+
const invocations = [];
|
|
1056
|
+
const invoke = (method, ...params) => {
|
|
1057
|
+
invocations.push([method, ...params]);
|
|
1058
|
+
const command = commandMap[method];
|
|
1059
|
+
if (!command) {
|
|
1060
|
+
throw new Error(`command ${method} not found`);
|
|
3921
1061
|
}
|
|
3922
|
-
|
|
3923
|
-
|
|
3924
|
-
|
|
3925
|
-
|
|
1062
|
+
return command(...params);
|
|
1063
|
+
};
|
|
1064
|
+
const mockRpc = {
|
|
1065
|
+
invocations,
|
|
1066
|
+
invoke,
|
|
1067
|
+
invokeAndTransfer: invoke
|
|
1068
|
+
};
|
|
1069
|
+
return mockRpc;
|
|
3926
1070
|
};
|
|
3927
1071
|
|
|
3928
|
-
const
|
|
3929
|
-
|
|
3930
|
-
|
|
3931
|
-
oldState
|
|
3932
|
-
} = get$1(uid);
|
|
3933
|
-
if (oldState === newState) {
|
|
3934
|
-
return [];
|
|
3935
|
-
}
|
|
3936
|
-
set(uid, newState, newState);
|
|
3937
|
-
const commands = applyRender(oldState, newState, diffResult);
|
|
3938
|
-
return commands;
|
|
1072
|
+
const rpcs = Object.create(null);
|
|
1073
|
+
const set$2 = (id, rpc) => {
|
|
1074
|
+
rpcs[id] = rpc;
|
|
3939
1075
|
};
|
|
3940
|
-
|
|
3941
|
-
|
|
3942
|
-
return [{
|
|
3943
|
-
name: HandlePointerDown,
|
|
3944
|
-
params: ['handleClickAt', 'event.clientX', 'event.clientY'],
|
|
3945
|
-
preventDefault: true
|
|
3946
|
-
}, {
|
|
3947
|
-
name: HandleWheel,
|
|
3948
|
-
params: ['handleWheel', 'event.deltaMode', 'event.deltaY'],
|
|
3949
|
-
passive: true
|
|
3950
|
-
}, {
|
|
3951
|
-
name: HandleBlur,
|
|
3952
|
-
params: ['handleBlur']
|
|
3953
|
-
}, {
|
|
3954
|
-
name: HandleBeforeInput,
|
|
3955
|
-
params: ['handleBeforeInput']
|
|
3956
|
-
}, {
|
|
3957
|
-
name: HandleInput,
|
|
3958
|
-
params: ['handleInput', 'event.target.value']
|
|
3959
|
-
}, {
|
|
3960
|
-
name: HandleFocus,
|
|
3961
|
-
params: ['handleFocus']
|
|
3962
|
-
}];
|
|
1076
|
+
const get = id => {
|
|
1077
|
+
return rpcs[id];
|
|
3963
1078
|
};
|
|
3964
|
-
|
|
3965
|
-
|
|
3966
|
-
const {
|
|
3967
|
-
focusedIndex
|
|
3968
|
-
} = state;
|
|
3969
|
-
return selectIndex(state, focusedIndex);
|
|
1079
|
+
const remove = id => {
|
|
1080
|
+
delete rpcs[id];
|
|
3970
1081
|
};
|
|
3971
1082
|
|
|
3972
|
-
|
|
3973
|
-
|
|
3974
|
-
|
|
3975
|
-
|
|
1083
|
+
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
|
1084
|
+
const create = rpcId => {
|
|
1085
|
+
return {
|
|
1086
|
+
async dispose() {
|
|
1087
|
+
const rpc = get(rpcId);
|
|
1088
|
+
await rpc.dispose();
|
|
1089
|
+
},
|
|
1090
|
+
// @ts-ignore
|
|
1091
|
+
invoke(method, ...params) {
|
|
1092
|
+
const rpc = get(rpcId);
|
|
1093
|
+
// @ts-ignore
|
|
1094
|
+
return rpc.invoke(method, ...params);
|
|
1095
|
+
},
|
|
1096
|
+
// @ts-ignore
|
|
1097
|
+
invokeAndTransfer(method, ...params) {
|
|
1098
|
+
const rpc = get(rpcId);
|
|
1099
|
+
// @ts-ignore
|
|
1100
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
1101
|
+
},
|
|
1102
|
+
registerMockRpc(commandMap) {
|
|
1103
|
+
const mockRpc = createMockRpc({
|
|
1104
|
+
commandMap
|
|
1105
|
+
});
|
|
1106
|
+
set$2(rpcId, mockRpc);
|
|
1107
|
+
// @ts-ignore
|
|
1108
|
+
mockRpc[Symbol.dispose] = () => {
|
|
1109
|
+
remove(rpcId);
|
|
1110
|
+
};
|
|
1111
|
+
// @ts-ignore
|
|
1112
|
+
return mockRpc;
|
|
1113
|
+
},
|
|
1114
|
+
set(rpc) {
|
|
1115
|
+
set$2(rpcId, rpc);
|
|
3976
1116
|
}
|
|
3977
|
-
}
|
|
3978
|
-
return -1;
|
|
1117
|
+
};
|
|
3979
1118
|
};
|
|
3980
1119
|
|
|
3981
|
-
const
|
|
3982
|
-
|
|
3983
|
-
const index = findLabelIndex(state.items, label);
|
|
3984
|
-
if (index === -1) {
|
|
3985
|
-
return state;
|
|
3986
|
-
}
|
|
3987
|
-
return selectIndex(state, index);
|
|
3988
|
-
};
|
|
1120
|
+
const EditorWorker = 99;
|
|
1121
|
+
const RendererWorker = 1;
|
|
3989
1122
|
|
|
3990
|
-
const
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
waitUntil
|
|
3994
|
-
}) => {
|
|
3995
|
-
// TODO ask renderer worker to create quickpick instance, with given options
|
|
3996
|
-
const picks = [];
|
|
3997
|
-
// const id=QuickPickCallbacks.registerCallback()
|
|
3998
|
-
await invoke$1('QuickPick.showCustom', picks, {
|
|
3999
|
-
ignoreFocusOut,
|
|
4000
|
-
initialValue,
|
|
4001
|
-
waitUntil
|
|
4002
|
-
});
|
|
4003
|
-
return {
|
|
4004
|
-
canceled: false,
|
|
4005
|
-
inputValue: ''
|
|
4006
|
-
};
|
|
4007
|
-
};
|
|
1123
|
+
const {
|
|
1124
|
+
set: set$1
|
|
1125
|
+
} = create(EditorWorker);
|
|
4008
1126
|
|
|
4009
|
-
const
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
'
|
|
4016
|
-
'
|
|
4017
|
-
'QuickPick.focusIndex': wrapCommand(focusIndex),
|
|
4018
|
-
'QuickPick.focusLast': wrapCommand(focusLast),
|
|
4019
|
-
'QuickPick.focusNext': wrapCommand(focusNext),
|
|
4020
|
-
'QuickPick.focusPrevious': wrapCommand(focusPrevious),
|
|
4021
|
-
'QuickPick.getCommandIds': getCommandIds,
|
|
4022
|
-
'QuickPick.getKeyBindings': getKeyBindings,
|
|
4023
|
-
'QuickPick.handleBeforeInput': wrapCommand(handleBeforeInput),
|
|
4024
|
-
'QuickPick.handleBlur': wrapCommand(handleBlur),
|
|
4025
|
-
'QuickPick.handleClickAt': wrapCommand(handleClickAt),
|
|
4026
|
-
'QuickPick.handleFocus': wrapCommand(handleFocus),
|
|
4027
|
-
'QuickPick.handleInput': wrapCommand(handleInput),
|
|
4028
|
-
'QuickPick.handleMessagePort': handleMessagePort,
|
|
4029
|
-
'QuickPick.handleWheel': wrapCommand(handleWheel),
|
|
4030
|
-
'QuickPick.initialize': initialize,
|
|
4031
|
-
'QuickPick.loadContent': wrapCommand(loadContent),
|
|
4032
|
-
'QuickPick.render2': render2,
|
|
4033
|
-
'QuickPick.renderEventListeners': renderEventListeners,
|
|
4034
|
-
'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
|
|
4035
|
-
'QuickPick.selectIndex': wrapCommand(selectIndex),
|
|
4036
|
-
'QuickPick.selectItem': wrapCommand(selectItem),
|
|
4037
|
-
'QuickPick.setDeltaY': wrapCommand(setDeltaY),
|
|
4038
|
-
'QuickPick.setValue': wrapCommand(setValue),
|
|
4039
|
-
'QuickPick.showQuickInput': showQuickInput
|
|
1127
|
+
const {
|
|
1128
|
+
invoke: invoke$1,
|
|
1129
|
+
invokeAndTransfer,
|
|
1130
|
+
set
|
|
1131
|
+
} = create(RendererWorker);
|
|
1132
|
+
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1133
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1134
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
4040
1135
|
};
|
|
4041
1136
|
|
|
4042
1137
|
const initializeEditorWorker = async () => {
|
|
4043
|
-
const rpc = await create$
|
|
1138
|
+
const rpc = await create$2({
|
|
4044
1139
|
commandMap: {},
|
|
4045
1140
|
async send(port) {
|
|
4046
1141
|
await sendMessagePortToEditorWorker(port, 0);
|
|
4047
1142
|
}
|
|
4048
1143
|
});
|
|
4049
|
-
set$
|
|
1144
|
+
set$1(rpc);
|
|
4050
1145
|
};
|
|
4051
1146
|
|
|
4052
1147
|
const initializeRendererWorker = async () => {
|
|
4053
|
-
const rpc = await create({
|
|
1148
|
+
const rpc = await create$1({
|
|
4054
1149
|
commandMap: commandMap
|
|
4055
1150
|
});
|
|
4056
|
-
set
|
|
1151
|
+
set(rpc);
|
|
4057
1152
|
};
|
|
4058
1153
|
|
|
4059
1154
|
const Memfs = 'memfs';
|
|
@@ -4086,6 +1181,13 @@ const invoke = (method, ...params) => {
|
|
|
4086
1181
|
return invoke$1('SearchProcess.invoke', method, ...params);
|
|
4087
1182
|
};
|
|
4088
1183
|
|
|
1184
|
+
const splitLines = lines => {
|
|
1185
|
+
if (!lines) {
|
|
1186
|
+
return [];
|
|
1187
|
+
}
|
|
1188
|
+
return lines.split('\n');
|
|
1189
|
+
};
|
|
1190
|
+
|
|
4089
1191
|
// TODO create direct connection from electron to file search worker using message ports
|
|
4090
1192
|
|
|
4091
1193
|
const searchFile = async (path, value, prepare) => {
|
|
@@ -4096,7 +1198,7 @@ const searchFile = async (path, value, prepare) => {
|
|
|
4096
1198
|
searchPath: path
|
|
4097
1199
|
};
|
|
4098
1200
|
const stdout = await invoke('SearchFile.searchFile', options);
|
|
4099
|
-
const lines = splitLines
|
|
1201
|
+
const lines = splitLines(stdout);
|
|
4100
1202
|
return lines;
|
|
4101
1203
|
};
|
|
4102
1204
|
|
|
@@ -4110,7 +1212,6 @@ const searchModules = {
|
|
|
4110
1212
|
|
|
4111
1213
|
const listen = async () => {
|
|
4112
1214
|
Object.assign(commandMapRef, commandMap);
|
|
4113
|
-
registerCommands(commandMap);
|
|
4114
1215
|
register(searchModules);
|
|
4115
1216
|
await Promise.all([initializeRendererWorker(), initializeEditorWorker()]);
|
|
4116
1217
|
};
|