@lvce-editor/file-search-worker 3.3.0 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fileSearchWorkerMain.js +1503 -1329
- package/package.json +6 -6
|
@@ -54,6 +54,41 @@ 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 getType = value => {
|
|
64
|
+
switch (typeof value) {
|
|
65
|
+
case 'number':
|
|
66
|
+
return 'number';
|
|
67
|
+
case 'function':
|
|
68
|
+
return 'function';
|
|
69
|
+
case 'string':
|
|
70
|
+
return 'string';
|
|
71
|
+
case 'object':
|
|
72
|
+
if (value === null) {
|
|
73
|
+
return 'null';
|
|
74
|
+
}
|
|
75
|
+
if (Array.isArray(value)) {
|
|
76
|
+
return 'array';
|
|
77
|
+
}
|
|
78
|
+
return 'object';
|
|
79
|
+
case 'boolean':
|
|
80
|
+
return 'boolean';
|
|
81
|
+
default:
|
|
82
|
+
return 'unknown';
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
const array = value => {
|
|
86
|
+
const type = getType(value);
|
|
87
|
+
if (type !== 'array') {
|
|
88
|
+
throw new AssertionError('expected value to be of type array');
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
57
92
|
const isMessagePort = value => {
|
|
58
93
|
return value && value instanceof MessagePort;
|
|
59
94
|
};
|
|
@@ -128,33 +163,38 @@ const E_INCOMPATIBLE_NATIVE_MODULE = 'E_INCOMPATIBLE_NATIVE_MODULE';
|
|
|
128
163
|
const E_MODULES_NOT_SUPPORTED_IN_ELECTRON = 'E_MODULES_NOT_SUPPORTED_IN_ELECTRON';
|
|
129
164
|
const ERR_MODULE_NOT_FOUND = 'ERR_MODULE_NOT_FOUND';
|
|
130
165
|
const NewLine$1 = '\n';
|
|
131
|
-
const
|
|
132
|
-
return lines.
|
|
166
|
+
const joinLines$1 = lines => {
|
|
167
|
+
return lines.join(NewLine$1);
|
|
133
168
|
};
|
|
134
|
-
const
|
|
135
|
-
|
|
169
|
+
const RE_AT = /^\s+at/;
|
|
170
|
+
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
171
|
+
const isNormalStackLine = line => {
|
|
172
|
+
return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
|
|
136
173
|
};
|
|
137
|
-
const
|
|
138
|
-
const
|
|
139
|
-
|
|
140
|
-
|
|
174
|
+
const getDetails = lines => {
|
|
175
|
+
const index = lines.findIndex(isNormalStackLine);
|
|
176
|
+
if (index === -1) {
|
|
177
|
+
return {
|
|
178
|
+
actualMessage: joinLines$1(lines),
|
|
179
|
+
rest: []
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
let lastIndex = index - 1;
|
|
183
|
+
while (++lastIndex < lines.length) {
|
|
184
|
+
if (!isNormalStackLine(lines[lastIndex])) {
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
141
188
|
return {
|
|
142
|
-
|
|
143
|
-
|
|
189
|
+
actualMessage: lines[index - 1],
|
|
190
|
+
rest: lines.slice(index, lastIndex)
|
|
144
191
|
};
|
|
145
192
|
};
|
|
146
|
-
const
|
|
147
|
-
return lines.
|
|
193
|
+
const splitLines$2 = lines => {
|
|
194
|
+
return lines.split(NewLine$1);
|
|
148
195
|
};
|
|
149
|
-
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
150
|
-
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
151
196
|
const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
|
|
152
197
|
const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
|
|
153
|
-
const RE_AT = /^\s+at/;
|
|
154
|
-
const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
|
|
155
|
-
const isUnhelpfulNativeModuleError = stderr => {
|
|
156
|
-
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
157
|
-
};
|
|
158
198
|
const isMessageCodeBlockStartIndex = line => {
|
|
159
199
|
return RE_MESSAGE_CODE_BLOCK_START.test(line);
|
|
160
200
|
};
|
|
@@ -169,51 +209,46 @@ const getMessageCodeBlock = stderr => {
|
|
|
169
209
|
const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
|
|
170
210
|
return relevantMessage;
|
|
171
211
|
};
|
|
172
|
-
const
|
|
173
|
-
|
|
212
|
+
const isModuleNotFoundMessage = line => {
|
|
213
|
+
return line.includes('[ERR_MODULE_NOT_FOUND]');
|
|
214
|
+
};
|
|
215
|
+
const getModuleNotFoundError = stderr => {
|
|
216
|
+
const lines = splitLines$2(stderr);
|
|
217
|
+
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
218
|
+
const message = lines[messageIndex];
|
|
174
219
|
return {
|
|
175
|
-
message
|
|
176
|
-
code:
|
|
220
|
+
message,
|
|
221
|
+
code: ERR_MODULE_NOT_FOUND
|
|
177
222
|
};
|
|
178
223
|
};
|
|
179
|
-
const
|
|
224
|
+
const isModuleNotFoundError = stderr => {
|
|
180
225
|
if (!stderr) {
|
|
181
226
|
return false;
|
|
182
227
|
}
|
|
183
|
-
return stderr.includes('
|
|
184
|
-
};
|
|
185
|
-
const getModuleSyntaxError = () => {
|
|
186
|
-
return {
|
|
187
|
-
message: `ES Modules are not supported in electron`,
|
|
188
|
-
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
189
|
-
};
|
|
228
|
+
return stderr.includes('ERR_MODULE_NOT_FOUND');
|
|
190
229
|
};
|
|
191
|
-
const
|
|
230
|
+
const isModulesSyntaxError = stderr => {
|
|
192
231
|
if (!stderr) {
|
|
193
232
|
return false;
|
|
194
233
|
}
|
|
195
|
-
return stderr.includes('
|
|
234
|
+
return stderr.includes('SyntaxError: Cannot use import statement outside a module');
|
|
196
235
|
};
|
|
197
|
-
const
|
|
198
|
-
|
|
236
|
+
const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
|
|
237
|
+
const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
|
|
238
|
+
const isUnhelpfulNativeModuleError = stderr => {
|
|
239
|
+
return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
|
|
199
240
|
};
|
|
200
|
-
const
|
|
201
|
-
const
|
|
202
|
-
if (index === -1) {
|
|
203
|
-
return {
|
|
204
|
-
actualMessage: joinLines$1(lines),
|
|
205
|
-
rest: []
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
let lastIndex = index - 1;
|
|
209
|
-
while (++lastIndex < lines.length) {
|
|
210
|
-
if (!isNormalStackLine(lines[lastIndex])) {
|
|
211
|
-
break;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
241
|
+
const getNativeModuleErrorMessage = stderr => {
|
|
242
|
+
const message = getMessageCodeBlock(stderr);
|
|
214
243
|
return {
|
|
215
|
-
|
|
216
|
-
|
|
244
|
+
message: `Incompatible native node module: ${message}`,
|
|
245
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE
|
|
246
|
+
};
|
|
247
|
+
};
|
|
248
|
+
const getModuleSyntaxError = () => {
|
|
249
|
+
return {
|
|
250
|
+
message: `ES Modules are not supported in electron`,
|
|
251
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
|
|
217
252
|
};
|
|
218
253
|
};
|
|
219
254
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -274,7 +309,7 @@ const listen$7 = () => {
|
|
|
274
309
|
}
|
|
275
310
|
return globalThis;
|
|
276
311
|
};
|
|
277
|
-
const signal$
|
|
312
|
+
const signal$8 = global => {
|
|
278
313
|
global.postMessage(readyMessage);
|
|
279
314
|
};
|
|
280
315
|
class IpcChildWithModuleWorker extends Ipc {
|
|
@@ -300,7 +335,7 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
300
335
|
this._rawIpc.addEventListener('message', callback);
|
|
301
336
|
}
|
|
302
337
|
}
|
|
303
|
-
const wrap$
|
|
338
|
+
const wrap$f = global => {
|
|
304
339
|
return new IpcChildWithModuleWorker(global);
|
|
305
340
|
};
|
|
306
341
|
const withResolvers = () => {
|
|
@@ -328,8 +363,8 @@ const waitForFirstMessage = async port => {
|
|
|
328
363
|
};
|
|
329
364
|
const listen$6 = async () => {
|
|
330
365
|
const parentIpcRaw = listen$7();
|
|
331
|
-
signal$
|
|
332
|
-
const parentIpc = wrap$
|
|
366
|
+
signal$8(parentIpcRaw);
|
|
367
|
+
const parentIpc = wrap$f(parentIpcRaw);
|
|
333
368
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
334
369
|
if (firstMessage.method !== 'initialize') {
|
|
335
370
|
throw new IpcError('unexpected first message');
|
|
@@ -371,13 +406,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
|
|
|
371
406
|
this._rawIpc.start();
|
|
372
407
|
}
|
|
373
408
|
}
|
|
374
|
-
const wrap$
|
|
409
|
+
const wrap$e = port => {
|
|
375
410
|
return new IpcChildWithModuleWorkerAndMessagePort(port);
|
|
376
411
|
};
|
|
377
412
|
const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
378
413
|
__proto__: null,
|
|
379
414
|
listen: listen$6,
|
|
380
|
-
wrap: wrap$
|
|
415
|
+
wrap: wrap$e
|
|
381
416
|
};
|
|
382
417
|
|
|
383
418
|
const Two = '2.0';
|
|
@@ -389,32 +424,32 @@ const create$4 = (method, params) => {
|
|
|
389
424
|
};
|
|
390
425
|
};
|
|
391
426
|
const callbacks = Object.create(null);
|
|
392
|
-
const set = (id, fn) => {
|
|
427
|
+
const set$1 = (id, fn) => {
|
|
393
428
|
callbacks[id] = fn;
|
|
394
429
|
};
|
|
395
|
-
const get = id => {
|
|
430
|
+
const get$1 = id => {
|
|
396
431
|
return callbacks[id];
|
|
397
432
|
};
|
|
398
433
|
const remove$2 = id => {
|
|
399
434
|
delete callbacks[id];
|
|
400
435
|
};
|
|
401
436
|
let id = 0;
|
|
402
|
-
const create$3 = () => {
|
|
437
|
+
const create$3$1 = () => {
|
|
403
438
|
return ++id;
|
|
404
439
|
};
|
|
405
440
|
const registerPromise = () => {
|
|
406
|
-
const id = create$3();
|
|
441
|
+
const id = create$3$1();
|
|
407
442
|
const {
|
|
408
443
|
resolve,
|
|
409
444
|
promise
|
|
410
445
|
} = Promise.withResolvers();
|
|
411
|
-
set(id, resolve);
|
|
446
|
+
set$1(id, resolve);
|
|
412
447
|
return {
|
|
413
448
|
id,
|
|
414
449
|
promise
|
|
415
450
|
};
|
|
416
451
|
};
|
|
417
|
-
const create$2 = (method, params) => {
|
|
452
|
+
const create$2$1 = (method, params) => {
|
|
418
453
|
const {
|
|
419
454
|
id,
|
|
420
455
|
promise
|
|
@@ -565,7 +600,7 @@ const warn$1 = (...args) => {
|
|
|
565
600
|
console.warn(...args);
|
|
566
601
|
};
|
|
567
602
|
const resolve = (id, response) => {
|
|
568
|
-
const fn = get(id);
|
|
603
|
+
const fn = get$1(id);
|
|
569
604
|
if (!fn) {
|
|
570
605
|
console.log(response);
|
|
571
606
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -604,7 +639,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
604
639
|
}
|
|
605
640
|
};
|
|
606
641
|
};
|
|
607
|
-
const create$1 = (message, error) => {
|
|
642
|
+
const create$1$1 = (message, error) => {
|
|
608
643
|
return {
|
|
609
644
|
jsonrpc: Two,
|
|
610
645
|
id: message.id,
|
|
@@ -615,7 +650,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
615
650
|
const prettyError = preparePrettyError(error);
|
|
616
651
|
logError(error, prettyError);
|
|
617
652
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
618
|
-
return create$1(message, errorProperty);
|
|
653
|
+
return create$1$1(message, errorProperty);
|
|
619
654
|
};
|
|
620
655
|
const create$5 = (message, result) => {
|
|
621
656
|
return {
|
|
@@ -706,7 +741,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
706
741
|
const {
|
|
707
742
|
message,
|
|
708
743
|
promise
|
|
709
|
-
} = create$2(method, params);
|
|
744
|
+
} = create$2$1(method, params);
|
|
710
745
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
711
746
|
ipc.sendAndTransfer(message);
|
|
712
747
|
} else {
|
|
@@ -743,6 +778,8 @@ const execute$1 = (command, ...args) => {
|
|
|
743
778
|
|
|
744
779
|
const createRpc = ipc => {
|
|
745
780
|
const rpc = {
|
|
781
|
+
// @ts-ignore
|
|
782
|
+
ipc,
|
|
746
783
|
/**
|
|
747
784
|
* @deprecated
|
|
748
785
|
*/
|
|
@@ -769,7 +806,8 @@ const logError = () => {
|
|
|
769
806
|
};
|
|
770
807
|
const handleMessage = event => {
|
|
771
808
|
const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
|
|
772
|
-
|
|
809
|
+
const actualExecute = event?.target?.execute || execute$1;
|
|
810
|
+
return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
773
811
|
};
|
|
774
812
|
const handleIpc = ipc => {
|
|
775
813
|
if ('addEventListener' in ipc) {
|
|
@@ -787,7 +825,7 @@ const listen$1 = async (module, options) => {
|
|
|
787
825
|
const ipc = module.wrap(rawIpc);
|
|
788
826
|
return ipc;
|
|
789
827
|
};
|
|
790
|
-
const create = async ({
|
|
828
|
+
const create$3 = async ({
|
|
791
829
|
commandMap
|
|
792
830
|
}) => {
|
|
793
831
|
// TODO create a commandMap per rpc instance
|
|
@@ -799,121 +837,274 @@ const create = async ({
|
|
|
799
837
|
};
|
|
800
838
|
const WebWorkerRpcClient = {
|
|
801
839
|
__proto__: null,
|
|
802
|
-
create
|
|
840
|
+
create: create$3
|
|
803
841
|
};
|
|
804
842
|
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
const Directory$1 = 3;
|
|
808
|
-
const File$2 = 7;
|
|
843
|
+
const User = 1;
|
|
844
|
+
const Script = 2;
|
|
809
845
|
|
|
810
|
-
const
|
|
846
|
+
const minimumSliderSize = 20;
|
|
811
847
|
|
|
812
|
-
const
|
|
813
|
-
|
|
814
|
-
const response = await fetch(url);
|
|
815
|
-
if (!response.ok) {
|
|
816
|
-
throw new Error(response.statusText);
|
|
817
|
-
}
|
|
818
|
-
const text = await response.blob();
|
|
819
|
-
return text;
|
|
820
|
-
} catch (error) {
|
|
821
|
-
throw new VError(error, `Failed to request blob for ${url}`);
|
|
822
|
-
}
|
|
848
|
+
const handleError = async (error, notify = true, prefix = '') => {
|
|
849
|
+
console.error(error);
|
|
823
850
|
};
|
|
824
|
-
|
|
825
|
-
const
|
|
826
|
-
|
|
827
|
-
const response = await fetch(url);
|
|
828
|
-
if (!response.ok) {
|
|
829
|
-
throw new Error(response.statusText);
|
|
830
|
-
}
|
|
831
|
-
const text = await response.json();
|
|
832
|
-
return text;
|
|
833
|
-
} catch (error) {
|
|
834
|
-
throw new VError(error, `Failed to request json for ${url}`);
|
|
835
|
-
}
|
|
851
|
+
const showErrorDialog = async () => {};
|
|
852
|
+
const warn = (...args) => {
|
|
853
|
+
console.warn(...args);
|
|
836
854
|
};
|
|
837
855
|
|
|
838
|
-
const
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
}
|
|
844
|
-
const text = await response.text();
|
|
845
|
-
return text;
|
|
846
|
-
} catch (error) {
|
|
847
|
-
throw new VError(error, `Failed to request text for ${url}`);
|
|
848
|
-
}
|
|
856
|
+
const state$5 = {
|
|
857
|
+
menuEntries: []
|
|
858
|
+
};
|
|
859
|
+
const getAll = () => {
|
|
860
|
+
return state$5.menuEntries;
|
|
849
861
|
};
|
|
850
862
|
|
|
851
|
-
const
|
|
852
|
-
|
|
853
|
-
const Slash = Slash$1;
|
|
863
|
+
const Hide = 'hide';
|
|
864
|
+
const KeepOpen = '';
|
|
854
865
|
|
|
855
|
-
|
|
866
|
+
const emptyObject = {};
|
|
867
|
+
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
868
|
+
const i18nString = (key, placeholders = emptyObject) => {
|
|
869
|
+
if (placeholders === emptyObject) {
|
|
870
|
+
return key;
|
|
871
|
+
}
|
|
872
|
+
const replacer = (match, rest) => {
|
|
873
|
+
return placeholders[rest];
|
|
874
|
+
};
|
|
875
|
+
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
876
|
+
};
|
|
856
877
|
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
878
|
+
/**
|
|
879
|
+
* @enum {string}
|
|
880
|
+
*/
|
|
881
|
+
const UiStrings = {
|
|
882
|
+
Files: 'Files',
|
|
883
|
+
GoToFile: 'Go to file',
|
|
884
|
+
NoMatchingColorThemesFound: 'No matching color themes found',
|
|
885
|
+
NoMatchingResults: 'No matching results',
|
|
886
|
+
NoRecentlyOpenedFoldersFound: 'No recently opened folders found',
|
|
887
|
+
NoResults: 'No Results',
|
|
888
|
+
NoSymbolFound: 'No symbol found',
|
|
889
|
+
NoWorkspaceSymbolsFound: 'no workspace symbols found',
|
|
890
|
+
OpenRecent: 'Open Recent',
|
|
891
|
+
SelectColorTheme: 'Select Color Theme',
|
|
892
|
+
SelectToOpen: 'Select to open',
|
|
893
|
+
ShowAndRunCommands: 'Show And Run Commands',
|
|
894
|
+
TypeNameOfCommandToRun: 'Type the name of a command to run.',
|
|
895
|
+
TypeTheNameOfAViewToOpen: 'Type the name of a view, output channel or terminal to open.'
|
|
861
896
|
};
|
|
862
|
-
const
|
|
863
|
-
|
|
897
|
+
const noMatchingColorThemesFound = () => {
|
|
898
|
+
return i18nString(UiStrings.NoMatchingColorThemesFound);
|
|
864
899
|
};
|
|
865
|
-
const
|
|
866
|
-
|
|
900
|
+
const selectColorTheme = () => {
|
|
901
|
+
return i18nString(UiStrings.SelectColorTheme);
|
|
867
902
|
};
|
|
868
|
-
const
|
|
869
|
-
|
|
903
|
+
const typeNameofCommandToRun = () => {
|
|
904
|
+
return i18nString(UiStrings.TypeNameOfCommandToRun);
|
|
870
905
|
};
|
|
871
|
-
const
|
|
872
|
-
|
|
873
|
-
const dirents = [];
|
|
874
|
-
for (const fileUri of fileList) {
|
|
875
|
-
if (fileUri.startsWith(uri)) {
|
|
876
|
-
const rest = fileUri.slice(uri.length + 1);
|
|
877
|
-
if (rest.includes(Slash)) {
|
|
878
|
-
const name = rest.slice(0, rest.indexOf(Slash));
|
|
879
|
-
if (dirents.some(dirent => dirent.name === name)) {
|
|
880
|
-
continue;
|
|
881
|
-
}
|
|
882
|
-
dirents.push({
|
|
883
|
-
type: Directory$1,
|
|
884
|
-
name
|
|
885
|
-
});
|
|
886
|
-
} else {
|
|
887
|
-
dirents.push({
|
|
888
|
-
type: File$2,
|
|
889
|
-
name: rest
|
|
890
|
-
});
|
|
891
|
-
}
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
return dirents;
|
|
906
|
+
const showAndRunCommands = () => {
|
|
907
|
+
return i18nString(UiStrings.ShowAndRunCommands);
|
|
895
908
|
};
|
|
896
|
-
const
|
|
897
|
-
|
|
909
|
+
const noMatchingResults = () => {
|
|
910
|
+
return i18nString(UiStrings.NoMatchingResults);
|
|
898
911
|
};
|
|
899
|
-
const
|
|
900
|
-
|
|
901
|
-
const blob = getBlob$2(fetchUri);
|
|
902
|
-
return blob;
|
|
912
|
+
const files = () => {
|
|
913
|
+
return i18nString(UiStrings.Files);
|
|
903
914
|
};
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
const
|
|
915
|
+
const goToFile = () => {
|
|
916
|
+
return i18nString(UiStrings.GoToFile);
|
|
917
|
+
};
|
|
918
|
+
const noResults = () => {
|
|
919
|
+
return i18nString(UiStrings.NoResults);
|
|
920
|
+
};
|
|
921
|
+
const selectToOpen = () => {
|
|
922
|
+
return i18nString(UiStrings.SelectToOpen);
|
|
923
|
+
};
|
|
924
|
+
const openRecent = () => {
|
|
925
|
+
return i18nString(UiStrings.OpenRecent);
|
|
926
|
+
};
|
|
927
|
+
const noRecentlyOpenedFoldersFound = () => {
|
|
928
|
+
return i18nString(UiStrings.NoRecentlyOpenedFoldersFound);
|
|
929
|
+
};
|
|
930
|
+
const noSymbolFound = () => {
|
|
931
|
+
return i18nString(UiStrings.NoSymbolFound);
|
|
932
|
+
};
|
|
933
|
+
const noWorkspaceSymbolsFound = () => {
|
|
934
|
+
return i18nString(UiStrings.NoWorkspaceSymbolsFound);
|
|
935
|
+
};
|
|
936
|
+
|
|
937
|
+
const state$4 = {
|
|
938
|
+
rpc: undefined
|
|
939
|
+
};
|
|
940
|
+
|
|
941
|
+
// TODO use rpc registry
|
|
942
|
+
const invoke$1 = (method, ...params) => {
|
|
943
|
+
const rpc = state$4.rpc;
|
|
944
|
+
// @ts-ignore
|
|
945
|
+
return rpc.invoke(method, ...params);
|
|
946
|
+
};
|
|
947
|
+
const setRpc = rpc => {
|
|
948
|
+
state$4.rpc = rpc;
|
|
949
|
+
};
|
|
950
|
+
|
|
951
|
+
const name$8 = 'command';
|
|
952
|
+
const getPlaceholder$b = () => {
|
|
953
|
+
return typeNameofCommandToRun();
|
|
954
|
+
};
|
|
955
|
+
const helpEntries = () => {
|
|
956
|
+
return [{
|
|
957
|
+
description: showAndRunCommands(),
|
|
958
|
+
category: 'global commands'
|
|
959
|
+
}];
|
|
960
|
+
};
|
|
961
|
+
const getLabel$5 = () => {
|
|
962
|
+
return '';
|
|
963
|
+
};
|
|
964
|
+
const getNoResults$a = () => {
|
|
965
|
+
return {
|
|
966
|
+
label: noMatchingResults()
|
|
967
|
+
};
|
|
968
|
+
};
|
|
969
|
+
|
|
970
|
+
// TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
|
|
971
|
+
const getBuiltinPicks = async () => {
|
|
972
|
+
const builtinPicks = getAll();
|
|
973
|
+
return builtinPicks;
|
|
974
|
+
};
|
|
975
|
+
const prefixIdWithExt = item => {
|
|
976
|
+
if (!item.label) {
|
|
977
|
+
warn('[QuickPick] item has missing label', item);
|
|
978
|
+
}
|
|
979
|
+
if (!item.id) {
|
|
980
|
+
warn('[QuickPick] item has missing id', item);
|
|
981
|
+
}
|
|
982
|
+
return {
|
|
983
|
+
...item,
|
|
984
|
+
id: `ext.${item.id}`,
|
|
985
|
+
label: item.label || item.id
|
|
986
|
+
};
|
|
987
|
+
};
|
|
988
|
+
const getExtensionPicks = async () => {
|
|
989
|
+
try {
|
|
990
|
+
// TODO don't call this every time
|
|
991
|
+
const extensionPicks = await invoke$1('ExtensionHostCommands.getCommands');
|
|
992
|
+
if (!extensionPicks) {
|
|
993
|
+
return [];
|
|
994
|
+
}
|
|
995
|
+
const mappedPicks = extensionPicks.map(prefixIdWithExt);
|
|
996
|
+
return mappedPicks;
|
|
997
|
+
} catch (error) {
|
|
998
|
+
console.error(`Failed to get extension picks: ${error}`);
|
|
999
|
+
return [];
|
|
1000
|
+
}
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
// TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
|
|
1004
|
+
|
|
1005
|
+
const getPicks$b = async () => {
|
|
1006
|
+
const builtinPicks = await getBuiltinPicks();
|
|
1007
|
+
const extensionPicks = await getExtensionPicks();
|
|
1008
|
+
return [...builtinPicks, ...extensionPicks];
|
|
1009
|
+
};
|
|
1010
|
+
const shouldHide = item => {
|
|
1011
|
+
if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
|
|
1012
|
+
return false;
|
|
1013
|
+
}
|
|
1014
|
+
return true;
|
|
1015
|
+
};
|
|
1016
|
+
const selectPickBuiltin = async item => {
|
|
1017
|
+
const args = item.args || [];
|
|
1018
|
+
// TODO ids should be all numbers for efficiency -> also directly can call command
|
|
1019
|
+
await invoke$1(item.id, ...args);
|
|
1020
|
+
if (shouldHide(item)) {
|
|
1021
|
+
return {
|
|
1022
|
+
command: Hide
|
|
1023
|
+
};
|
|
1024
|
+
}
|
|
1025
|
+
return {
|
|
1026
|
+
command: KeepOpen
|
|
1027
|
+
};
|
|
1028
|
+
};
|
|
1029
|
+
const selectPickExtension = async item => {
|
|
1030
|
+
const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
|
|
1031
|
+
try {
|
|
1032
|
+
await invoke$1('ExtensionHostCommands.executeCommand', id);
|
|
1033
|
+
} catch (error) {
|
|
1034
|
+
await handleError(error, false);
|
|
1035
|
+
// @ts-ignore
|
|
1036
|
+
await showErrorDialog();
|
|
1037
|
+
}
|
|
1038
|
+
return {
|
|
1039
|
+
command: Hide
|
|
1040
|
+
};
|
|
1041
|
+
};
|
|
1042
|
+
const selectPick$b = async item => {
|
|
1043
|
+
if (item.id.startsWith('ext.')) {
|
|
1044
|
+
return selectPickExtension(item);
|
|
1045
|
+
}
|
|
1046
|
+
return selectPickBuiltin(item);
|
|
1047
|
+
};
|
|
1048
|
+
const getFilterValue$a = value => {
|
|
1049
|
+
return value;
|
|
1050
|
+
};
|
|
1051
|
+
const getPickFilterValue$6 = pick => {
|
|
1052
|
+
return pick.label;
|
|
1053
|
+
};
|
|
1054
|
+
const getPickLabel$5 = pick => {
|
|
1055
|
+
return pick.label;
|
|
1056
|
+
};
|
|
1057
|
+
const getPickIcon$5 = () => {
|
|
1058
|
+
return '';
|
|
1059
|
+
};
|
|
1060
|
+
|
|
1061
|
+
const QuickPickEntriesCommand = {
|
|
1062
|
+
__proto__: null,
|
|
1063
|
+
getFilterValue: getFilterValue$a,
|
|
1064
|
+
getLabel: getLabel$5,
|
|
1065
|
+
getNoResults: getNoResults$a,
|
|
1066
|
+
getPickFilterValue: getPickFilterValue$6,
|
|
1067
|
+
getPickIcon: getPickIcon$5,
|
|
1068
|
+
getPickLabel: getPickLabel$5,
|
|
1069
|
+
getPicks: getPicks$b,
|
|
1070
|
+
getPlaceholder: getPlaceholder$b,
|
|
1071
|
+
helpEntries,
|
|
1072
|
+
name: name$8,
|
|
1073
|
+
selectPick: selectPick$b
|
|
1074
|
+
};
|
|
1075
|
+
|
|
1076
|
+
const execute = async (method, ...params) => {
|
|
1077
|
+
// TODO
|
|
1078
|
+
};
|
|
1079
|
+
|
|
1080
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1081
|
+
const getProtocol = uri => {
|
|
1082
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1083
|
+
if (protocolMatch) {
|
|
1084
|
+
return protocolMatch[1];
|
|
1085
|
+
}
|
|
1086
|
+
return '';
|
|
1087
|
+
};
|
|
1088
|
+
|
|
1089
|
+
const Memfs = 'memfs';
|
|
1090
|
+
const Html = 'html';
|
|
1091
|
+
const Fetch = 'fetch';
|
|
1092
|
+
|
|
1093
|
+
const Directory$1 = 3;
|
|
1094
|
+
const File$2 = 7;
|
|
1095
|
+
|
|
1096
|
+
class FileNotFoundError extends Error {
|
|
1097
|
+
constructor(uri) {
|
|
1098
|
+
super(`File not found: ${uri}`);
|
|
1099
|
+
this.code = 'ENOENT';
|
|
1100
|
+
}
|
|
1101
|
+
}
|
|
1102
|
+
|
|
1103
|
+
const ApplicationJson = 'application/json';
|
|
1104
|
+
const AudioMpeg = 'audio/mpeg';
|
|
1105
|
+
const FontTtf = 'font/ttf';
|
|
1106
|
+
const ImagePng = 'image/png';
|
|
1107
|
+
const ImageSvgXml = 'image/svg+xml';
|
|
917
1108
|
const TextCss = 'text/css';
|
|
918
1109
|
const TextHtml = 'text/html';
|
|
919
1110
|
const TextJavaScript = 'text/javascript';
|
|
@@ -971,15 +1162,19 @@ const getContentType = uri => {
|
|
|
971
1162
|
return mime;
|
|
972
1163
|
};
|
|
973
1164
|
|
|
1165
|
+
const Slash$1 = '/';
|
|
1166
|
+
|
|
1167
|
+
const Slash = Slash$1;
|
|
1168
|
+
|
|
974
1169
|
// TODO move this to an extension?
|
|
975
1170
|
|
|
976
|
-
const state$
|
|
1171
|
+
const state$3 = {
|
|
977
1172
|
files: Object.create(null)
|
|
978
1173
|
};
|
|
979
1174
|
const getDirent = uri => {
|
|
980
|
-
return state$
|
|
1175
|
+
return state$3.files[uri];
|
|
981
1176
|
};
|
|
982
|
-
const readFile = uri => {
|
|
1177
|
+
const readFile$1 = uri => {
|
|
983
1178
|
const dirent = getDirent(uri);
|
|
984
1179
|
if (!dirent) {
|
|
985
1180
|
throw new FileNotFoundError(uri);
|
|
@@ -994,52 +1189,52 @@ const ensureParentDir = uri => {
|
|
|
994
1189
|
let endIndex = uri.indexOf(Slash);
|
|
995
1190
|
while (endIndex >= 0) {
|
|
996
1191
|
const part = uri.slice(startIndex, endIndex + 1);
|
|
997
|
-
state$
|
|
1192
|
+
state$3.files[part] = {
|
|
998
1193
|
type: Directory$1,
|
|
999
1194
|
content: ''
|
|
1000
1195
|
};
|
|
1001
1196
|
endIndex = uri.indexOf(Slash, endIndex + 1);
|
|
1002
1197
|
}
|
|
1003
1198
|
};
|
|
1004
|
-
const writeFile = (uri, content) => {
|
|
1199
|
+
const writeFile$1 = (uri, content) => {
|
|
1005
1200
|
const dirent = getDirent(uri);
|
|
1006
1201
|
if (dirent) {
|
|
1007
1202
|
dirent.content = content;
|
|
1008
1203
|
} else {
|
|
1009
1204
|
ensureParentDir(uri);
|
|
1010
|
-
state$
|
|
1205
|
+
state$3.files[uri] = {
|
|
1011
1206
|
type: File$2,
|
|
1012
1207
|
content
|
|
1013
1208
|
};
|
|
1014
1209
|
}
|
|
1015
1210
|
};
|
|
1016
|
-
const mkdir = uri => {
|
|
1211
|
+
const mkdir$1 = uri => {
|
|
1017
1212
|
if (!uri.endsWith(Slash)) {
|
|
1018
1213
|
uri += Slash;
|
|
1019
1214
|
}
|
|
1020
1215
|
ensureParentDir(uri);
|
|
1021
|
-
state$
|
|
1216
|
+
state$3.files[uri] = {
|
|
1022
1217
|
type: Directory$1,
|
|
1023
1218
|
content: ''
|
|
1024
1219
|
};
|
|
1025
1220
|
};
|
|
1026
|
-
const remove = uri => {
|
|
1221
|
+
const remove$1 = uri => {
|
|
1027
1222
|
const toDelete = [];
|
|
1028
|
-
for (const key of Object.keys(state$
|
|
1223
|
+
for (const key of Object.keys(state$3.files)) {
|
|
1029
1224
|
if (key.startsWith(uri)) {
|
|
1030
1225
|
toDelete.push(key);
|
|
1031
1226
|
}
|
|
1032
1227
|
}
|
|
1033
1228
|
for (const key of toDelete) {
|
|
1034
|
-
delete state$
|
|
1229
|
+
delete state$3.files[key];
|
|
1035
1230
|
}
|
|
1036
1231
|
};
|
|
1037
|
-
const readDirWithFileTypes = uri => {
|
|
1232
|
+
const readDirWithFileTypes$1 = uri => {
|
|
1038
1233
|
if (!uri.endsWith(Slash)) {
|
|
1039
1234
|
uri += Slash;
|
|
1040
1235
|
}
|
|
1041
1236
|
const dirents = [];
|
|
1042
|
-
for (const [key, value] of Object.entries(state$
|
|
1237
|
+
for (const [key, value] of Object.entries(state$3.files)) {
|
|
1043
1238
|
if (key.startsWith(uri)) {
|
|
1044
1239
|
// @ts-ignore
|
|
1045
1240
|
switch (value.type) {
|
|
@@ -1066,8 +1261,8 @@ const readDirWithFileTypes = uri => {
|
|
|
1066
1261
|
}
|
|
1067
1262
|
return dirents;
|
|
1068
1263
|
};
|
|
1069
|
-
const getBlob = (uri, type) => {
|
|
1070
|
-
const content = readFile(uri);
|
|
1264
|
+
const getBlob$2 = (uri, type) => {
|
|
1265
|
+
const content = readFile$1(uri);
|
|
1071
1266
|
const contentType = type || getContentType(uri);
|
|
1072
1267
|
const blob = new Blob([content], {
|
|
1073
1268
|
type: contentType
|
|
@@ -1075,769 +1270,50 @@ const getBlob = (uri, type) => {
|
|
|
1075
1270
|
return blob;
|
|
1076
1271
|
};
|
|
1077
1272
|
const getBlobUrl = (uri, type) => {
|
|
1078
|
-
const blob = getBlob(uri, type);
|
|
1273
|
+
const blob = getBlob$2(uri, type);
|
|
1079
1274
|
const url = URL.createObjectURL(blob);
|
|
1080
1275
|
return url;
|
|
1081
1276
|
};
|
|
1082
|
-
const chmod = () => {
|
|
1277
|
+
const chmod$1 = () => {
|
|
1083
1278
|
throw new Error('[memfs] chmod not implemented');
|
|
1084
1279
|
};
|
|
1085
1280
|
const getFiles = () => {
|
|
1086
|
-
return state$
|
|
1281
|
+
return state$3.files;
|
|
1087
1282
|
};
|
|
1088
1283
|
|
|
1089
|
-
const
|
|
1284
|
+
const searchFile$4 = async () => {
|
|
1285
|
+
const files = await getFiles();
|
|
1286
|
+
const keys = Object.keys(files);
|
|
1287
|
+
return keys;
|
|
1288
|
+
};
|
|
1090
1289
|
|
|
1091
|
-
const
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
matches: emptyMatches
|
|
1095
|
-
};
|
|
1290
|
+
const SearchFileMemfs = {
|
|
1291
|
+
__proto__: null,
|
|
1292
|
+
searchFile: searchFile$4
|
|
1096
1293
|
};
|
|
1097
1294
|
|
|
1098
|
-
const
|
|
1099
|
-
const Left = 2;
|
|
1295
|
+
const assetDir = '';
|
|
1100
1296
|
|
|
1101
|
-
|
|
1297
|
+
const fileMapUrl = `${assetDir}/config/fileMap.json`;
|
|
1102
1298
|
|
|
1103
|
-
const
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1299
|
+
const getJson = async url => {
|
|
1300
|
+
try {
|
|
1301
|
+
const response = await fetch(url);
|
|
1302
|
+
if (!response.ok) {
|
|
1303
|
+
throw new Error(response.statusText);
|
|
1304
|
+
}
|
|
1305
|
+
const text = await response.json();
|
|
1306
|
+
return text;
|
|
1307
|
+
} catch (error) {
|
|
1308
|
+
throw new VError(error, `Failed to request json for ${url}`);
|
|
1108
1309
|
}
|
|
1109
|
-
return table;
|
|
1110
|
-
};
|
|
1111
|
-
const EmptyMatches = [];
|
|
1112
|
-
const Dash = '-';
|
|
1113
|
-
const Dot = '.';
|
|
1114
|
-
const EmptyString = '';
|
|
1115
|
-
const Space = ' ';
|
|
1116
|
-
const Underline = '_';
|
|
1117
|
-
const T = 't';
|
|
1118
|
-
const isLowerCase = char => {
|
|
1119
|
-
return char === char.toLowerCase();
|
|
1120
1310
|
};
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
switch (columnCharBefore) {
|
|
1128
|
-
case Dash:
|
|
1129
|
-
case Underline:
|
|
1130
|
-
case EmptyString:
|
|
1131
|
-
case T:
|
|
1132
|
-
case Space:
|
|
1133
|
-
case Dot:
|
|
1134
|
-
return true;
|
|
1135
|
-
}
|
|
1136
|
-
if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
|
|
1137
|
-
return true;
|
|
1138
|
-
}
|
|
1139
|
-
return false;
|
|
1140
|
-
};
|
|
1141
|
-
|
|
1142
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1143
|
-
const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
|
|
1144
|
-
if (rowCharLow !== columnCharLow) {
|
|
1145
|
-
return -1;
|
|
1146
|
-
}
|
|
1147
|
-
const isMatch = rowChar === columnChar;
|
|
1148
|
-
if (isMatch) {
|
|
1149
|
-
if (isDiagonalMatch) {
|
|
1150
|
-
return 8;
|
|
1151
|
-
}
|
|
1152
|
-
if (isGap(columnCharBefore, columnChar)) {
|
|
1153
|
-
return 8;
|
|
1154
|
-
}
|
|
1155
|
-
return 5;
|
|
1156
|
-
}
|
|
1157
|
-
if (isGap(columnCharBefore, columnChar)) {
|
|
1158
|
-
return 8;
|
|
1159
|
-
}
|
|
1160
|
-
return 5;
|
|
1161
|
-
};
|
|
1162
|
-
|
|
1163
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1164
|
-
|
|
1165
|
-
const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
|
|
1166
|
-
while (patternPos < patternLen && wordPos < wordLen) {
|
|
1167
|
-
if (patternLow[patternPos] === wordLow[wordPos]) {
|
|
1168
|
-
patternPos += 1;
|
|
1169
|
-
}
|
|
1170
|
-
wordPos += 1;
|
|
1171
|
-
}
|
|
1172
|
-
return patternPos === patternLen; // pattern must be exhausted
|
|
1173
|
-
};
|
|
1174
|
-
|
|
1175
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1176
|
-
const traceHighlights = (table, arrows, patternLength, wordLength) => {
|
|
1177
|
-
let row = patternLength;
|
|
1178
|
-
let column = wordLength;
|
|
1179
|
-
const matches = [];
|
|
1180
|
-
while (row >= 1 && column >= 1) {
|
|
1181
|
-
const arrow = arrows[row][column];
|
|
1182
|
-
if (arrow === Left) {
|
|
1183
|
-
column--;
|
|
1184
|
-
} else if (arrow === Diagonal) {
|
|
1185
|
-
row--;
|
|
1186
|
-
column--;
|
|
1187
|
-
const start = column + 1;
|
|
1188
|
-
while (row >= 1 && column >= 1) {
|
|
1189
|
-
const arrow = arrows[row][column];
|
|
1190
|
-
if (arrow === Left) {
|
|
1191
|
-
break;
|
|
1192
|
-
}
|
|
1193
|
-
if (arrow === Diagonal) {
|
|
1194
|
-
row--;
|
|
1195
|
-
column--;
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
const end = column;
|
|
1199
|
-
matches.unshift(end, start);
|
|
1200
|
-
}
|
|
1201
|
-
}
|
|
1202
|
-
matches.unshift(table[patternLength][wordLength - 1]);
|
|
1203
|
-
return matches;
|
|
1204
|
-
};
|
|
1205
|
-
|
|
1206
|
-
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1207
|
-
const gridSize = 128;
|
|
1208
|
-
const table = createTable(gridSize);
|
|
1209
|
-
const arrows = createTable(gridSize);
|
|
1210
|
-
const fuzzySearch = (pattern, word) => {
|
|
1211
|
-
const patternLength = Math.min(pattern.length, gridSize - 1);
|
|
1212
|
-
const wordLength = Math.min(word.length, gridSize - 1);
|
|
1213
|
-
const patternLower = pattern.toLowerCase();
|
|
1214
|
-
const wordLower = word.toLowerCase();
|
|
1215
|
-
if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
|
|
1216
|
-
return EmptyMatches;
|
|
1217
|
-
}
|
|
1218
|
-
let strongMatch = false;
|
|
1219
|
-
for (let row = 1; row < patternLength + 1; row++) {
|
|
1220
|
-
const rowChar = pattern[row - 1];
|
|
1221
|
-
const rowCharLow = patternLower[row - 1];
|
|
1222
|
-
for (let column = 1; column < wordLength + 1; column++) {
|
|
1223
|
-
const columnChar = word[column - 1];
|
|
1224
|
-
const columnCharLow = wordLower[column - 1];
|
|
1225
|
-
const columnCharBefore = word[column - 2] || '';
|
|
1226
|
-
const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
|
|
1227
|
-
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
|
|
1228
|
-
if (row === 1 && score > 5) {
|
|
1229
|
-
strongMatch = true;
|
|
1230
|
-
}
|
|
1231
|
-
let diagonalScore = score + table[row - 1][column - 1];
|
|
1232
|
-
if (isDiagonalMatch && score !== -1) {
|
|
1233
|
-
diagonalScore += 2;
|
|
1234
|
-
}
|
|
1235
|
-
const leftScore = table[row][column - 1];
|
|
1236
|
-
if (leftScore > diagonalScore) {
|
|
1237
|
-
table[row][column] = leftScore;
|
|
1238
|
-
arrows[row][column] = Left;
|
|
1239
|
-
} else {
|
|
1240
|
-
table[row][column] = diagonalScore;
|
|
1241
|
-
arrows[row][column] = Diagonal;
|
|
1242
|
-
}
|
|
1243
|
-
}
|
|
1244
|
-
}
|
|
1245
|
-
if (!strongMatch) {
|
|
1246
|
-
return EmptyMatches;
|
|
1247
|
-
}
|
|
1248
|
-
const highlights = traceHighlights(table, arrows, patternLength, wordLength);
|
|
1249
|
-
return highlights;
|
|
1250
|
-
};
|
|
1251
|
-
|
|
1252
|
-
const filterQuickPickItem = (pattern, word) => {
|
|
1253
|
-
const matches = fuzzySearch(pattern, word);
|
|
1254
|
-
return matches;
|
|
1255
|
-
};
|
|
1256
|
-
|
|
1257
|
-
const getBaseName = path => {
|
|
1258
|
-
return path.slice(path.lastIndexOf('/') + 1);
|
|
1259
|
-
};
|
|
1260
|
-
|
|
1261
|
-
const filterQuickPickItems = (items, value) => {
|
|
1262
|
-
if (!value) {
|
|
1263
|
-
return items.map(convertToPick);
|
|
1264
|
-
}
|
|
1265
|
-
const results = [];
|
|
1266
|
-
for (const item of items) {
|
|
1267
|
-
const baseName = getBaseName(item);
|
|
1268
|
-
const matches = filterQuickPickItem(value, baseName);
|
|
1269
|
-
if (matches.length > 0) {
|
|
1270
|
-
results.push({
|
|
1271
|
-
pick: item,
|
|
1272
|
-
matches
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
}
|
|
1276
|
-
return results;
|
|
1277
|
-
};
|
|
1278
|
-
|
|
1279
|
-
const Enter = 3;
|
|
1280
|
-
const Escape = 8;
|
|
1281
|
-
const PageUp = 10;
|
|
1282
|
-
const PageDown = 11;
|
|
1283
|
-
const UpArrow = 14;
|
|
1284
|
-
const DownArrow = 16;
|
|
1285
|
-
|
|
1286
|
-
const FocusQuickPickInput = 20;
|
|
1287
|
-
|
|
1288
|
-
const getKeyBindings = () => {
|
|
1289
|
-
return [{
|
|
1290
|
-
key: Escape,
|
|
1291
|
-
command: 'Viewlet.closeWidget',
|
|
1292
|
-
args: ['QuickPick'],
|
|
1293
|
-
when: FocusQuickPickInput
|
|
1294
|
-
}, {
|
|
1295
|
-
key: UpArrow,
|
|
1296
|
-
command: 'QuickPick.focusPrevious',
|
|
1297
|
-
when: FocusQuickPickInput
|
|
1298
|
-
}, {
|
|
1299
|
-
key: DownArrow,
|
|
1300
|
-
command: 'QuickPick.focusNext',
|
|
1301
|
-
when: FocusQuickPickInput
|
|
1302
|
-
}, {
|
|
1303
|
-
key: PageUp,
|
|
1304
|
-
command: 'QuickPick.focusFirst',
|
|
1305
|
-
when: FocusQuickPickInput
|
|
1306
|
-
}, {
|
|
1307
|
-
key: PageDown,
|
|
1308
|
-
command: 'QuickPick.focusLast',
|
|
1309
|
-
when: FocusQuickPickInput
|
|
1310
|
-
}, {
|
|
1311
|
-
key: Enter,
|
|
1312
|
-
command: 'QuickPick.selectCurrentIndex',
|
|
1313
|
-
when: FocusQuickPickInput
|
|
1314
|
-
}];
|
|
1315
|
-
};
|
|
1316
|
-
|
|
1317
|
-
// TODO support file icons
|
|
1318
|
-
const getFolderIcon = () => {
|
|
1319
|
-
return '';
|
|
1320
|
-
};
|
|
1321
|
-
|
|
1322
|
-
const Hide = 'hide';
|
|
1323
|
-
const KeepOpen = '';
|
|
1324
|
-
|
|
1325
|
-
const emptyObject = {};
|
|
1326
|
-
const RE_PLACEHOLDER = /\{(PH\d+)\}/g;
|
|
1327
|
-
const i18nString = (key, placeholders = emptyObject) => {
|
|
1328
|
-
if (placeholders === emptyObject) {
|
|
1329
|
-
return key;
|
|
1330
|
-
}
|
|
1331
|
-
const replacer = (match, rest) => {
|
|
1332
|
-
return placeholders[rest];
|
|
1333
|
-
};
|
|
1334
|
-
return key.replaceAll(RE_PLACEHOLDER, replacer);
|
|
1335
|
-
};
|
|
1336
|
-
|
|
1337
|
-
/**
|
|
1338
|
-
* @enum {string}
|
|
1339
|
-
*/
|
|
1340
|
-
const UiStrings = {
|
|
1341
|
-
Files: 'Files',
|
|
1342
|
-
GoToFile: 'Go to file',
|
|
1343
|
-
NoMatchingColorThemesFound: 'No matching color themes found',
|
|
1344
|
-
NoMatchingResults: 'No matching results',
|
|
1345
|
-
NoRecentlyOpenedFoldersFound: 'No recently opened folders found',
|
|
1346
|
-
NoResults: 'No Results',
|
|
1347
|
-
NoSymbolFound: 'No symbol found',
|
|
1348
|
-
NoWorkspaceSymbolsFound: 'no workspace symbols found',
|
|
1349
|
-
OpenRecent: 'Open Recent',
|
|
1350
|
-
SelectColorTheme: 'Select Color Theme',
|
|
1351
|
-
SelectToOpen: 'Select to open',
|
|
1352
|
-
ShowAndRunCommands: 'Show And Run Commands',
|
|
1353
|
-
TypeNameOfCommandToRun: 'Type the name of a command to run.',
|
|
1354
|
-
TypeTheNameOfAViewToOpen: 'Type the name of a view, output channel or terminal to open.'
|
|
1355
|
-
};
|
|
1356
|
-
const noMatchingColorThemesFound = () => {
|
|
1357
|
-
return i18nString(UiStrings.NoMatchingColorThemesFound);
|
|
1358
|
-
};
|
|
1359
|
-
const selectColorTheme = () => {
|
|
1360
|
-
return i18nString(UiStrings.SelectColorTheme);
|
|
1361
|
-
};
|
|
1362
|
-
const typeNameofCommandToRun = () => {
|
|
1363
|
-
return i18nString(UiStrings.TypeNameOfCommandToRun);
|
|
1364
|
-
};
|
|
1365
|
-
const showAndRunCommands = () => {
|
|
1366
|
-
return i18nString(UiStrings.ShowAndRunCommands);
|
|
1367
|
-
};
|
|
1368
|
-
const noMatchingResults = () => {
|
|
1369
|
-
return i18nString(UiStrings.NoMatchingResults);
|
|
1370
|
-
};
|
|
1371
|
-
const files = () => {
|
|
1372
|
-
return i18nString(UiStrings.Files);
|
|
1373
|
-
};
|
|
1374
|
-
const goToFile = () => {
|
|
1375
|
-
return i18nString(UiStrings.GoToFile);
|
|
1376
|
-
};
|
|
1377
|
-
const noResults = () => {
|
|
1378
|
-
return i18nString(UiStrings.NoResults);
|
|
1379
|
-
};
|
|
1380
|
-
const selectToOpen = () => {
|
|
1381
|
-
return i18nString(UiStrings.SelectToOpen);
|
|
1382
|
-
};
|
|
1383
|
-
const openRecent = () => {
|
|
1384
|
-
return i18nString(UiStrings.OpenRecent);
|
|
1385
|
-
};
|
|
1386
|
-
const noRecentlyOpenedFoldersFound = () => {
|
|
1387
|
-
return i18nString(UiStrings.NoRecentlyOpenedFoldersFound);
|
|
1388
|
-
};
|
|
1389
|
-
const noSymbolFound = () => {
|
|
1390
|
-
return i18nString(UiStrings.NoSymbolFound);
|
|
1391
|
-
};
|
|
1392
|
-
const noWorkspaceSymbolsFound = () => {
|
|
1393
|
-
return i18nString(UiStrings.NoWorkspaceSymbolsFound);
|
|
1394
|
-
};
|
|
1395
|
-
|
|
1396
|
-
const state$4 = {
|
|
1397
|
-
rpc: undefined
|
|
1398
|
-
};
|
|
1399
|
-
const invoke$1 = (method, ...params) => {
|
|
1400
|
-
const rpc = state$4.rpc;
|
|
1401
|
-
// @ts-ignore
|
|
1402
|
-
return rpc.invoke(method, ...params);
|
|
1403
|
-
};
|
|
1404
|
-
const setRpc = rpc => {
|
|
1405
|
-
state$4.rpc = rpc;
|
|
1406
|
-
};
|
|
1407
|
-
|
|
1408
|
-
// TODO this should be in FileSystem module
|
|
1409
|
-
const pathBaseName = path => {
|
|
1410
|
-
return path.slice(path.lastIndexOf('/') + 1);
|
|
1411
|
-
};
|
|
1412
|
-
|
|
1413
|
-
// TODO this should be in FileSystem module
|
|
1414
|
-
const pathDirName = path => {
|
|
1415
|
-
const pathSeparator = '/';
|
|
1416
|
-
const index = path.lastIndexOf(pathSeparator);
|
|
1417
|
-
if (index === -1) {
|
|
1418
|
-
return '';
|
|
1419
|
-
}
|
|
1420
|
-
return path.slice(0, index);
|
|
1421
|
-
};
|
|
1422
|
-
|
|
1423
|
-
const getRecentlyOpened = () => {
|
|
1424
|
-
return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
1425
|
-
};
|
|
1426
|
-
const openWorkspaceFolder = uri => {
|
|
1427
|
-
return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
|
|
1428
|
-
};
|
|
1429
|
-
const getPlaceholder$b = () => {
|
|
1430
|
-
return selectToOpen();
|
|
1431
|
-
};
|
|
1432
|
-
const getLabel$5 = () => {
|
|
1433
|
-
return openRecent();
|
|
1434
|
-
};
|
|
1435
|
-
const getHelpEntries$9 = () => {
|
|
1436
|
-
return [];
|
|
1437
|
-
};
|
|
1438
|
-
const getNoResults$a = () => {
|
|
1439
|
-
return {
|
|
1440
|
-
label: noRecentlyOpenedFoldersFound()
|
|
1441
|
-
};
|
|
1442
|
-
};
|
|
1443
|
-
|
|
1444
|
-
// TODO could also change api so that getPicks returns an array of anything
|
|
1445
|
-
// and the transformPick gets the label for each pick
|
|
1446
|
-
// This would make the code more module since the code for getting the picks
|
|
1447
|
-
// would be more independent of the specific data format of the quickpick provider
|
|
1448
|
-
|
|
1449
|
-
const getPicks$b = async () => {
|
|
1450
|
-
const recentlyOpened = await getRecentlyOpened();
|
|
1451
|
-
return recentlyOpened;
|
|
1452
|
-
};
|
|
1453
|
-
|
|
1454
|
-
// TODO selectPick should be independent of show/hide
|
|
1455
|
-
const selectPick$b = async pick => {
|
|
1456
|
-
const path = pick;
|
|
1457
|
-
await openWorkspaceFolder(path);
|
|
1458
|
-
return {
|
|
1459
|
-
command: Hide
|
|
1460
|
-
};
|
|
1461
|
-
};
|
|
1462
|
-
const getFilterValue$a = value => {
|
|
1463
|
-
return pathBaseName(value);
|
|
1464
|
-
};
|
|
1465
|
-
const getPickFilterValue$6 = pick => {
|
|
1466
|
-
return pathBaseName(pick);
|
|
1467
|
-
};
|
|
1468
|
-
const getPickLabel$5 = pick => {
|
|
1469
|
-
return pathBaseName(pick);
|
|
1470
|
-
};
|
|
1471
|
-
const getPickDescription$3 = pick => {
|
|
1472
|
-
return pathDirName(pick);
|
|
1473
|
-
};
|
|
1474
|
-
const getPickIcon$5 = () => {
|
|
1475
|
-
return '';
|
|
1476
|
-
};
|
|
1477
|
-
const getPickFileIcon$2 = () => {
|
|
1478
|
-
return getFolderIcon();
|
|
1479
|
-
};
|
|
1480
|
-
|
|
1481
|
-
const QuickPickEntriesOpenRecent = {
|
|
1482
|
-
__proto__: null,
|
|
1483
|
-
getFilterValue: getFilterValue$a,
|
|
1484
|
-
getHelpEntries: getHelpEntries$9,
|
|
1485
|
-
getLabel: getLabel$5,
|
|
1486
|
-
getNoResults: getNoResults$a,
|
|
1487
|
-
getPickDescription: getPickDescription$3,
|
|
1488
|
-
getPickFileIcon: getPickFileIcon$2,
|
|
1489
|
-
getPickFilterValue: getPickFilterValue$6,
|
|
1490
|
-
getPickIcon: getPickIcon$5,
|
|
1491
|
-
getPickLabel: getPickLabel$5,
|
|
1492
|
-
getPicks: getPicks$b,
|
|
1493
|
-
getPlaceholder: getPlaceholder$b,
|
|
1494
|
-
selectPick: selectPick$b
|
|
1495
|
-
};
|
|
1496
|
-
|
|
1497
|
-
const CommandPalette = 'quickPick://commandPalette';
|
|
1498
|
-
const File$1 = 'quickPick://file';
|
|
1499
|
-
const EveryThing = 'quickPick://everything';
|
|
1500
|
-
const Number$1 = 'quickPick://number';
|
|
1501
|
-
const Recent = 'quickPick://recent';
|
|
1502
|
-
const ColorTheme = 'quickPick://color-theme';
|
|
1503
|
-
const Symbol$2 = 'quickPick://symbol';
|
|
1504
|
-
const View$1 = 'quickPick://view';
|
|
1505
|
-
const WorkspaceSymbol$1 = 'quickPick://workspace-symbol';
|
|
1506
|
-
const Custom = 'quickPick://custom';
|
|
1507
|
-
|
|
1508
|
-
const loadQuickPickEntries = moduleId => {
|
|
1509
|
-
switch (moduleId) {
|
|
1510
|
-
case Recent:
|
|
1511
|
-
return QuickPickEntriesOpenRecent;
|
|
1512
|
-
default:
|
|
1513
|
-
throw new Error(`unknown module "${moduleId}"`);
|
|
1514
|
-
}
|
|
1515
|
-
};
|
|
1516
|
-
|
|
1517
|
-
const getColorThemeNames = async () => {
|
|
1518
|
-
return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
|
|
1519
|
-
};
|
|
1520
|
-
|
|
1521
|
-
const setColorTheme = id => {
|
|
1522
|
-
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
1523
|
-
};
|
|
1524
|
-
const getPlaceholder$a = () => {
|
|
1525
|
-
return selectColorTheme();
|
|
1526
|
-
};
|
|
1527
|
-
const getLabel$4 = () => {
|
|
1528
|
-
return selectColorTheme();
|
|
1529
|
-
};
|
|
1530
|
-
const getPicks$a = async searchValue => {
|
|
1531
|
-
const colorThemeNames = await getColorThemeNames();
|
|
1532
|
-
return colorThemeNames;
|
|
1533
|
-
};
|
|
1534
|
-
const selectPick$a = async pick => {
|
|
1535
|
-
await setColorTheme(/* colorThemeId */pick);
|
|
1536
|
-
return {
|
|
1537
|
-
command: Hide
|
|
1538
|
-
};
|
|
1539
|
-
};
|
|
1540
|
-
const focusPick = async pick => {
|
|
1541
|
-
await setColorTheme(/* colorThemeId */pick);
|
|
1542
|
-
};
|
|
1543
|
-
const getFilterValue$9 = value => {
|
|
1544
|
-
return value;
|
|
1545
|
-
};
|
|
1546
|
-
const getNoResults$9 = () => {
|
|
1547
|
-
return {
|
|
1548
|
-
label: noMatchingColorThemesFound()
|
|
1549
|
-
};
|
|
1550
|
-
};
|
|
1551
|
-
const getPickFilterValue$5 = pick => {
|
|
1552
|
-
return pick;
|
|
1553
|
-
};
|
|
1554
|
-
const getPickLabel$4 = pick => {
|
|
1555
|
-
return pick;
|
|
1556
|
-
};
|
|
1557
|
-
const getPickIcon$4 = pick => {
|
|
1558
|
-
return '';
|
|
1559
|
-
};
|
|
1560
|
-
|
|
1561
|
-
const QuickPickEntriesColorTheme = {
|
|
1562
|
-
__proto__: null,
|
|
1563
|
-
focusPick,
|
|
1564
|
-
getFilterValue: getFilterValue$9,
|
|
1565
|
-
getLabel: getLabel$4,
|
|
1566
|
-
getNoResults: getNoResults$9,
|
|
1567
|
-
getPickFilterValue: getPickFilterValue$5,
|
|
1568
|
-
getPickIcon: getPickIcon$4,
|
|
1569
|
-
getPickLabel: getPickLabel$4,
|
|
1570
|
-
getPicks: getPicks$a,
|
|
1571
|
-
getPlaceholder: getPlaceholder$a,
|
|
1572
|
-
selectPick: selectPick$a,
|
|
1573
|
-
setColorTheme
|
|
1574
|
-
};
|
|
1575
|
-
|
|
1576
|
-
const Tag$1 = 'Tag';
|
|
1577
|
-
const Cloud$1 = 'Cloud';
|
|
1578
|
-
const SourceControl$1 = 'SourceControl';
|
|
1579
|
-
const None$1 = '';
|
|
1580
|
-
|
|
1581
|
-
const SourceControl = 1;
|
|
1582
|
-
const Cloud = 2;
|
|
1583
|
-
const Tag = 3;
|
|
1584
|
-
|
|
1585
|
-
const name$8 = 'custom';
|
|
1586
|
-
const state$3 = {
|
|
1587
|
-
args: []
|
|
1588
|
-
};
|
|
1589
|
-
const setArgs = args => {
|
|
1590
|
-
state$3.args = args;
|
|
1591
|
-
};
|
|
1592
|
-
const getPlaceholder$9 = () => {
|
|
1593
|
-
return '';
|
|
1594
|
-
};
|
|
1595
|
-
const getLabel$3 = () => {
|
|
1596
|
-
return 'Custom';
|
|
1597
|
-
};
|
|
1598
|
-
|
|
1599
|
-
// TODO help entries should not be here
|
|
1600
|
-
const getHelpEntries$8 = () => {
|
|
1601
|
-
return [];
|
|
1602
|
-
};
|
|
1603
|
-
const getNoResults$8 = () => {
|
|
1604
|
-
return {
|
|
1605
|
-
label: noMatchingResults()
|
|
1606
|
-
};
|
|
1607
|
-
};
|
|
1608
|
-
const getPicks$9 = async searchValue => {
|
|
1609
|
-
const items = state$3.args[1] || [];
|
|
1610
|
-
return items;
|
|
1611
|
-
};
|
|
1612
|
-
const selectPick$9 = async pick => {
|
|
1613
|
-
const {
|
|
1614
|
-
args
|
|
1615
|
-
} = state$3;
|
|
1616
|
-
const resolve = args[2];
|
|
1617
|
-
resolve(pick);
|
|
1618
|
-
return {
|
|
1619
|
-
command: Hide
|
|
1620
|
-
};
|
|
1621
|
-
};
|
|
1622
|
-
const getFilterValue$8 = value => {
|
|
1623
|
-
return value;
|
|
1624
|
-
};
|
|
1625
|
-
const getPickFilterValue$4 = pick => {
|
|
1626
|
-
return pick;
|
|
1627
|
-
};
|
|
1628
|
-
const getPickLabel$3 = pick => {
|
|
1629
|
-
return pick.label;
|
|
1630
|
-
};
|
|
1631
|
-
const getPickDescription$2 = pick => {
|
|
1632
|
-
return pick.description || '';
|
|
1633
|
-
};
|
|
1634
|
-
const convertIcon = icon => {
|
|
1635
|
-
switch (icon) {
|
|
1636
|
-
case SourceControl:
|
|
1637
|
-
return SourceControl$1;
|
|
1638
|
-
case Cloud:
|
|
1639
|
-
return Cloud$1;
|
|
1640
|
-
case Tag:
|
|
1641
|
-
return Tag$1;
|
|
1642
|
-
default:
|
|
1643
|
-
return None$1;
|
|
1644
|
-
}
|
|
1645
|
-
};
|
|
1646
|
-
const getPickIcon$3 = pick => {
|
|
1647
|
-
return convertIcon(pick.icon);
|
|
1648
|
-
};
|
|
1649
|
-
|
|
1650
|
-
const QuickPickEntriesCustom = {
|
|
1651
|
-
__proto__: null,
|
|
1652
|
-
getFilterValue: getFilterValue$8,
|
|
1653
|
-
getHelpEntries: getHelpEntries$8,
|
|
1654
|
-
getLabel: getLabel$3,
|
|
1655
|
-
getNoResults: getNoResults$8,
|
|
1656
|
-
getPickDescription: getPickDescription$2,
|
|
1657
|
-
getPickFilterValue: getPickFilterValue$4,
|
|
1658
|
-
getPickIcon: getPickIcon$3,
|
|
1659
|
-
getPickLabel: getPickLabel$3,
|
|
1660
|
-
getPicks: getPicks$9,
|
|
1661
|
-
getPlaceholder: getPlaceholder$9,
|
|
1662
|
-
name: name$8,
|
|
1663
|
-
selectPick: selectPick$9,
|
|
1664
|
-
setArgs,
|
|
1665
|
-
state: state$3
|
|
1666
|
-
};
|
|
1667
|
-
|
|
1668
|
-
const handleError = async (error, notify = true, prefix = '') => {
|
|
1669
|
-
console.error(error);
|
|
1670
|
-
};
|
|
1671
|
-
const showErrorDialog = async () => {};
|
|
1672
|
-
const warn = (...args) => {
|
|
1673
|
-
console.warn(...args);
|
|
1674
|
-
};
|
|
1675
|
-
|
|
1676
|
-
const state$2 = {
|
|
1677
|
-
menuEntries: []
|
|
1678
|
-
};
|
|
1679
|
-
const getAll = () => {
|
|
1680
|
-
return state$2.menuEntries;
|
|
1681
|
-
};
|
|
1682
|
-
|
|
1683
|
-
const name$7 = 'command';
|
|
1684
|
-
const getPlaceholder$8 = () => {
|
|
1685
|
-
return typeNameofCommandToRun();
|
|
1686
|
-
};
|
|
1687
|
-
const helpEntries = () => {
|
|
1688
|
-
return [{
|
|
1689
|
-
description: showAndRunCommands(),
|
|
1690
|
-
category: 'global commands'
|
|
1691
|
-
}];
|
|
1692
|
-
};
|
|
1693
|
-
const getLabel$2 = () => {
|
|
1694
|
-
return '';
|
|
1695
|
-
};
|
|
1696
|
-
const getNoResults$7 = () => {
|
|
1697
|
-
return {
|
|
1698
|
-
label: noMatchingResults()
|
|
1699
|
-
};
|
|
1700
|
-
};
|
|
1701
|
-
|
|
1702
|
-
// TODO combine Ajax with cache (specify strategy: cacheFirst, networkFirst)
|
|
1703
|
-
const getBuiltinPicks = async () => {
|
|
1704
|
-
const builtinPicks = getAll();
|
|
1705
|
-
return builtinPicks;
|
|
1706
|
-
};
|
|
1707
|
-
const prefixIdWithExt = item => {
|
|
1708
|
-
if (!item.label) {
|
|
1709
|
-
warn('[QuickPick] item has missing label', item);
|
|
1710
|
-
}
|
|
1711
|
-
if (!item.id) {
|
|
1712
|
-
warn('[QuickPick] item has missing id', item);
|
|
1713
|
-
}
|
|
1714
|
-
return {
|
|
1715
|
-
...item,
|
|
1716
|
-
id: `ext.${item.id}`,
|
|
1717
|
-
label: item.label || item.id
|
|
1718
|
-
};
|
|
1719
|
-
};
|
|
1720
|
-
const getExtensionPicks = async () => {
|
|
1721
|
-
try {
|
|
1722
|
-
// TODO don't call this every time
|
|
1723
|
-
const extensionPicks = await invoke$1('ExtensionHostCommands.getCommands');
|
|
1724
|
-
if (!extensionPicks) {
|
|
1725
|
-
return [];
|
|
1726
|
-
}
|
|
1727
|
-
const mappedPicks = extensionPicks.map(prefixIdWithExt);
|
|
1728
|
-
return mappedPicks;
|
|
1729
|
-
} catch (error) {
|
|
1730
|
-
console.error(`Failed to get extension picks: ${error}`);
|
|
1731
|
-
return [];
|
|
1732
|
-
}
|
|
1733
|
-
};
|
|
1734
|
-
|
|
1735
|
-
// TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
|
|
1736
|
-
|
|
1737
|
-
const getPicks$8 = async () => {
|
|
1738
|
-
const builtinPicks = await getBuiltinPicks();
|
|
1739
|
-
const extensionPicks = await getExtensionPicks();
|
|
1740
|
-
return [...builtinPicks, ...extensionPicks];
|
|
1741
|
-
};
|
|
1742
|
-
const shouldHide = item => {
|
|
1743
|
-
if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
|
|
1744
|
-
return false;
|
|
1745
|
-
}
|
|
1746
|
-
return true;
|
|
1747
|
-
};
|
|
1748
|
-
const selectPickBuiltin = async item => {
|
|
1749
|
-
const args = item.args || [];
|
|
1750
|
-
// TODO ids should be all numbers for efficiency -> also directly can call command
|
|
1751
|
-
await invoke$1(item.id, ...args);
|
|
1752
|
-
if (shouldHide(item)) {
|
|
1753
|
-
return {
|
|
1754
|
-
command: Hide
|
|
1755
|
-
};
|
|
1756
|
-
}
|
|
1757
|
-
return {
|
|
1758
|
-
command: KeepOpen
|
|
1759
|
-
};
|
|
1760
|
-
};
|
|
1761
|
-
const selectPickExtension = async item => {
|
|
1762
|
-
const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
|
|
1763
|
-
try {
|
|
1764
|
-
await invoke$1('ExtensionHostCommands.executeCommand', id);
|
|
1765
|
-
} catch (error) {
|
|
1766
|
-
await handleError(error, false);
|
|
1767
|
-
// @ts-ignore
|
|
1768
|
-
await showErrorDialog();
|
|
1769
|
-
}
|
|
1770
|
-
return {
|
|
1771
|
-
command: Hide
|
|
1772
|
-
};
|
|
1773
|
-
};
|
|
1774
|
-
const selectPick$8 = async item => {
|
|
1775
|
-
if (item.id.startsWith('ext.')) {
|
|
1776
|
-
return selectPickExtension(item);
|
|
1777
|
-
}
|
|
1778
|
-
return selectPickBuiltin(item);
|
|
1779
|
-
};
|
|
1780
|
-
const getFilterValue$7 = value => {
|
|
1781
|
-
return value;
|
|
1782
|
-
};
|
|
1783
|
-
const getPickFilterValue$3 = pick => {
|
|
1784
|
-
return pick.label;
|
|
1785
|
-
};
|
|
1786
|
-
const getPickLabel$2 = pick => {
|
|
1787
|
-
return pick.label;
|
|
1788
|
-
};
|
|
1789
|
-
const getPickIcon$2 = () => {
|
|
1790
|
-
return '';
|
|
1791
|
-
};
|
|
1792
|
-
|
|
1793
|
-
const QuickPickEntriesCommand = {
|
|
1794
|
-
__proto__: null,
|
|
1795
|
-
getFilterValue: getFilterValue$7,
|
|
1796
|
-
getLabel: getLabel$2,
|
|
1797
|
-
getNoResults: getNoResults$7,
|
|
1798
|
-
getPickFilterValue: getPickFilterValue$3,
|
|
1799
|
-
getPickIcon: getPickIcon$2,
|
|
1800
|
-
getPickLabel: getPickLabel$2,
|
|
1801
|
-
getPicks: getPicks$8,
|
|
1802
|
-
getPlaceholder: getPlaceholder$8,
|
|
1803
|
-
helpEntries,
|
|
1804
|
-
name: name$7,
|
|
1805
|
-
selectPick: selectPick$8
|
|
1806
|
-
};
|
|
1807
|
-
|
|
1808
|
-
const execute = async (method, ...params) => {
|
|
1809
|
-
// TODO
|
|
1810
|
-
};
|
|
1811
|
-
|
|
1812
|
-
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1813
|
-
const getProtocol = uri => {
|
|
1814
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1815
|
-
if (protocolMatch) {
|
|
1816
|
-
return protocolMatch[1];
|
|
1817
|
-
}
|
|
1818
|
-
return '';
|
|
1819
|
-
};
|
|
1820
|
-
|
|
1821
|
-
const Memfs = 'memfs';
|
|
1822
|
-
const Html = 'html';
|
|
1823
|
-
const Fetch = 'fetch';
|
|
1824
|
-
|
|
1825
|
-
const searchFile$4 = async () => {
|
|
1826
|
-
const files = await getFiles();
|
|
1827
|
-
const keys = Object.keys(files);
|
|
1828
|
-
return keys;
|
|
1829
|
-
};
|
|
1830
|
-
|
|
1831
|
-
const SearchFileMemfs = {
|
|
1832
|
-
__proto__: null,
|
|
1833
|
-
searchFile: searchFile$4
|
|
1834
|
-
};
|
|
1835
|
-
|
|
1836
|
-
const removeLeadingSlash = path => {
|
|
1837
|
-
if (path.startsWith('/')) {
|
|
1838
|
-
return path.slice(1);
|
|
1839
|
-
}
|
|
1840
|
-
return path;
|
|
1311
|
+
|
|
1312
|
+
const removeLeadingSlash = path => {
|
|
1313
|
+
if (path.startsWith('/')) {
|
|
1314
|
+
return path.slice(1);
|
|
1315
|
+
}
|
|
1316
|
+
return path;
|
|
1841
1317
|
};
|
|
1842
1318
|
|
|
1843
1319
|
// TODO simplify code
|
|
@@ -1860,7 +1336,7 @@ const SearchFileFetch = {
|
|
|
1860
1336
|
};
|
|
1861
1337
|
|
|
1862
1338
|
const Directory = 'directory';
|
|
1863
|
-
const File = 'file';
|
|
1339
|
+
const File$1 = 'file';
|
|
1864
1340
|
|
|
1865
1341
|
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
1866
1342
|
|
|
@@ -1878,6 +1354,7 @@ const fromAsync = async asyncIterable => {
|
|
|
1878
1354
|
* retrieve the child handles
|
|
1879
1355
|
*
|
|
1880
1356
|
*/
|
|
1357
|
+
|
|
1881
1358
|
const getChildHandles = async handle => {
|
|
1882
1359
|
// @ts-ignore
|
|
1883
1360
|
const handles = await fromAsync(handle.values());
|
|
@@ -2138,7 +1615,7 @@ replaceTraps(oldTraps => ({
|
|
|
2138
1615
|
}
|
|
2139
1616
|
}));
|
|
2140
1617
|
|
|
2141
|
-
const state$
|
|
1618
|
+
const state$2 = {
|
|
2142
1619
|
databases: Object.create(null),
|
|
2143
1620
|
eventId: 0,
|
|
2144
1621
|
dbVersion: 1,
|
|
@@ -2149,78 +1626,268 @@ const state$1 = {
|
|
|
2149
1626
|
|
|
2150
1627
|
const getHandleDb = async () => {
|
|
2151
1628
|
// @ts-ignore
|
|
2152
|
-
const db = await openDB('handle', state$
|
|
1629
|
+
const db = await openDB('handle', state$2.dbVersion, {
|
|
2153
1630
|
async upgrade(db) {
|
|
2154
1631
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
2155
1632
|
await db.createObjectStore('file-handles-store', {});
|
|
2156
1633
|
}
|
|
2157
1634
|
}
|
|
2158
|
-
});
|
|
2159
|
-
return db;
|
|
1635
|
+
});
|
|
1636
|
+
return db;
|
|
1637
|
+
};
|
|
1638
|
+
const getHandle$1 = async uri => {
|
|
1639
|
+
const handleDb = await getHandleDb();
|
|
1640
|
+
const handle = await handleDb.get('file-handles-store', uri);
|
|
1641
|
+
return handle;
|
|
1642
|
+
};
|
|
1643
|
+
|
|
1644
|
+
const getHandle = async uri => {
|
|
1645
|
+
try {
|
|
1646
|
+
// TODO retrieve handle from state or from indexeddb
|
|
1647
|
+
// TODO if not found, throw error
|
|
1648
|
+
const handle = await getHandle$1(uri);
|
|
1649
|
+
return handle;
|
|
1650
|
+
} catch (error) {
|
|
1651
|
+
throw new VError(error, 'Failed to get handle');
|
|
1652
|
+
}
|
|
1653
|
+
};
|
|
1654
|
+
|
|
1655
|
+
const getDirectoryHandle = async uri => {
|
|
1656
|
+
const handle = await getHandle(uri);
|
|
1657
|
+
if (handle) {
|
|
1658
|
+
return handle;
|
|
1659
|
+
}
|
|
1660
|
+
const dirname$1 = dirname('/', uri);
|
|
1661
|
+
if (uri === dirname$1) {
|
|
1662
|
+
return undefined;
|
|
1663
|
+
}
|
|
1664
|
+
return getDirectoryHandle(dirname$1);
|
|
1665
|
+
};
|
|
1666
|
+
const toIgnore = ['.git', 'node_modules', 'dist', 'dist2'];
|
|
1667
|
+
const searchFilesRecursively = async (all, parent, handle) => {
|
|
1668
|
+
const childHandles = await getChildHandles(handle);
|
|
1669
|
+
const promises = [];
|
|
1670
|
+
for (const childHandle of childHandles) {
|
|
1671
|
+
if (toIgnore.includes(childHandle.name)) {
|
|
1672
|
+
continue;
|
|
1673
|
+
}
|
|
1674
|
+
const absolutePath = parent + '/' + childHandle.name;
|
|
1675
|
+
switch (childHandle.kind) {
|
|
1676
|
+
case Directory:
|
|
1677
|
+
promises.push(searchFilesRecursively(all, absolutePath, childHandle));
|
|
1678
|
+
break;
|
|
1679
|
+
case File$1:
|
|
1680
|
+
all.push(absolutePath);
|
|
1681
|
+
break;
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1684
|
+
await Promise.all(promises);
|
|
1685
|
+
};
|
|
1686
|
+
const searchFile$2 = async uri => {
|
|
1687
|
+
const path = uri.slice('html://'.length);
|
|
1688
|
+
const handle = await getDirectoryHandle(path);
|
|
1689
|
+
if (!handle) {
|
|
1690
|
+
// @ts-ignore
|
|
1691
|
+
throw new VError(`Folder not found ${uri}`);
|
|
1692
|
+
}
|
|
1693
|
+
const all = [];
|
|
1694
|
+
await searchFilesRecursively(all, '', handle);
|
|
1695
|
+
return all;
|
|
1696
|
+
};
|
|
1697
|
+
|
|
1698
|
+
const SearchFileHtml = {
|
|
1699
|
+
__proto__: null,
|
|
1700
|
+
searchFile: searchFile$2
|
|
1701
|
+
};
|
|
1702
|
+
|
|
1703
|
+
const emptyMatches = [];
|
|
1704
|
+
|
|
1705
|
+
const convertToPick = item => {
|
|
1706
|
+
return {
|
|
1707
|
+
pick: item,
|
|
1708
|
+
matches: emptyMatches
|
|
1709
|
+
};
|
|
1710
|
+
};
|
|
1711
|
+
|
|
1712
|
+
const Diagonal = 1;
|
|
1713
|
+
const Left = 2;
|
|
1714
|
+
|
|
1715
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1716
|
+
|
|
1717
|
+
const createTable = size => {
|
|
1718
|
+
const table = [];
|
|
1719
|
+
for (let i = 0; i < size; i++) {
|
|
1720
|
+
const row = new Uint8Array(size);
|
|
1721
|
+
table.push(row);
|
|
1722
|
+
}
|
|
1723
|
+
return table;
|
|
1724
|
+
};
|
|
1725
|
+
const EmptyMatches = [];
|
|
1726
|
+
const Dash = '-';
|
|
1727
|
+
const Dot = '.';
|
|
1728
|
+
const EmptyString = '';
|
|
1729
|
+
const Space = ' ';
|
|
1730
|
+
const Underline = '_';
|
|
1731
|
+
const T = 't';
|
|
1732
|
+
const isLowerCase = char => {
|
|
1733
|
+
return char === char.toLowerCase();
|
|
1734
|
+
};
|
|
1735
|
+
const isUpperCase = char => {
|
|
1736
|
+
return char === char.toUpperCase();
|
|
1737
|
+
};
|
|
1738
|
+
|
|
1739
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1740
|
+
const isGap = (columnCharBefore, columnChar) => {
|
|
1741
|
+
switch (columnCharBefore) {
|
|
1742
|
+
case Dash:
|
|
1743
|
+
case Underline:
|
|
1744
|
+
case EmptyString:
|
|
1745
|
+
case T:
|
|
1746
|
+
case Space:
|
|
1747
|
+
case Dot:
|
|
1748
|
+
return true;
|
|
1749
|
+
}
|
|
1750
|
+
if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
|
|
1751
|
+
return true;
|
|
1752
|
+
}
|
|
1753
|
+
return false;
|
|
1754
|
+
};
|
|
1755
|
+
|
|
1756
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1757
|
+
const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
|
|
1758
|
+
if (rowCharLow !== columnCharLow) {
|
|
1759
|
+
return -1;
|
|
1760
|
+
}
|
|
1761
|
+
const isMatch = rowChar === columnChar;
|
|
1762
|
+
if (isMatch) {
|
|
1763
|
+
if (isDiagonalMatch) {
|
|
1764
|
+
return 8;
|
|
1765
|
+
}
|
|
1766
|
+
if (isGap(columnCharBefore, columnChar)) {
|
|
1767
|
+
return 8;
|
|
1768
|
+
}
|
|
1769
|
+
return 5;
|
|
1770
|
+
}
|
|
1771
|
+
if (isGap(columnCharBefore, columnChar)) {
|
|
1772
|
+
return 8;
|
|
1773
|
+
}
|
|
1774
|
+
return 5;
|
|
1775
|
+
};
|
|
1776
|
+
|
|
1777
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1778
|
+
|
|
1779
|
+
const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
|
|
1780
|
+
while (patternPos < patternLen && wordPos < wordLen) {
|
|
1781
|
+
if (patternLow[patternPos] === wordLow[wordPos]) {
|
|
1782
|
+
patternPos += 1;
|
|
1783
|
+
}
|
|
1784
|
+
wordPos += 1;
|
|
1785
|
+
}
|
|
1786
|
+
return patternPos === patternLen; // pattern must be exhausted
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1789
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1790
|
+
const traceHighlights = (table, arrows, patternLength, wordLength) => {
|
|
1791
|
+
let row = patternLength;
|
|
1792
|
+
let column = wordLength;
|
|
1793
|
+
const matches = [];
|
|
1794
|
+
while (row >= 1 && column >= 1) {
|
|
1795
|
+
const arrow = arrows[row][column];
|
|
1796
|
+
if (arrow === Left) {
|
|
1797
|
+
column--;
|
|
1798
|
+
} else if (arrow === Diagonal) {
|
|
1799
|
+
row--;
|
|
1800
|
+
column--;
|
|
1801
|
+
const start = column + 1;
|
|
1802
|
+
while (row >= 1 && column >= 1) {
|
|
1803
|
+
const arrow = arrows[row][column];
|
|
1804
|
+
if (arrow === Left) {
|
|
1805
|
+
break;
|
|
1806
|
+
}
|
|
1807
|
+
if (arrow === Diagonal) {
|
|
1808
|
+
row--;
|
|
1809
|
+
column--;
|
|
1810
|
+
}
|
|
1811
|
+
}
|
|
1812
|
+
const end = column;
|
|
1813
|
+
matches.unshift(end, start);
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
matches.unshift(table[patternLength][wordLength - 1]);
|
|
1817
|
+
return matches;
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
// based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
|
|
1821
|
+
const gridSize = 128;
|
|
1822
|
+
const table = createTable(gridSize);
|
|
1823
|
+
const arrows = createTable(gridSize);
|
|
1824
|
+
const fuzzySearch = (pattern, word) => {
|
|
1825
|
+
const patternLength = Math.min(pattern.length, gridSize - 1);
|
|
1826
|
+
const wordLength = Math.min(word.length, gridSize - 1);
|
|
1827
|
+
const patternLower = pattern.toLowerCase();
|
|
1828
|
+
const wordLower = word.toLowerCase();
|
|
1829
|
+
if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
|
|
1830
|
+
return EmptyMatches;
|
|
1831
|
+
}
|
|
1832
|
+
let strongMatch = false;
|
|
1833
|
+
for (let row = 1; row < patternLength + 1; row++) {
|
|
1834
|
+
const rowChar = pattern[row - 1];
|
|
1835
|
+
const rowCharLow = patternLower[row - 1];
|
|
1836
|
+
for (let column = 1; column < wordLength + 1; column++) {
|
|
1837
|
+
const columnChar = word[column - 1];
|
|
1838
|
+
const columnCharLow = wordLower[column - 1];
|
|
1839
|
+
const columnCharBefore = word[column - 2] || '';
|
|
1840
|
+
const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
|
|
1841
|
+
const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
|
|
1842
|
+
if (row === 1 && score > 5) {
|
|
1843
|
+
strongMatch = true;
|
|
1844
|
+
}
|
|
1845
|
+
let diagonalScore = score + table[row - 1][column - 1];
|
|
1846
|
+
if (isDiagonalMatch && score !== -1) {
|
|
1847
|
+
diagonalScore += 2;
|
|
1848
|
+
}
|
|
1849
|
+
const leftScore = table[row][column - 1];
|
|
1850
|
+
if (leftScore > diagonalScore) {
|
|
1851
|
+
table[row][column] = leftScore;
|
|
1852
|
+
arrows[row][column] = Left;
|
|
1853
|
+
} else {
|
|
1854
|
+
table[row][column] = diagonalScore;
|
|
1855
|
+
arrows[row][column] = Diagonal;
|
|
1856
|
+
}
|
|
1857
|
+
}
|
|
1858
|
+
}
|
|
1859
|
+
if (!strongMatch) {
|
|
1860
|
+
return EmptyMatches;
|
|
1861
|
+
}
|
|
1862
|
+
const highlights = traceHighlights(table, arrows, patternLength, wordLength);
|
|
1863
|
+
return highlights;
|
|
2160
1864
|
};
|
|
2161
|
-
|
|
2162
|
-
|
|
2163
|
-
const
|
|
2164
|
-
return
|
|
1865
|
+
|
|
1866
|
+
const filterQuickPickItem = (pattern, word) => {
|
|
1867
|
+
const matches = fuzzySearch(pattern, word);
|
|
1868
|
+
return matches;
|
|
2165
1869
|
};
|
|
2166
1870
|
|
|
2167
|
-
const
|
|
2168
|
-
|
|
2169
|
-
// TODO retrieve handle from state or from indexeddb
|
|
2170
|
-
// TODO if not found, throw error
|
|
2171
|
-
const handle = await getHandle$1(uri);
|
|
2172
|
-
return handle;
|
|
2173
|
-
} catch (error) {
|
|
2174
|
-
throw new VError(error, 'Failed to get handle');
|
|
2175
|
-
}
|
|
1871
|
+
const getBaseName = path => {
|
|
1872
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
2176
1873
|
};
|
|
2177
1874
|
|
|
2178
|
-
const
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
return handle;
|
|
2182
|
-
}
|
|
2183
|
-
const dirname$1 = dirname('/', uri);
|
|
2184
|
-
if (uri === dirname$1) {
|
|
2185
|
-
return undefined;
|
|
1875
|
+
const filterQuickPickItems = (items, value) => {
|
|
1876
|
+
if (!value) {
|
|
1877
|
+
return items.map(convertToPick);
|
|
2186
1878
|
}
|
|
2187
|
-
|
|
2188
|
-
|
|
2189
|
-
const
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
}
|
|
2197
|
-
const absolutePath = parent + '/' + childHandle.name;
|
|
2198
|
-
switch (childHandle.kind) {
|
|
2199
|
-
case Directory:
|
|
2200
|
-
promises.push(searchFilesRecursively(all, absolutePath, childHandle));
|
|
2201
|
-
break;
|
|
2202
|
-
case File:
|
|
2203
|
-
all.push(absolutePath);
|
|
2204
|
-
break;
|
|
1879
|
+
const results = [];
|
|
1880
|
+
for (const item of items) {
|
|
1881
|
+
const baseName = getBaseName(item);
|
|
1882
|
+
const matches = filterQuickPickItem(value, baseName);
|
|
1883
|
+
if (matches.length > 0) {
|
|
1884
|
+
results.push({
|
|
1885
|
+
pick: item,
|
|
1886
|
+
matches
|
|
1887
|
+
});
|
|
2205
1888
|
}
|
|
2206
1889
|
}
|
|
2207
|
-
|
|
2208
|
-
};
|
|
2209
|
-
const searchFile$2 = async uri => {
|
|
2210
|
-
const path = uri.slice('html://'.length);
|
|
2211
|
-
const handle = await getDirectoryHandle(path);
|
|
2212
|
-
if (!handle) {
|
|
2213
|
-
// @ts-ignore
|
|
2214
|
-
throw new VError(`Folder not found ${uri}`);
|
|
2215
|
-
}
|
|
2216
|
-
const all = [];
|
|
2217
|
-
await searchFilesRecursively(all, '', handle);
|
|
2218
|
-
return all;
|
|
2219
|
-
};
|
|
2220
|
-
|
|
2221
|
-
const SearchFileHtml = {
|
|
2222
|
-
__proto__: null,
|
|
2223
|
-
searchFile: searchFile$2
|
|
1890
|
+
return results;
|
|
2224
1891
|
};
|
|
2225
1892
|
|
|
2226
1893
|
const getFileSearchRipGrepArgs = () => {
|
|
@@ -2246,7 +1913,7 @@ const searchFile$1 = async (path, value, prepare) => {
|
|
|
2246
1913
|
const options = {
|
|
2247
1914
|
ripGrepArgs,
|
|
2248
1915
|
searchPath: path,
|
|
2249
|
-
limit:
|
|
1916
|
+
limit: 9_999_999
|
|
2250
1917
|
};
|
|
2251
1918
|
const stdout = await invoke('SearchFile.searchFile', options);
|
|
2252
1919
|
const lines = splitLines(stdout);
|
|
@@ -2282,32 +1949,47 @@ const searchFile = async (path, value, prepare, assetDir) => {
|
|
|
2282
1949
|
return result;
|
|
2283
1950
|
};
|
|
2284
1951
|
|
|
2285
|
-
|
|
2286
|
-
const
|
|
1952
|
+
// TODO this should be in FileSystem module
|
|
1953
|
+
const pathBaseName = path => {
|
|
1954
|
+
return path.slice(path.lastIndexOf('/') + 1);
|
|
1955
|
+
};
|
|
1956
|
+
|
|
1957
|
+
// TODO this should be in FileSystem module
|
|
1958
|
+
const pathDirName = path => {
|
|
1959
|
+
const pathSeparator = '/';
|
|
1960
|
+
const index = path.lastIndexOf(pathSeparator);
|
|
1961
|
+
if (index === -1) {
|
|
1962
|
+
return '';
|
|
1963
|
+
}
|
|
1964
|
+
return path.slice(0, index);
|
|
1965
|
+
};
|
|
1966
|
+
|
|
1967
|
+
const name$7 = 'file';
|
|
1968
|
+
const getPlaceholder$a = () => {
|
|
2287
1969
|
return '';
|
|
2288
1970
|
};
|
|
2289
|
-
const getLabel$
|
|
1971
|
+
const getLabel$4 = () => {
|
|
2290
1972
|
return files();
|
|
2291
1973
|
};
|
|
2292
1974
|
|
|
2293
1975
|
// TODO help entries should not be here
|
|
2294
|
-
const getHelpEntries$
|
|
1976
|
+
const getHelpEntries$9 = () => {
|
|
2295
1977
|
return [{
|
|
2296
1978
|
description: goToFile(),
|
|
2297
1979
|
category: 'global commands'
|
|
2298
1980
|
}];
|
|
2299
1981
|
};
|
|
2300
|
-
const getNoResults$
|
|
1982
|
+
const getNoResults$9 = () => {
|
|
2301
1983
|
return {
|
|
2302
1984
|
label: noMatchingResults()
|
|
2303
1985
|
};
|
|
2304
1986
|
};
|
|
2305
|
-
const getPicks$
|
|
1987
|
+
const getPicks$a = async searchValue => {
|
|
2306
1988
|
{
|
|
2307
1989
|
return [];
|
|
2308
1990
|
}
|
|
2309
1991
|
};
|
|
2310
|
-
const selectPick$
|
|
1992
|
+
const selectPick$a = async pick => {
|
|
2311
1993
|
if (typeof pick === 'object') {
|
|
2312
1994
|
pick = pick.pick;
|
|
2313
1995
|
}
|
|
@@ -2318,125 +2000,234 @@ const selectPick$7 = async pick => {
|
|
|
2318
2000
|
command: Hide
|
|
2319
2001
|
};
|
|
2320
2002
|
};
|
|
2003
|
+
const getFilterValue$9 = value => {
|
|
2004
|
+
return value;
|
|
2005
|
+
};
|
|
2006
|
+
const getPickFilterValue$5 = pick => {
|
|
2007
|
+
if (typeof pick === 'object') {
|
|
2008
|
+
pick = pick.pick;
|
|
2009
|
+
}
|
|
2010
|
+
return pick;
|
|
2011
|
+
};
|
|
2012
|
+
const getPickLabel$4 = pick => {
|
|
2013
|
+
if (typeof pick === 'object') {
|
|
2014
|
+
pick = pick.pick;
|
|
2015
|
+
}
|
|
2016
|
+
const baseName = pathBaseName(pick);
|
|
2017
|
+
return baseName;
|
|
2018
|
+
};
|
|
2019
|
+
const getPickDescription$3 = pick => {
|
|
2020
|
+
if (typeof pick === 'object') {
|
|
2021
|
+
pick = pick.pick;
|
|
2022
|
+
}
|
|
2023
|
+
const dirName = pathDirName(pick);
|
|
2024
|
+
return dirName;
|
|
2025
|
+
};
|
|
2026
|
+
const getPickIcon$4 = () => {
|
|
2027
|
+
return '';
|
|
2028
|
+
};
|
|
2029
|
+
const getPickFileIcon$2 = pick => {
|
|
2030
|
+
return '';
|
|
2031
|
+
};
|
|
2032
|
+
const isPrepared$1 = () => {
|
|
2033
|
+
const workspace = '';
|
|
2034
|
+
// TODO protocol should always be defined. For files it should use file protocol
|
|
2035
|
+
const protocol = getProtocol(workspace);
|
|
2036
|
+
return !protocol;
|
|
2037
|
+
};
|
|
2038
|
+
|
|
2039
|
+
const QuickPickEntriesFile = {
|
|
2040
|
+
__proto__: null,
|
|
2041
|
+
getFilterValue: getFilterValue$9,
|
|
2042
|
+
getHelpEntries: getHelpEntries$9,
|
|
2043
|
+
getLabel: getLabel$4,
|
|
2044
|
+
getNoResults: getNoResults$9,
|
|
2045
|
+
getPickDescription: getPickDescription$3,
|
|
2046
|
+
getPickFileIcon: getPickFileIcon$2,
|
|
2047
|
+
getPickFilterValue: getPickFilterValue$5,
|
|
2048
|
+
getPickIcon: getPickIcon$4,
|
|
2049
|
+
getPickLabel: getPickLabel$4,
|
|
2050
|
+
getPicks: getPicks$a,
|
|
2051
|
+
getPlaceholder: getPlaceholder$a,
|
|
2052
|
+
isPrepared: isPrepared$1,
|
|
2053
|
+
name: name$7,
|
|
2054
|
+
selectPick: selectPick$a
|
|
2055
|
+
};
|
|
2056
|
+
|
|
2057
|
+
const name$6 = 'goToLine';
|
|
2058
|
+
const getPlaceholder$9 = () => {
|
|
2059
|
+
return '';
|
|
2060
|
+
};
|
|
2061
|
+
const getHelpEntries$8 = () => {
|
|
2062
|
+
return [];
|
|
2063
|
+
};
|
|
2064
|
+
const getNoResults$8 = () => {
|
|
2065
|
+
return undefined;
|
|
2066
|
+
};
|
|
2067
|
+
const getPicks$9 = async () => {
|
|
2068
|
+
const picks = [{
|
|
2069
|
+
label: '1'
|
|
2070
|
+
}, {
|
|
2071
|
+
label: '2'
|
|
2072
|
+
}, {
|
|
2073
|
+
label: '3'
|
|
2074
|
+
}, {
|
|
2075
|
+
label: '4'
|
|
2076
|
+
}, {
|
|
2077
|
+
label: '5'
|
|
2078
|
+
}, {
|
|
2079
|
+
label: '6'
|
|
2080
|
+
}];
|
|
2081
|
+
return picks;
|
|
2082
|
+
};
|
|
2083
|
+
const selectPick$9 = async item => {
|
|
2084
|
+
const rowIndex = Number.parseInt(item.label);
|
|
2085
|
+
const position = {
|
|
2086
|
+
rowIndex,
|
|
2087
|
+
columnIndex: 5
|
|
2088
|
+
};
|
|
2089
|
+
await execute(/* EditorSetCursor.editorSetCursor */'TODO', /* position */position);
|
|
2090
|
+
// TODO put cursor onto that line
|
|
2091
|
+
return {
|
|
2092
|
+
command: Hide
|
|
2093
|
+
};
|
|
2094
|
+
};
|
|
2095
|
+
const getFilterValue$8 = value => {
|
|
2096
|
+
return value;
|
|
2097
|
+
};
|
|
2098
|
+
|
|
2099
|
+
const QuickPickEntriesGoToLine = {
|
|
2100
|
+
__proto__: null,
|
|
2101
|
+
getFilterValue: getFilterValue$8,
|
|
2102
|
+
getHelpEntries: getHelpEntries$8,
|
|
2103
|
+
getNoResults: getNoResults$8,
|
|
2104
|
+
getPicks: getPicks$9,
|
|
2105
|
+
getPlaceholder: getPlaceholder$9,
|
|
2106
|
+
name: name$6,
|
|
2107
|
+
selectPick: selectPick$9
|
|
2108
|
+
};
|
|
2109
|
+
|
|
2110
|
+
const name$5 = 'noop';
|
|
2111
|
+
const getPlaceholder$8 = () => {
|
|
2112
|
+
return '';
|
|
2113
|
+
};
|
|
2114
|
+
const getHelpEntries$7 = () => {
|
|
2115
|
+
return [];
|
|
2116
|
+
};
|
|
2117
|
+
const getNoResults$7 = () => {
|
|
2118
|
+
return noResults();
|
|
2119
|
+
};
|
|
2120
|
+
const getPicks$8 = async value => {
|
|
2121
|
+
return [];
|
|
2122
|
+
};
|
|
2123
|
+
const selectPick$8 = async item => {
|
|
2124
|
+
return {
|
|
2125
|
+
command: Hide
|
|
2126
|
+
};
|
|
2127
|
+
};
|
|
2128
|
+
const getFilterValue$7 = value => {
|
|
2129
|
+
return value;
|
|
2130
|
+
};
|
|
2131
|
+
const getPickFilterValue$4 = pick => {
|
|
2132
|
+
return pick;
|
|
2133
|
+
};
|
|
2134
|
+
|
|
2135
|
+
const QuickPickNoop = {
|
|
2136
|
+
__proto__: null,
|
|
2137
|
+
getFilterValue: getFilterValue$7,
|
|
2138
|
+
getHelpEntries: getHelpEntries$7,
|
|
2139
|
+
getNoResults: getNoResults$7,
|
|
2140
|
+
getPickFilterValue: getPickFilterValue$4,
|
|
2141
|
+
getPicks: getPicks$8,
|
|
2142
|
+
getPlaceholder: getPlaceholder$8,
|
|
2143
|
+
name: name$5,
|
|
2144
|
+
selectPick: selectPick$8
|
|
2145
|
+
};
|
|
2146
|
+
|
|
2147
|
+
const name$4 = 'symbol';
|
|
2148
|
+
const getPlaceholder$7 = () => {
|
|
2149
|
+
return '';
|
|
2150
|
+
};
|
|
2151
|
+
const getHelpEntries$6 = () => {
|
|
2152
|
+
return [];
|
|
2153
|
+
};
|
|
2154
|
+
const getNoResults$6 = () => {
|
|
2155
|
+
return {
|
|
2156
|
+
label: noSymbolFound()
|
|
2157
|
+
};
|
|
2158
|
+
};
|
|
2159
|
+
const getPicks$7 = async () => {
|
|
2160
|
+
const picks = [];
|
|
2161
|
+
return picks;
|
|
2162
|
+
};
|
|
2163
|
+
const selectPick$7 = async item => {
|
|
2164
|
+
return {
|
|
2165
|
+
command: Hide
|
|
2166
|
+
};
|
|
2167
|
+
};
|
|
2321
2168
|
const getFilterValue$6 = value => {
|
|
2322
2169
|
return value;
|
|
2323
2170
|
};
|
|
2324
|
-
const getPickFilterValue$2 = pick => {
|
|
2325
|
-
if (typeof pick === 'object') {
|
|
2326
|
-
pick = pick.pick;
|
|
2327
|
-
}
|
|
2328
|
-
return pick;
|
|
2329
|
-
};
|
|
2330
|
-
const getPickLabel$1 = pick => {
|
|
2331
|
-
if (typeof pick === 'object') {
|
|
2332
|
-
pick = pick.pick;
|
|
2333
|
-
}
|
|
2334
|
-
const baseName = pathBaseName(pick);
|
|
2335
|
-
return baseName;
|
|
2336
|
-
};
|
|
2337
|
-
const getPickDescription$1 = pick => {
|
|
2338
|
-
if (typeof pick === 'object') {
|
|
2339
|
-
pick = pick.pick;
|
|
2340
|
-
}
|
|
2341
|
-
const dirName = pathDirName(pick);
|
|
2342
|
-
return dirName;
|
|
2343
|
-
};
|
|
2344
|
-
const getPickIcon$1 = () => {
|
|
2345
|
-
return '';
|
|
2346
|
-
};
|
|
2347
|
-
const getPickFileIcon$1 = pick => {
|
|
2348
|
-
return '';
|
|
2349
|
-
};
|
|
2350
|
-
const isPrepared$1 = () => {
|
|
2351
|
-
const workspace = '';
|
|
2352
|
-
// TODO protocol should always be defined. For files it should use file protocol
|
|
2353
|
-
const protocol = getProtocol(workspace);
|
|
2354
|
-
return !protocol;
|
|
2355
|
-
};
|
|
2356
2171
|
|
|
2357
|
-
const
|
|
2172
|
+
const QuickPickEntriesSymbol = {
|
|
2358
2173
|
__proto__: null,
|
|
2359
2174
|
getFilterValue: getFilterValue$6,
|
|
2360
|
-
getHelpEntries: getHelpEntries$
|
|
2361
|
-
getLabel: getLabel$1,
|
|
2175
|
+
getHelpEntries: getHelpEntries$6,
|
|
2362
2176
|
getNoResults: getNoResults$6,
|
|
2363
|
-
getPickDescription: getPickDescription$1,
|
|
2364
|
-
getPickFileIcon: getPickFileIcon$1,
|
|
2365
|
-
getPickFilterValue: getPickFilterValue$2,
|
|
2366
|
-
getPickIcon: getPickIcon$1,
|
|
2367
|
-
getPickLabel: getPickLabel$1,
|
|
2368
2177
|
getPicks: getPicks$7,
|
|
2369
2178
|
getPlaceholder: getPlaceholder$7,
|
|
2370
|
-
|
|
2371
|
-
name: name$6,
|
|
2179
|
+
name: name$4,
|
|
2372
2180
|
selectPick: selectPick$7
|
|
2373
2181
|
};
|
|
2374
2182
|
|
|
2375
|
-
|
|
2183
|
+
// TODO probably not needed
|
|
2184
|
+
|
|
2376
2185
|
const getPlaceholder$6 = () => {
|
|
2377
|
-
return
|
|
2378
|
-
};
|
|
2379
|
-
const getHelpEntries$6 = () => {
|
|
2380
|
-
return [];
|
|
2186
|
+
return typeNameofCommandToRun();
|
|
2381
2187
|
};
|
|
2382
|
-
const
|
|
2188
|
+
const getHelpEntries$5 = () => {
|
|
2383
2189
|
return undefined;
|
|
2384
2190
|
};
|
|
2385
2191
|
const getPicks$6 = async () => {
|
|
2386
|
-
const
|
|
2387
|
-
|
|
2388
|
-
|
|
2389
|
-
|
|
2390
|
-
}, {
|
|
2391
|
-
label: '3'
|
|
2392
|
-
}, {
|
|
2393
|
-
label: '4'
|
|
2394
|
-
}, {
|
|
2395
|
-
label: '5'
|
|
2396
|
-
}, {
|
|
2397
|
-
label: '6'
|
|
2398
|
-
}];
|
|
2399
|
-
return picks;
|
|
2192
|
+
// const views = ViewService.getViews()
|
|
2193
|
+
// const picks = views.map(toPick)
|
|
2194
|
+
// return picks
|
|
2195
|
+
return [];
|
|
2400
2196
|
};
|
|
2401
2197
|
const selectPick$6 = async item => {
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
};
|
|
2407
|
-
await execute(/* EditorSetCursor.editorSetCursor */'TODO', /* position */position);
|
|
2408
|
-
// TODO put cursor onto that line
|
|
2409
|
-
return {
|
|
2410
|
-
command: Hide
|
|
2411
|
-
};
|
|
2198
|
+
// Command.execute(/* openView */ 549, /* viewName */ item.label)
|
|
2199
|
+
// return {
|
|
2200
|
+
// command: QuickPickReturnValue.Hide,
|
|
2201
|
+
// }
|
|
2412
2202
|
};
|
|
2413
2203
|
const getFilterValue$5 = value => {
|
|
2414
2204
|
return value;
|
|
2415
2205
|
};
|
|
2416
2206
|
|
|
2417
|
-
const
|
|
2207
|
+
const QuickPickEntriesView = {
|
|
2418
2208
|
__proto__: null,
|
|
2419
2209
|
getFilterValue: getFilterValue$5,
|
|
2420
|
-
getHelpEntries: getHelpEntries$
|
|
2421
|
-
getNoResults: getNoResults$5,
|
|
2210
|
+
getHelpEntries: getHelpEntries$5,
|
|
2422
2211
|
getPicks: getPicks$6,
|
|
2423
2212
|
getPlaceholder: getPlaceholder$6,
|
|
2424
|
-
name: name$5,
|
|
2425
2213
|
selectPick: selectPick$6
|
|
2426
2214
|
};
|
|
2427
2215
|
|
|
2428
|
-
const name$
|
|
2216
|
+
const name$3 = 'workspace-symbol';
|
|
2429
2217
|
const getPlaceholder$5 = () => {
|
|
2430
2218
|
return '';
|
|
2431
2219
|
};
|
|
2432
|
-
const getHelpEntries$
|
|
2220
|
+
const getHelpEntries$4 = () => {
|
|
2433
2221
|
return [];
|
|
2434
2222
|
};
|
|
2435
|
-
const getNoResults$
|
|
2436
|
-
return
|
|
2223
|
+
const getNoResults$5 = () => {
|
|
2224
|
+
return {
|
|
2225
|
+
label: noWorkspaceSymbolsFound()
|
|
2226
|
+
};
|
|
2437
2227
|
};
|
|
2438
|
-
const getPicks$5 = async
|
|
2439
|
-
|
|
2228
|
+
const getPicks$5 = async () => {
|
|
2229
|
+
const picks = [];
|
|
2230
|
+
return picks;
|
|
2440
2231
|
};
|
|
2441
2232
|
const selectPick$5 = async item => {
|
|
2442
2233
|
return {
|
|
@@ -2446,311 +2237,556 @@ const selectPick$5 = async item => {
|
|
|
2446
2237
|
const getFilterValue$4 = value => {
|
|
2447
2238
|
return value;
|
|
2448
2239
|
};
|
|
2449
|
-
const getPickFilterValue$1 = pick => {
|
|
2450
|
-
return pick;
|
|
2451
|
-
};
|
|
2452
2240
|
|
|
2453
|
-
const
|
|
2241
|
+
const QuickPickEntriesWorkspaceSymbol = {
|
|
2454
2242
|
__proto__: null,
|
|
2455
2243
|
getFilterValue: getFilterValue$4,
|
|
2456
|
-
getHelpEntries: getHelpEntries$
|
|
2457
|
-
getNoResults: getNoResults$
|
|
2458
|
-
getPickFilterValue: getPickFilterValue$1,
|
|
2244
|
+
getHelpEntries: getHelpEntries$4,
|
|
2245
|
+
getNoResults: getNoResults$5,
|
|
2459
2246
|
getPicks: getPicks$5,
|
|
2460
2247
|
getPlaceholder: getPlaceholder$5,
|
|
2461
|
-
name: name$
|
|
2248
|
+
name: name$3,
|
|
2462
2249
|
selectPick: selectPick$5
|
|
2463
2250
|
};
|
|
2464
2251
|
|
|
2465
|
-
const
|
|
2252
|
+
const Command = '>';
|
|
2253
|
+
const Symbol$2 = '@';
|
|
2254
|
+
const WorkspaceSymbol$1 = '#';
|
|
2255
|
+
const GoToLine = ':';
|
|
2256
|
+
const View$1 = 'view ';
|
|
2257
|
+
const None$1 = '';
|
|
2258
|
+
|
|
2259
|
+
// TODO avoid global variable
|
|
2260
|
+
|
|
2261
|
+
const state$1 = {
|
|
2262
|
+
// providerId: PROVIDER_NOOP,
|
|
2263
|
+
provider: QuickPickNoop,
|
|
2264
|
+
prefix: 'string-that-should-never-match-another-string'
|
|
2265
|
+
};
|
|
2266
|
+
|
|
2267
|
+
/**
|
|
2268
|
+
* @type {string}
|
|
2269
|
+
*/
|
|
2270
|
+
const name$2 = 'everything';
|
|
2466
2271
|
const getPlaceholder$4 = () => {
|
|
2272
|
+
return state$1.provider.getPlaceholder();
|
|
2273
|
+
};
|
|
2274
|
+
const getLabel$3 = () => {
|
|
2467
2275
|
return '';
|
|
2468
2276
|
};
|
|
2469
|
-
const getHelpEntries$
|
|
2470
|
-
return
|
|
2277
|
+
const getHelpEntries$3 = () => {
|
|
2278
|
+
return state$1.provider.getHelpEntries();
|
|
2279
|
+
};
|
|
2280
|
+
const getNoResults$4 = () => {
|
|
2281
|
+
return state$1.provider.getNoResults();
|
|
2282
|
+
};
|
|
2283
|
+
const getPrefix = value => {
|
|
2284
|
+
if (value.startsWith(Command)) {
|
|
2285
|
+
return Command;
|
|
2286
|
+
}
|
|
2287
|
+
if (value.startsWith(Symbol$2)) {
|
|
2288
|
+
return Symbol$2;
|
|
2289
|
+
}
|
|
2290
|
+
if (value.startsWith(WorkspaceSymbol$1)) {
|
|
2291
|
+
return WorkspaceSymbol$1;
|
|
2292
|
+
}
|
|
2293
|
+
if (value.startsWith(GoToLine)) {
|
|
2294
|
+
return GoToLine;
|
|
2295
|
+
}
|
|
2296
|
+
if (value.startsWith(View$1)) {
|
|
2297
|
+
return View$1;
|
|
2298
|
+
}
|
|
2299
|
+
return None$1;
|
|
2300
|
+
};
|
|
2301
|
+
const getQuickPickProvider = prefix => {
|
|
2302
|
+
// TODO could use enum for prefix
|
|
2303
|
+
// TODO could use regex to extract prefix
|
|
2304
|
+
// TODO or could check first letter char code (less comparisons)
|
|
2305
|
+
switch (prefix) {
|
|
2306
|
+
case Command:
|
|
2307
|
+
return QuickPickEntriesCommand;
|
|
2308
|
+
case Symbol$2:
|
|
2309
|
+
return QuickPickEntriesSymbol;
|
|
2310
|
+
case WorkspaceSymbol$1:
|
|
2311
|
+
return QuickPickEntriesWorkspaceSymbol;
|
|
2312
|
+
case GoToLine:
|
|
2313
|
+
return QuickPickEntriesGoToLine;
|
|
2314
|
+
case View$1:
|
|
2315
|
+
return QuickPickEntriesView;
|
|
2316
|
+
default:
|
|
2317
|
+
return QuickPickEntriesFile;
|
|
2318
|
+
}
|
|
2319
|
+
};
|
|
2320
|
+
const getPicks$4 = async value => {
|
|
2321
|
+
const prefix = getPrefix(value);
|
|
2322
|
+
// TODO race condition
|
|
2323
|
+
if (state$1.prefix !== prefix) {
|
|
2324
|
+
state$1.prefix = prefix;
|
|
2325
|
+
// @ts-ignore
|
|
2326
|
+
state$1.provider = await getQuickPickProvider(prefix);
|
|
2327
|
+
}
|
|
2328
|
+
// TODO this line is a bit duplicated with getFilterValue
|
|
2329
|
+
const slicedValue = value.slice(prefix.length);
|
|
2330
|
+
const picks = await state$1.provider.getPicks(slicedValue);
|
|
2331
|
+
return picks;
|
|
2332
|
+
};
|
|
2333
|
+
const selectPick$4 = item => {
|
|
2334
|
+
const {
|
|
2335
|
+
provider
|
|
2336
|
+
} = state$1;
|
|
2337
|
+
return provider.selectPick(item);
|
|
2338
|
+
};
|
|
2339
|
+
const openCommandPalette = () => {
|
|
2340
|
+
// show('>')
|
|
2341
|
+
};
|
|
2342
|
+
const openView = () => {
|
|
2343
|
+
// show('view ')
|
|
2344
|
+
};
|
|
2345
|
+
const getFilterValue$3 = value => {
|
|
2346
|
+
return value.slice(state$1.prefix.length);
|
|
2347
|
+
};
|
|
2348
|
+
const getPickFilterValue$3 = pick => {
|
|
2349
|
+
const {
|
|
2350
|
+
provider
|
|
2351
|
+
} = state$1;
|
|
2352
|
+
return provider.getPickFilterValue(pick);
|
|
2353
|
+
};
|
|
2354
|
+
const getPickDescription$2 = pick => {
|
|
2355
|
+
const {
|
|
2356
|
+
provider
|
|
2357
|
+
} = state$1;
|
|
2358
|
+
// @ts-ignore
|
|
2359
|
+
if (provider.getPickDescription) {
|
|
2360
|
+
// @ts-ignore
|
|
2361
|
+
return provider.getPickDescription(pick);
|
|
2362
|
+
}
|
|
2363
|
+
return '';
|
|
2364
|
+
};
|
|
2365
|
+
const getPickLabel$3 = pick => {
|
|
2366
|
+
const {
|
|
2367
|
+
provider
|
|
2368
|
+
} = state$1;
|
|
2369
|
+
// @ts-ignore
|
|
2370
|
+
return provider.getPickLabel(pick);
|
|
2371
|
+
};
|
|
2372
|
+
const getPickIcon$3 = pick => {
|
|
2373
|
+
const {
|
|
2374
|
+
provider
|
|
2375
|
+
} = state$1;
|
|
2376
|
+
// @ts-ignore
|
|
2377
|
+
return provider.getPickIcon(pick);
|
|
2378
|
+
};
|
|
2379
|
+
const getPickFileIcon$1 = pick => {
|
|
2380
|
+
const {
|
|
2381
|
+
provider
|
|
2382
|
+
} = state$1;
|
|
2383
|
+
// @ts-ignore
|
|
2384
|
+
if (provider.getPickFileIcon) {
|
|
2385
|
+
// @ts-ignore
|
|
2386
|
+
return provider.getPickFileIcon(pick);
|
|
2387
|
+
}
|
|
2388
|
+
return '';
|
|
2389
|
+
};
|
|
2390
|
+
const isPrepared = () => {
|
|
2391
|
+
const {
|
|
2392
|
+
provider
|
|
2393
|
+
} = state$1;
|
|
2394
|
+
// @ts-ignore
|
|
2395
|
+
if (provider.isPrepared) {
|
|
2396
|
+
// @ts-ignore
|
|
2397
|
+
return provider.isPrepared();
|
|
2398
|
+
}
|
|
2399
|
+
return false;
|
|
2400
|
+
};
|
|
2401
|
+
|
|
2402
|
+
const QuickPickEntriesEverything = {
|
|
2403
|
+
__proto__: null,
|
|
2404
|
+
getFilterValue: getFilterValue$3,
|
|
2405
|
+
getHelpEntries: getHelpEntries$3,
|
|
2406
|
+
getLabel: getLabel$3,
|
|
2407
|
+
getNoResults: getNoResults$4,
|
|
2408
|
+
getPickDescription: getPickDescription$2,
|
|
2409
|
+
getPickFileIcon: getPickFileIcon$1,
|
|
2410
|
+
getPickFilterValue: getPickFilterValue$3,
|
|
2411
|
+
getPickIcon: getPickIcon$3,
|
|
2412
|
+
getPickLabel: getPickLabel$3,
|
|
2413
|
+
getPicks: getPicks$4,
|
|
2414
|
+
getPlaceholder: getPlaceholder$4,
|
|
2415
|
+
isPrepared,
|
|
2416
|
+
name: name$2,
|
|
2417
|
+
openCommandPalette,
|
|
2418
|
+
openView,
|
|
2419
|
+
selectPick: selectPick$4,
|
|
2420
|
+
state: state$1
|
|
2471
2421
|
};
|
|
2472
|
-
|
|
2422
|
+
|
|
2423
|
+
const Default = 0;
|
|
2424
|
+
const Finished = 2;
|
|
2425
|
+
|
|
2426
|
+
const create$2 = () => {
|
|
2427
|
+
const states = Object.create(null);
|
|
2473
2428
|
return {
|
|
2474
|
-
|
|
2429
|
+
get(uid) {
|
|
2430
|
+
return states[uid];
|
|
2431
|
+
},
|
|
2432
|
+
set(uid, oldState, newState) {
|
|
2433
|
+
states[uid] = {
|
|
2434
|
+
oldState,
|
|
2435
|
+
newState
|
|
2436
|
+
};
|
|
2437
|
+
}
|
|
2475
2438
|
};
|
|
2476
2439
|
};
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2440
|
+
|
|
2441
|
+
const {
|
|
2442
|
+
get,
|
|
2443
|
+
set
|
|
2444
|
+
} = create$2();
|
|
2445
|
+
|
|
2446
|
+
const create$1 = ({
|
|
2447
|
+
itemHeight,
|
|
2448
|
+
headerHeight = 0,
|
|
2449
|
+
minimumSliderSize = 20
|
|
2450
|
+
}) => {
|
|
2482
2451
|
return {
|
|
2483
|
-
|
|
2452
|
+
deltaY: 0,
|
|
2453
|
+
minLineY: 0,
|
|
2454
|
+
maxLineY: 0,
|
|
2455
|
+
finalDeltaY: 0,
|
|
2456
|
+
itemHeight,
|
|
2457
|
+
headerHeight,
|
|
2458
|
+
items: [],
|
|
2459
|
+
minimumSliderSize,
|
|
2460
|
+
focusedIndex: -1,
|
|
2461
|
+
touchOffsetY: 0,
|
|
2462
|
+
touchTimeStamp: 0,
|
|
2463
|
+
touchDifference: 0,
|
|
2464
|
+
scrollBarHeight: 0,
|
|
2465
|
+
scrollBarActive: false
|
|
2484
2466
|
};
|
|
2485
2467
|
};
|
|
2486
|
-
|
|
2487
|
-
|
|
2468
|
+
|
|
2469
|
+
const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
|
|
2470
|
+
const state = {
|
|
2471
|
+
uid,
|
|
2472
|
+
state: Default,
|
|
2473
|
+
picks: [],
|
|
2474
|
+
recentPicks: [],
|
|
2475
|
+
recentPickIds: new Map(),
|
|
2476
|
+
// TODO use object.create(null) instead
|
|
2477
|
+
versionId: 0,
|
|
2478
|
+
provider: QuickPickEntriesEverything,
|
|
2479
|
+
// TODO make this dynamic again
|
|
2480
|
+
warned: [],
|
|
2481
|
+
visiblePicks: [],
|
|
2482
|
+
maxVisibleItems: 10,
|
|
2483
|
+
uri,
|
|
2484
|
+
cursorOffset: 0,
|
|
2485
|
+
height: 300,
|
|
2486
|
+
top: 50,
|
|
2487
|
+
width: 600,
|
|
2488
|
+
...create$1({
|
|
2489
|
+
itemHeight: listItemHeight,
|
|
2490
|
+
headerHeight: 30,
|
|
2491
|
+
minimumSliderSize: minimumSliderSize
|
|
2492
|
+
}),
|
|
2493
|
+
inputSource: User,
|
|
2494
|
+
args,
|
|
2495
|
+
focused: false,
|
|
2496
|
+
platform,
|
|
2497
|
+
value: ''
|
|
2498
|
+
};
|
|
2499
|
+
set(uid, state, state);
|
|
2500
|
+
return state;
|
|
2488
2501
|
};
|
|
2489
2502
|
|
|
2490
|
-
const
|
|
2491
|
-
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2495
|
-
|
|
2496
|
-
|
|
2497
|
-
|
|
2498
|
-
|
|
2503
|
+
const getBlob$1 = async url => {
|
|
2504
|
+
try {
|
|
2505
|
+
const response = await fetch(url);
|
|
2506
|
+
if (!response.ok) {
|
|
2507
|
+
throw new Error(response.statusText);
|
|
2508
|
+
}
|
|
2509
|
+
const text = await response.blob();
|
|
2510
|
+
return text;
|
|
2511
|
+
} catch (error) {
|
|
2512
|
+
throw new VError(error, `Failed to request blob for ${url}`);
|
|
2513
|
+
}
|
|
2499
2514
|
};
|
|
2500
2515
|
|
|
2501
|
-
|
|
2516
|
+
const getText = async url => {
|
|
2517
|
+
try {
|
|
2518
|
+
const response = await fetch(url);
|
|
2519
|
+
if (!response.ok) {
|
|
2520
|
+
throw new Error(response.statusText);
|
|
2521
|
+
}
|
|
2522
|
+
const text = await response.text();
|
|
2523
|
+
return text;
|
|
2524
|
+
} catch (error) {
|
|
2525
|
+
throw new VError(error, `Failed to request text for ${url}`);
|
|
2526
|
+
}
|
|
2527
|
+
};
|
|
2502
2528
|
|
|
2503
|
-
|
|
2504
|
-
|
|
2529
|
+
// TODO move all of this to an extension
|
|
2530
|
+
|
|
2531
|
+
const readFile = async uri => {
|
|
2532
|
+
const fetchUri = `${assetDir}${uri}`;
|
|
2533
|
+
const text = await getText(fetchUri);
|
|
2534
|
+
return text;
|
|
2505
2535
|
};
|
|
2506
|
-
const
|
|
2507
|
-
|
|
2536
|
+
const writeFile = () => {
|
|
2537
|
+
throw new Error('not implemented');
|
|
2508
2538
|
};
|
|
2509
|
-
const
|
|
2510
|
-
|
|
2511
|
-
// const picks = views.map(toPick)
|
|
2512
|
-
// return picks
|
|
2513
|
-
return [];
|
|
2539
|
+
const mkdir = () => {
|
|
2540
|
+
throw new Error('not implemented');
|
|
2514
2541
|
};
|
|
2515
|
-
const
|
|
2516
|
-
|
|
2517
|
-
// return {
|
|
2518
|
-
// command: QuickPickReturnValue.Hide,
|
|
2519
|
-
// }
|
|
2542
|
+
const remove = () => {
|
|
2543
|
+
throw new Error('not implemented');
|
|
2520
2544
|
};
|
|
2521
|
-
const
|
|
2522
|
-
|
|
2545
|
+
const readDirWithFileTypes = async uri => {
|
|
2546
|
+
const fileList = await getJson(fileMapUrl);
|
|
2547
|
+
const dirents = [];
|
|
2548
|
+
for (const fileUri of fileList) {
|
|
2549
|
+
if (fileUri.startsWith(uri)) {
|
|
2550
|
+
const rest = fileUri.slice(uri.length + 1);
|
|
2551
|
+
if (rest.includes(Slash)) {
|
|
2552
|
+
const name = rest.slice(0, rest.indexOf(Slash));
|
|
2553
|
+
if (dirents.some(dirent => dirent.name === name)) {
|
|
2554
|
+
continue;
|
|
2555
|
+
}
|
|
2556
|
+
dirents.push({
|
|
2557
|
+
type: Directory$1,
|
|
2558
|
+
name
|
|
2559
|
+
});
|
|
2560
|
+
} else {
|
|
2561
|
+
dirents.push({
|
|
2562
|
+
type: File$2,
|
|
2563
|
+
name: rest
|
|
2564
|
+
});
|
|
2565
|
+
}
|
|
2566
|
+
}
|
|
2567
|
+
}
|
|
2568
|
+
return dirents;
|
|
2569
|
+
};
|
|
2570
|
+
const chmod = () => {
|
|
2571
|
+
throw new Error('[memfs] chmod not implemented');
|
|
2572
|
+
};
|
|
2573
|
+
const getBlob = async (uri, type) => {
|
|
2574
|
+
const fetchUri = `${assetDir}${uri}`;
|
|
2575
|
+
const blob = getBlob$1(fetchUri);
|
|
2576
|
+
return blob;
|
|
2523
2577
|
};
|
|
2524
2578
|
|
|
2525
|
-
const
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2579
|
+
const Enter = 3;
|
|
2580
|
+
const Escape = 8;
|
|
2581
|
+
const PageUp = 10;
|
|
2582
|
+
const PageDown = 11;
|
|
2583
|
+
const UpArrow = 14;
|
|
2584
|
+
const DownArrow = 16;
|
|
2585
|
+
|
|
2586
|
+
const FocusQuickPickInput = 20;
|
|
2587
|
+
|
|
2588
|
+
const getKeyBindings = () => {
|
|
2589
|
+
return [{
|
|
2590
|
+
key: Escape,
|
|
2591
|
+
command: 'Viewlet.closeWidget',
|
|
2592
|
+
args: ['QuickPick'],
|
|
2593
|
+
when: FocusQuickPickInput
|
|
2594
|
+
}, {
|
|
2595
|
+
key: UpArrow,
|
|
2596
|
+
command: 'QuickPick.focusPrevious',
|
|
2597
|
+
when: FocusQuickPickInput
|
|
2598
|
+
}, {
|
|
2599
|
+
key: DownArrow,
|
|
2600
|
+
command: 'QuickPick.focusNext',
|
|
2601
|
+
when: FocusQuickPickInput
|
|
2602
|
+
}, {
|
|
2603
|
+
key: PageUp,
|
|
2604
|
+
command: 'QuickPick.focusFirst',
|
|
2605
|
+
when: FocusQuickPickInput
|
|
2606
|
+
}, {
|
|
2607
|
+
key: PageDown,
|
|
2608
|
+
command: 'QuickPick.focusLast',
|
|
2609
|
+
when: FocusQuickPickInput
|
|
2610
|
+
}, {
|
|
2611
|
+
key: Enter,
|
|
2612
|
+
command: 'QuickPick.selectCurrentIndex',
|
|
2613
|
+
when: FocusQuickPickInput
|
|
2614
|
+
}];
|
|
2532
2615
|
};
|
|
2533
2616
|
|
|
2534
|
-
const
|
|
2535
|
-
|
|
2536
|
-
|
|
2617
|
+
const getDefaultValue = uri => {
|
|
2618
|
+
switch (uri) {
|
|
2619
|
+
case 'quickPick://everything':
|
|
2620
|
+
return '>';
|
|
2621
|
+
default:
|
|
2622
|
+
return '';
|
|
2623
|
+
}
|
|
2537
2624
|
};
|
|
2538
|
-
|
|
2539
|
-
|
|
2625
|
+
|
|
2626
|
+
const getColorThemeNames = async () => {
|
|
2627
|
+
return invoke$1(/* Ajax.getJson */'ColorTheme.getColorThemeNames');
|
|
2540
2628
|
};
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
};
|
|
2629
|
+
|
|
2630
|
+
const setColorTheme = id => {
|
|
2631
|
+
return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
|
|
2545
2632
|
};
|
|
2546
|
-
const
|
|
2547
|
-
|
|
2548
|
-
|
|
2633
|
+
const getPlaceholder$3 = () => {
|
|
2634
|
+
return selectColorTheme();
|
|
2635
|
+
};
|
|
2636
|
+
const getLabel$2 = () => {
|
|
2637
|
+
return selectColorTheme();
|
|
2638
|
+
};
|
|
2639
|
+
const getPicks$3 = async searchValue => {
|
|
2640
|
+
const colorThemeNames = await getColorThemeNames();
|
|
2641
|
+
return colorThemeNames;
|
|
2549
2642
|
};
|
|
2550
|
-
const selectPick$
|
|
2643
|
+
const selectPick$3 = async pick => {
|
|
2644
|
+
await setColorTheme(/* colorThemeId */pick);
|
|
2551
2645
|
return {
|
|
2552
2646
|
command: Hide
|
|
2553
2647
|
};
|
|
2554
2648
|
};
|
|
2555
|
-
const
|
|
2649
|
+
const focusPick = async pick => {
|
|
2650
|
+
await setColorTheme(/* colorThemeId */pick);
|
|
2651
|
+
};
|
|
2652
|
+
const getFilterValue$2 = value => {
|
|
2556
2653
|
return value;
|
|
2557
2654
|
};
|
|
2558
|
-
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
getHelpEntries: getHelpEntries$2,
|
|
2563
|
-
getNoResults: getNoResults$2,
|
|
2564
|
-
getPicks: getPicks$2,
|
|
2565
|
-
getPlaceholder: getPlaceholder$2,
|
|
2566
|
-
name: name$2,
|
|
2567
|
-
selectPick: selectPick$2
|
|
2655
|
+
const getNoResults$3 = () => {
|
|
2656
|
+
return {
|
|
2657
|
+
label: noMatchingColorThemesFound()
|
|
2658
|
+
};
|
|
2568
2659
|
};
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
const Symbol$1 = '@';
|
|
2572
|
-
const WorkspaceSymbol = '#';
|
|
2573
|
-
const GoToLine = ':';
|
|
2574
|
-
const View = 'view ';
|
|
2575
|
-
const None = '';
|
|
2576
|
-
|
|
2577
|
-
// TODO avoid global variable
|
|
2578
|
-
|
|
2579
|
-
const state = {
|
|
2580
|
-
// providerId: PROVIDER_NOOP,
|
|
2581
|
-
provider: QuickPickNoop,
|
|
2582
|
-
prefix: 'string-that-should-never-match-another-string'
|
|
2660
|
+
const getPickFilterValue$2 = pick => {
|
|
2661
|
+
return pick;
|
|
2583
2662
|
};
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
* @type {string}
|
|
2587
|
-
*/
|
|
2588
|
-
const name$1 = 'everything';
|
|
2589
|
-
const getPlaceholder$1 = () => {
|
|
2590
|
-
return state.provider.getPlaceholder();
|
|
2663
|
+
const getPickLabel$2 = pick => {
|
|
2664
|
+
return pick;
|
|
2591
2665
|
};
|
|
2592
|
-
const
|
|
2666
|
+
const getPickIcon$2 = pick => {
|
|
2593
2667
|
return '';
|
|
2594
2668
|
};
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
2600
|
-
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
|
|
2607
|
-
|
|
2608
|
-
|
|
2609
|
-
return WorkspaceSymbol;
|
|
2610
|
-
}
|
|
2611
|
-
if (value.startsWith(GoToLine)) {
|
|
2612
|
-
return GoToLine;
|
|
2613
|
-
}
|
|
2614
|
-
if (value.startsWith(View)) {
|
|
2615
|
-
return View;
|
|
2616
|
-
}
|
|
2617
|
-
return None;
|
|
2618
|
-
};
|
|
2619
|
-
const getQuickPickProvider = prefix => {
|
|
2620
|
-
// TODO could use enum for prefix
|
|
2621
|
-
// TODO could use regex to extract prefix
|
|
2622
|
-
// TODO or could check first letter char code (less comparisons)
|
|
2623
|
-
switch (prefix) {
|
|
2624
|
-
case Command:
|
|
2625
|
-
return QuickPickEntriesCommand;
|
|
2626
|
-
case Symbol$1:
|
|
2627
|
-
return QuickPickEntriesSymbol;
|
|
2628
|
-
case WorkspaceSymbol:
|
|
2629
|
-
return QuickPickEntriesWorkspaceSymbol;
|
|
2630
|
-
case GoToLine:
|
|
2631
|
-
return QuickPickEntriesGoToLine;
|
|
2632
|
-
case View:
|
|
2633
|
-
return QuickPickEntriesView;
|
|
2634
|
-
default:
|
|
2635
|
-
return QuickPickEntriesFile;
|
|
2636
|
-
}
|
|
2669
|
+
|
|
2670
|
+
const QuickPickEntriesColorTheme = {
|
|
2671
|
+
__proto__: null,
|
|
2672
|
+
focusPick,
|
|
2673
|
+
getFilterValue: getFilterValue$2,
|
|
2674
|
+
getLabel: getLabel$2,
|
|
2675
|
+
getNoResults: getNoResults$3,
|
|
2676
|
+
getPickFilterValue: getPickFilterValue$2,
|
|
2677
|
+
getPickIcon: getPickIcon$2,
|
|
2678
|
+
getPickLabel: getPickLabel$2,
|
|
2679
|
+
getPicks: getPicks$3,
|
|
2680
|
+
getPlaceholder: getPlaceholder$3,
|
|
2681
|
+
selectPick: selectPick$3,
|
|
2682
|
+
setColorTheme
|
|
2637
2683
|
};
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
|
|
2648
|
-
|
|
2649
|
-
|
|
2684
|
+
|
|
2685
|
+
const Tag$1 = 'Tag';
|
|
2686
|
+
const Cloud$1 = 'Cloud';
|
|
2687
|
+
const SourceControl$1 = 'SourceControl';
|
|
2688
|
+
const None = '';
|
|
2689
|
+
|
|
2690
|
+
const SourceControl = 1;
|
|
2691
|
+
const Cloud = 2;
|
|
2692
|
+
const Tag = 3;
|
|
2693
|
+
|
|
2694
|
+
const name$1 = 'custom';
|
|
2695
|
+
const state = {
|
|
2696
|
+
args: []
|
|
2650
2697
|
};
|
|
2651
|
-
const
|
|
2652
|
-
|
|
2653
|
-
provider
|
|
2654
|
-
} = state;
|
|
2655
|
-
return provider.selectPick(item);
|
|
2698
|
+
const setArgs = args => {
|
|
2699
|
+
state.args = args;
|
|
2656
2700
|
};
|
|
2657
|
-
const
|
|
2658
|
-
|
|
2701
|
+
const getPlaceholder$2 = () => {
|
|
2702
|
+
return '';
|
|
2659
2703
|
};
|
|
2660
|
-
const
|
|
2661
|
-
|
|
2704
|
+
const getLabel$1 = () => {
|
|
2705
|
+
return 'Custom';
|
|
2662
2706
|
};
|
|
2663
|
-
|
|
2664
|
-
|
|
2707
|
+
|
|
2708
|
+
// TODO help entries should not be here
|
|
2709
|
+
const getHelpEntries$2 = () => {
|
|
2710
|
+
return [];
|
|
2665
2711
|
};
|
|
2666
|
-
const
|
|
2667
|
-
|
|
2668
|
-
|
|
2669
|
-
}
|
|
2670
|
-
return provider.getPickFilterValue(pick);
|
|
2712
|
+
const getNoResults$2 = () => {
|
|
2713
|
+
return {
|
|
2714
|
+
label: noMatchingResults()
|
|
2715
|
+
};
|
|
2671
2716
|
};
|
|
2672
|
-
const
|
|
2673
|
-
const
|
|
2674
|
-
|
|
2675
|
-
} = state;
|
|
2676
|
-
// @ts-ignore
|
|
2677
|
-
if (provider.getPickDescription) {
|
|
2678
|
-
// @ts-ignore
|
|
2679
|
-
return provider.getPickDescription(pick);
|
|
2680
|
-
}
|
|
2681
|
-
return '';
|
|
2717
|
+
const getPicks$2 = async searchValue => {
|
|
2718
|
+
const items = state.args[1] || [];
|
|
2719
|
+
return items;
|
|
2682
2720
|
};
|
|
2683
|
-
const
|
|
2721
|
+
const selectPick$2 = async pick => {
|
|
2684
2722
|
const {
|
|
2685
|
-
|
|
2723
|
+
args
|
|
2686
2724
|
} = state;
|
|
2687
|
-
|
|
2688
|
-
|
|
2725
|
+
const resolve = args[2];
|
|
2726
|
+
resolve(pick);
|
|
2727
|
+
return {
|
|
2728
|
+
command: Hide
|
|
2729
|
+
};
|
|
2689
2730
|
};
|
|
2690
|
-
const
|
|
2691
|
-
|
|
2692
|
-
provider
|
|
2693
|
-
} = state;
|
|
2694
|
-
// @ts-ignore
|
|
2695
|
-
return provider.getPickIcon(pick);
|
|
2731
|
+
const getFilterValue$1 = value => {
|
|
2732
|
+
return value;
|
|
2696
2733
|
};
|
|
2697
|
-
const
|
|
2698
|
-
|
|
2699
|
-
provider
|
|
2700
|
-
} = state;
|
|
2701
|
-
// @ts-ignore
|
|
2702
|
-
if (provider.getPickFileIcon) {
|
|
2703
|
-
// @ts-ignore
|
|
2704
|
-
return provider.getPickFileIcon(pick);
|
|
2705
|
-
}
|
|
2706
|
-
return '';
|
|
2734
|
+
const getPickFilterValue$1 = pick => {
|
|
2735
|
+
return pick;
|
|
2707
2736
|
};
|
|
2708
|
-
const
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
|
|
2713
|
-
|
|
2714
|
-
|
|
2715
|
-
|
|
2737
|
+
const getPickLabel$1 = pick => {
|
|
2738
|
+
return pick.label;
|
|
2739
|
+
};
|
|
2740
|
+
const getPickDescription$1 = pick => {
|
|
2741
|
+
return pick.description || '';
|
|
2742
|
+
};
|
|
2743
|
+
const convertIcon = icon => {
|
|
2744
|
+
switch (icon) {
|
|
2745
|
+
case SourceControl:
|
|
2746
|
+
return SourceControl$1;
|
|
2747
|
+
case Cloud:
|
|
2748
|
+
return Cloud$1;
|
|
2749
|
+
case Tag:
|
|
2750
|
+
return Tag$1;
|
|
2751
|
+
default:
|
|
2752
|
+
return None;
|
|
2716
2753
|
}
|
|
2717
|
-
|
|
2754
|
+
};
|
|
2755
|
+
const getPickIcon$1 = pick => {
|
|
2756
|
+
return convertIcon(pick.icon);
|
|
2718
2757
|
};
|
|
2719
2758
|
|
|
2720
|
-
const
|
|
2759
|
+
const QuickPickEntriesCustom = {
|
|
2721
2760
|
__proto__: null,
|
|
2722
|
-
getFilterValue,
|
|
2723
|
-
getHelpEntries: getHelpEntries$
|
|
2724
|
-
getLabel,
|
|
2725
|
-
getNoResults: getNoResults$
|
|
2726
|
-
getPickDescription,
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
getPlaceholder: getPlaceholder$1,
|
|
2733
|
-
isPrepared,
|
|
2761
|
+
getFilterValue: getFilterValue$1,
|
|
2762
|
+
getHelpEntries: getHelpEntries$2,
|
|
2763
|
+
getLabel: getLabel$1,
|
|
2764
|
+
getNoResults: getNoResults$2,
|
|
2765
|
+
getPickDescription: getPickDescription$1,
|
|
2766
|
+
getPickFilterValue: getPickFilterValue$1,
|
|
2767
|
+
getPickIcon: getPickIcon$1,
|
|
2768
|
+
getPickLabel: getPickLabel$1,
|
|
2769
|
+
getPicks: getPicks$2,
|
|
2770
|
+
getPlaceholder: getPlaceholder$2,
|
|
2734
2771
|
name: name$1,
|
|
2735
|
-
|
|
2736
|
-
|
|
2737
|
-
selectPick: selectPick$1,
|
|
2772
|
+
selectPick: selectPick$2,
|
|
2773
|
+
setArgs,
|
|
2738
2774
|
state
|
|
2739
2775
|
};
|
|
2740
2776
|
|
|
2741
2777
|
const name = 'number';
|
|
2742
|
-
const getPlaceholder = () => {
|
|
2778
|
+
const getPlaceholder$1 = () => {
|
|
2743
2779
|
return '';
|
|
2744
2780
|
};
|
|
2745
|
-
const getHelpEntries = () => {
|
|
2781
|
+
const getHelpEntries$1 = () => {
|
|
2746
2782
|
return [];
|
|
2747
2783
|
};
|
|
2748
|
-
const getNoResults = () => {
|
|
2784
|
+
const getNoResults$1 = () => {
|
|
2749
2785
|
return {
|
|
2750
2786
|
label: noMatchingResults()
|
|
2751
2787
|
};
|
|
2752
2788
|
};
|
|
2753
|
-
const getPicks = async () => {
|
|
2789
|
+
const getPicks$1 = async () => {
|
|
2754
2790
|
const picks = [{
|
|
2755
2791
|
label: '1'
|
|
2756
2792
|
}, {
|
|
@@ -2774,7 +2810,7 @@ const getPicks = async () => {
|
|
|
2774
2810
|
}];
|
|
2775
2811
|
return picks;
|
|
2776
2812
|
};
|
|
2777
|
-
const selectPick = async item => {
|
|
2813
|
+
const selectPick$1 = async item => {
|
|
2778
2814
|
return {
|
|
2779
2815
|
command: Hide
|
|
2780
2816
|
};
|
|
@@ -2782,20 +2818,110 @@ const selectPick = async item => {
|
|
|
2782
2818
|
|
|
2783
2819
|
const QuickPickEntriesNumber = {
|
|
2784
2820
|
__proto__: null,
|
|
2821
|
+
getHelpEntries: getHelpEntries$1,
|
|
2822
|
+
getNoResults: getNoResults$1,
|
|
2823
|
+
getPicks: getPicks$1,
|
|
2824
|
+
getPlaceholder: getPlaceholder$1,
|
|
2825
|
+
name,
|
|
2826
|
+
selectPick: selectPick$1
|
|
2827
|
+
};
|
|
2828
|
+
|
|
2829
|
+
// TODO support file icons
|
|
2830
|
+
const getFolderIcon = () => {
|
|
2831
|
+
return '';
|
|
2832
|
+
};
|
|
2833
|
+
|
|
2834
|
+
const getRecentlyOpened = () => {
|
|
2835
|
+
return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
|
|
2836
|
+
};
|
|
2837
|
+
const openWorkspaceFolder = uri => {
|
|
2838
|
+
return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
|
|
2839
|
+
};
|
|
2840
|
+
const getPlaceholder = () => {
|
|
2841
|
+
return selectToOpen();
|
|
2842
|
+
};
|
|
2843
|
+
const getLabel = () => {
|
|
2844
|
+
return openRecent();
|
|
2845
|
+
};
|
|
2846
|
+
const getHelpEntries = () => {
|
|
2847
|
+
return [];
|
|
2848
|
+
};
|
|
2849
|
+
const getNoResults = () => {
|
|
2850
|
+
return {
|
|
2851
|
+
label: noRecentlyOpenedFoldersFound()
|
|
2852
|
+
};
|
|
2853
|
+
};
|
|
2854
|
+
|
|
2855
|
+
// TODO could also change api so that getPicks returns an array of anything
|
|
2856
|
+
// and the transformPick gets the label for each pick
|
|
2857
|
+
// This would make the code more module since the code for getting the picks
|
|
2858
|
+
// would be more independent of the specific data format of the quickpick provider
|
|
2859
|
+
|
|
2860
|
+
const getPicks = async () => {
|
|
2861
|
+
const recentlyOpened = await getRecentlyOpened();
|
|
2862
|
+
return recentlyOpened;
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2865
|
+
// TODO selectPick should be independent of show/hide
|
|
2866
|
+
const selectPick = async pick => {
|
|
2867
|
+
const path = pick;
|
|
2868
|
+
await openWorkspaceFolder(path);
|
|
2869
|
+
return {
|
|
2870
|
+
command: Hide
|
|
2871
|
+
};
|
|
2872
|
+
};
|
|
2873
|
+
const getFilterValue = value => {
|
|
2874
|
+
return pathBaseName(value);
|
|
2875
|
+
};
|
|
2876
|
+
const getPickFilterValue = pick => {
|
|
2877
|
+
return pathBaseName(pick);
|
|
2878
|
+
};
|
|
2879
|
+
const getPickLabel = pick => {
|
|
2880
|
+
return pathBaseName(pick);
|
|
2881
|
+
};
|
|
2882
|
+
const getPickDescription = pick => {
|
|
2883
|
+
return pathDirName(pick);
|
|
2884
|
+
};
|
|
2885
|
+
const getPickIcon = () => {
|
|
2886
|
+
return '';
|
|
2887
|
+
};
|
|
2888
|
+
const getPickFileIcon = () => {
|
|
2889
|
+
return getFolderIcon();
|
|
2890
|
+
};
|
|
2891
|
+
|
|
2892
|
+
const QuickPickEntriesOpenRecent = {
|
|
2893
|
+
__proto__: null,
|
|
2894
|
+
getFilterValue,
|
|
2785
2895
|
getHelpEntries,
|
|
2896
|
+
getLabel,
|
|
2786
2897
|
getNoResults,
|
|
2898
|
+
getPickDescription,
|
|
2899
|
+
getPickFileIcon,
|
|
2900
|
+
getPickFilterValue,
|
|
2901
|
+
getPickIcon,
|
|
2902
|
+
getPickLabel,
|
|
2787
2903
|
getPicks,
|
|
2788
2904
|
getPlaceholder,
|
|
2789
|
-
name,
|
|
2790
2905
|
selectPick
|
|
2791
2906
|
};
|
|
2792
2907
|
|
|
2908
|
+
const CommandPalette = 'quickPick://commandPalette';
|
|
2909
|
+
const File = 'quickPick://file';
|
|
2910
|
+
const EveryThing = 'quickPick://everything';
|
|
2911
|
+
const Number$1 = 'quickPick://number';
|
|
2912
|
+
const Recent = 'quickPick://recent';
|
|
2913
|
+
const ColorTheme = 'quickPick://color-theme';
|
|
2914
|
+
const Symbol$1 = 'quickPick://symbol';
|
|
2915
|
+
const View = 'quickPick://view';
|
|
2916
|
+
const WorkspaceSymbol = 'quickPick://workspace-symbol';
|
|
2917
|
+
const Custom = 'quickPick://custom';
|
|
2918
|
+
|
|
2793
2919
|
const load = moduleId => {
|
|
2794
2920
|
switch (moduleId) {
|
|
2795
2921
|
case CommandPalette:
|
|
2796
|
-
case File
|
|
2922
|
+
case File:
|
|
2797
2923
|
case EveryThing:
|
|
2798
|
-
case WorkspaceSymbol
|
|
2924
|
+
case WorkspaceSymbol:
|
|
2799
2925
|
return QuickPickEntriesEverything;
|
|
2800
2926
|
case Number$1:
|
|
2801
2927
|
return QuickPickEntriesNumber;
|
|
@@ -2803,9 +2929,9 @@ const load = moduleId => {
|
|
|
2803
2929
|
return QuickPickEntriesOpenRecent;
|
|
2804
2930
|
case ColorTheme:
|
|
2805
2931
|
return QuickPickEntriesColorTheme;
|
|
2806
|
-
case Symbol$
|
|
2932
|
+
case Symbol$1:
|
|
2807
2933
|
return QuickPickEntriesSymbol;
|
|
2808
|
-
case View
|
|
2934
|
+
case View:
|
|
2809
2935
|
return QuickPickEntriesView;
|
|
2810
2936
|
case Custom:
|
|
2811
2937
|
return QuickPickEntriesCustom;
|
|
@@ -2814,24 +2940,72 @@ const load = moduleId => {
|
|
|
2814
2940
|
}
|
|
2815
2941
|
};
|
|
2816
2942
|
|
|
2943
|
+
const loadContent = async state => {
|
|
2944
|
+
const {
|
|
2945
|
+
uri,
|
|
2946
|
+
args
|
|
2947
|
+
} = state;
|
|
2948
|
+
const value = getDefaultValue(uri);
|
|
2949
|
+
const provider = await load(uri);
|
|
2950
|
+
// @ts-ignore
|
|
2951
|
+
if (provider.setArgs) {
|
|
2952
|
+
// @ts-ignore
|
|
2953
|
+
provider.setArgs(args);
|
|
2954
|
+
}
|
|
2955
|
+
const newPicks = await provider.getPicks(value);
|
|
2956
|
+
array(newPicks);
|
|
2957
|
+
// @ts-ignore
|
|
2958
|
+
const filterValue = provider.getFilterValue(value);
|
|
2959
|
+
const items = filterQuickPickItems(state.items, filterValue);
|
|
2960
|
+
// @ts-ignore
|
|
2961
|
+
provider.getLabel();
|
|
2962
|
+
const minLineY = 0;
|
|
2963
|
+
const maxLineY = Math.min(minLineY + state.maxVisibleItems, newPicks.length);
|
|
2964
|
+
return {
|
|
2965
|
+
...state,
|
|
2966
|
+
picks: newPicks,
|
|
2967
|
+
items,
|
|
2968
|
+
focusedIndex: 0,
|
|
2969
|
+
state: Finished,
|
|
2970
|
+
minLineY,
|
|
2971
|
+
maxLineY,
|
|
2972
|
+
value,
|
|
2973
|
+
cursorOffset: value.length,
|
|
2974
|
+
provider,
|
|
2975
|
+
inputSource: Script,
|
|
2976
|
+
focused: true
|
|
2977
|
+
};
|
|
2978
|
+
};
|
|
2979
|
+
|
|
2980
|
+
const loadQuickPickEntries = moduleId => {
|
|
2981
|
+
switch (moduleId) {
|
|
2982
|
+
case Recent:
|
|
2983
|
+
return QuickPickEntriesOpenRecent;
|
|
2984
|
+
default:
|
|
2985
|
+
throw new Error(`unknown module "${moduleId}"`);
|
|
2986
|
+
}
|
|
2987
|
+
};
|
|
2988
|
+
|
|
2817
2989
|
const commandMap = {
|
|
2818
|
-
'FileSystemFetch.chmod': chmod
|
|
2819
|
-
'FileSystemFetch.getBlob': getBlob
|
|
2820
|
-
'FileSystemFetch.mkdir': mkdir
|
|
2821
|
-
'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes
|
|
2822
|
-
'FileSystemFetch.readFile': readFile
|
|
2823
|
-
'FileSystemFetch.remove': remove
|
|
2824
|
-
'FileSystemFetch.writeFile': writeFile
|
|
2825
|
-
'FileSystemMemory.chmod': chmod,
|
|
2826
|
-
'FileSystemMemory.getBlob': getBlob,
|
|
2990
|
+
'FileSystemFetch.chmod': chmod,
|
|
2991
|
+
'FileSystemFetch.getBlob': getBlob,
|
|
2992
|
+
'FileSystemFetch.mkdir': mkdir,
|
|
2993
|
+
'FileSystemFetch.readDirWithFileTypes': readDirWithFileTypes,
|
|
2994
|
+
'FileSystemFetch.readFile': readFile,
|
|
2995
|
+
'FileSystemFetch.remove': remove,
|
|
2996
|
+
'FileSystemFetch.writeFile': writeFile,
|
|
2997
|
+
'FileSystemMemory.chmod': chmod$1,
|
|
2998
|
+
'FileSystemMemory.getBlob': getBlob$2,
|
|
2827
2999
|
'FileSystemMemory.getBlobUrl': getBlobUrl,
|
|
2828
3000
|
'FileSystemMemory.getFiles': getFiles,
|
|
2829
|
-
'FileSystemMemory.mkdir': mkdir,
|
|
2830
|
-
'FileSystemMemory.readDirWithFileTypes': readDirWithFileTypes,
|
|
2831
|
-
'FileSystemMemory.readFile': readFile,
|
|
2832
|
-
'FileSystemMemory.remove': remove,
|
|
2833
|
-
'FileSystemMemory.writeFile': writeFile,
|
|
3001
|
+
'FileSystemMemory.mkdir': mkdir$1,
|
|
3002
|
+
'FileSystemMemory.readDirWithFileTypes': readDirWithFileTypes$1,
|
|
3003
|
+
'FileSystemMemory.readFile': readFile$1,
|
|
3004
|
+
'FileSystemMemory.remove': remove$1,
|
|
3005
|
+
'FileSystemMemory.writeFile': writeFile$1,
|
|
3006
|
+
'QuickPick.create': create,
|
|
2834
3007
|
'QuickPick.getKeyBindings': getKeyBindings,
|
|
3008
|
+
'QuickPick.loadContent': loadContent,
|
|
2835
3009
|
'QuickPick.loadEntries': loadQuickPickEntries,
|
|
2836
3010
|
'QuickPick.loadEntries2': load,
|
|
2837
3011
|
'SearchFile.filter': filterQuickPickItems,
|