@codingame/monaco-vscode-a17e9d37-b6c1-5556-8402-5db73960fae3-common 20.0.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/empty.js ADDED
@@ -0,0 +1 @@
1
+ export {}
package/package.json ADDED
@@ -0,0 +1,44 @@
1
+ {
2
+ "name": "@codingame/monaco-vscode-a17e9d37-b6c1-5556-8402-5db73960fae3-common",
3
+ "version": "20.0.0",
4
+ "private": false,
5
+ "description": "VSCode public API plugged on the monaco editor - common package (chat, debug, edit-sessions, editor, explorer, extension-gallery, extensions, interactive, mcp, multi-diff-editor, notebook, outline, output, preferences, quickaccess, scm, search, task, terminal, timeline, user-data-profile, user-data-sync, view-common, view-title-bar, views, workbench)",
6
+ "keywords": [],
7
+ "author": {
8
+ "name": "CodinGame",
9
+ "url": "http://www.codingame.com"
10
+ },
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+ssh://git@github.com/CodinGame/monaco-vscode-api.git"
15
+ },
16
+ "type": "module",
17
+ "dependencies": {
18
+ "@codingame/monaco-vscode-60014c9d-b815-501d-83a9-4b08725c2ec2-common": "20.0.0",
19
+ "@codingame/monaco-vscode-api": "20.0.0"
20
+ },
21
+ "exports": {
22
+ ".": {
23
+ "default": "./empty.js"
24
+ },
25
+ "./vscode/*.css": {
26
+ "default": "./vscode/src/*.css"
27
+ },
28
+ "./vscode/*": {
29
+ "types": "./vscode/src/*.d.ts",
30
+ "default": "./vscode/src/*.js"
31
+ },
32
+ "./*": {
33
+ "types": "./*.d.ts",
34
+ "default": "./*.js"
35
+ }
36
+ },
37
+ "typesVersions": {
38
+ "*": {
39
+ "vscode/*": [
40
+ "./vscode/src/*.d.ts"
41
+ ]
42
+ }
43
+ }
44
+ }
@@ -0,0 +1,41 @@
1
+ import { IMatch } from "@codingame/monaco-vscode-api/vscode/vs/base/common/filters";
2
+ export type FuzzyScore = [
3
+ number,
4
+ number[]
5
+ ];
6
+ export type FuzzyScorerCache = {
7
+ [key: string]: IItemScore;
8
+ };
9
+ export declare function scoreFuzzy(target: string, query: string, queryLower: string, allowNonContiguousMatches: boolean): FuzzyScore;
10
+ export type FuzzyScore2 = [
11
+ number | undefined,
12
+ IMatch[]
13
+ ];
14
+ export declare function scoreFuzzy2(target: string, query: IPreparedQuery | IPreparedQueryPiece, patternStart?: number, wordStart?: number): FuzzyScore2;
15
+ export interface IItemScore {
16
+ score: number;
17
+ labelMatch?: IMatch[];
18
+ descriptionMatch?: IMatch[];
19
+ }
20
+ export interface IItemAccessor<T> {
21
+ getItemLabel(item: T): string | undefined;
22
+ getItemDescription(item: T): string | undefined;
23
+ getItemPath(file: T): string | undefined;
24
+ }
25
+ export declare function scoreItemFuzzy<T>(item: T, query: IPreparedQuery, allowNonContiguousMatches: boolean, accessor: IItemAccessor<T>, cache: FuzzyScorerCache): IItemScore;
26
+ export declare function compareItemsByFuzzyScore<T>(itemA: T, itemB: T, query: IPreparedQuery, allowNonContiguousMatches: boolean, accessor: IItemAccessor<T>, cache: FuzzyScorerCache): number;
27
+ export interface IPreparedQueryPiece {
28
+ original: string;
29
+ originalLowercase: string;
30
+ pathNormalized: string;
31
+ normalized: string;
32
+ normalizedLowercase: string;
33
+ expectContiguousMatch: boolean;
34
+ }
35
+ export interface IPreparedQuery extends IPreparedQueryPiece {
36
+ values: IPreparedQueryPiece[] | undefined;
37
+ containsPathSeparator: boolean;
38
+ }
39
+ export declare function prepareQuery(original: string): IPreparedQuery;
40
+ export declare function pieceToQuery(piece: IPreparedQueryPiece): IPreparedQuery;
41
+ export declare function pieceToQuery(pieces: IPreparedQueryPiece[]): IPreparedQuery;
@@ -0,0 +1,487 @@
1
+
2
+ import { CharCode } from '@codingame/monaco-vscode-api/vscode/vs/base/common/charCode';
3
+ import { compareAnything } from '@codingame/monaco-vscode-api/vscode/vs/base/common/comparers';
4
+ import { isUpper, fuzzyScore, createMatches as createMatches$1, matchesPrefix } from '@codingame/monaco-vscode-api/vscode/vs/base/common/filters';
5
+ import { hash } from '@codingame/monaco-vscode-api/vscode/vs/base/common/hash';
6
+ import { sep } from '@codingame/monaco-vscode-api/vscode/vs/base/common/path';
7
+ import { isLinux, isWindows } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
8
+ import { equalsIgnoreCase, stripWildcards } from '@codingame/monaco-vscode-api/vscode/vs/base/common/strings';
9
+
10
+ const NO_MATCH = 0;
11
+ const NO_SCORE = [NO_MATCH, []];
12
+ function scoreFuzzy(target, query, queryLower, allowNonContiguousMatches) {
13
+ if (!target || !query) {
14
+ return NO_SCORE;
15
+ }
16
+ const targetLength = target.length;
17
+ const queryLength = query.length;
18
+ if (targetLength < queryLength) {
19
+ return NO_SCORE;
20
+ }
21
+ const targetLower = target.toLowerCase();
22
+ const res = doScoreFuzzy(query, queryLower, queryLength, target, targetLower, targetLength, allowNonContiguousMatches);
23
+ return res;
24
+ }
25
+ function doScoreFuzzy(query, queryLower, queryLength, target, targetLower, targetLength, allowNonContiguousMatches) {
26
+ const scores = [];
27
+ const matches = [];
28
+ for (let queryIndex = 0; queryIndex < queryLength; queryIndex++) {
29
+ const queryIndexOffset = queryIndex * targetLength;
30
+ const queryIndexPreviousOffset = queryIndexOffset - targetLength;
31
+ const queryIndexGtNull = queryIndex > 0;
32
+ const queryCharAtIndex = query[queryIndex];
33
+ const queryLowerCharAtIndex = queryLower[queryIndex];
34
+ for (let targetIndex = 0; targetIndex < targetLength; targetIndex++) {
35
+ const targetIndexGtNull = targetIndex > 0;
36
+ const currentIndex = queryIndexOffset + targetIndex;
37
+ const leftIndex = currentIndex - 1;
38
+ const diagIndex = queryIndexPreviousOffset + targetIndex - 1;
39
+ const leftScore = targetIndexGtNull ? scores[leftIndex] : 0;
40
+ const diagScore = queryIndexGtNull && targetIndexGtNull ? scores[diagIndex] : 0;
41
+ const matchesSequenceLength = queryIndexGtNull && targetIndexGtNull ? matches[diagIndex] : 0;
42
+ let score;
43
+ if (!diagScore && queryIndexGtNull) {
44
+ score = 0;
45
+ }
46
+ else {
47
+ score = computeCharScore(queryCharAtIndex, queryLowerCharAtIndex, target, targetLower, targetIndex, matchesSequenceLength);
48
+ }
49
+ const isValidScore = score && diagScore + score >= leftScore;
50
+ if (isValidScore && (
51
+ (allowNonContiguousMatches ||
52
+ queryIndexGtNull ||
53
+ targetLower.startsWith(queryLower, targetIndex)))) {
54
+ matches[currentIndex] = matchesSequenceLength + 1;
55
+ scores[currentIndex] = diagScore + score;
56
+ }
57
+ else {
58
+ matches[currentIndex] = NO_MATCH;
59
+ scores[currentIndex] = leftScore;
60
+ }
61
+ }
62
+ }
63
+ const positions = [];
64
+ let queryIndex = queryLength - 1;
65
+ let targetIndex = targetLength - 1;
66
+ while (queryIndex >= 0 && targetIndex >= 0) {
67
+ const currentIndex = queryIndex * targetLength + targetIndex;
68
+ const match = matches[currentIndex];
69
+ if (match === NO_MATCH) {
70
+ targetIndex--;
71
+ }
72
+ else {
73
+ positions.push(targetIndex);
74
+ queryIndex--;
75
+ targetIndex--;
76
+ }
77
+ }
78
+ return [scores[queryLength * targetLength - 1], positions.reverse()];
79
+ }
80
+ function computeCharScore(queryCharAtIndex, queryLowerCharAtIndex, target, targetLower, targetIndex, matchesSequenceLength) {
81
+ let score = 0;
82
+ if (!considerAsEqual(queryLowerCharAtIndex, targetLower[targetIndex])) {
83
+ return score;
84
+ }
85
+ score += 1;
86
+ if (matchesSequenceLength > 0) {
87
+ score += (Math.min(matchesSequenceLength, 3) * 6) + (Math.max(0, matchesSequenceLength - 3) * 3);
88
+ }
89
+ if (queryCharAtIndex === target[targetIndex]) {
90
+ score += 1;
91
+ }
92
+ if (targetIndex === 0) {
93
+ score += 8;
94
+ }
95
+ else {
96
+ const separatorBonus = scoreSeparatorAtPos(target.charCodeAt(targetIndex - 1));
97
+ if (separatorBonus) {
98
+ score += separatorBonus;
99
+ }
100
+ else if (isUpper(target.charCodeAt(targetIndex)) && matchesSequenceLength === 0) {
101
+ score += 2;
102
+ }
103
+ }
104
+ return score;
105
+ }
106
+ function considerAsEqual(a, b) {
107
+ if (a === b) {
108
+ return true;
109
+ }
110
+ if (a === '/' || a === '\\') {
111
+ return b === '/' || b === '\\';
112
+ }
113
+ return false;
114
+ }
115
+ function scoreSeparatorAtPos(charCode) {
116
+ switch (charCode) {
117
+ case CharCode.Slash:
118
+ case CharCode.Backslash:
119
+ return 5;
120
+ case CharCode.Underline:
121
+ case CharCode.Dash:
122
+ case CharCode.Period:
123
+ case CharCode.Space:
124
+ case CharCode.SingleQuote:
125
+ case CharCode.DoubleQuote:
126
+ case CharCode.Colon:
127
+ return 4;
128
+ default:
129
+ return 0;
130
+ }
131
+ }
132
+ const NO_SCORE2 = [undefined, []];
133
+ function scoreFuzzy2(target, query, patternStart = 0, wordStart = 0) {
134
+ const preparedQuery = query;
135
+ if (preparedQuery.values && preparedQuery.values.length > 1) {
136
+ return doScoreFuzzy2Multiple(target, preparedQuery.values, patternStart, wordStart);
137
+ }
138
+ return doScoreFuzzy2Single(target, query, patternStart, wordStart);
139
+ }
140
+ function doScoreFuzzy2Multiple(target, query, patternStart, wordStart) {
141
+ let totalScore = 0;
142
+ const totalMatches = [];
143
+ for (const queryPiece of query) {
144
+ const [score, matches] = doScoreFuzzy2Single(target, queryPiece, patternStart, wordStart);
145
+ if (typeof score !== 'number') {
146
+ return NO_SCORE2;
147
+ }
148
+ totalScore += score;
149
+ totalMatches.push(...matches);
150
+ }
151
+ return [totalScore, normalizeMatches(totalMatches)];
152
+ }
153
+ function doScoreFuzzy2Single(target, query, patternStart, wordStart) {
154
+ const score = fuzzyScore(query.original, query.originalLowercase, patternStart, target, target.toLowerCase(), wordStart, { firstMatchCanBeWeak: true, boostFullMatch: true });
155
+ if (!score) {
156
+ return NO_SCORE2;
157
+ }
158
+ return [score[0], createMatches$1(score)];
159
+ }
160
+ const NO_ITEM_SCORE = ( Object.freeze({ score: 0 }));
161
+ const PATH_IDENTITY_SCORE = 1 << 18;
162
+ const LABEL_PREFIX_SCORE_THRESHOLD = 1 << 17;
163
+ const LABEL_SCORE_THRESHOLD = 1 << 16;
164
+ function getCacheHash(label, description, allowNonContiguousMatches, query) {
165
+ const values = query.values ? query.values : [query];
166
+ const cacheHash = hash({
167
+ [query.normalized]: {
168
+ values: ( values.map(
169
+ v => ({ value: v.normalized, expectContiguousMatch: v.expectContiguousMatch })
170
+ )),
171
+ label,
172
+ description,
173
+ allowNonContiguousMatches
174
+ }
175
+ });
176
+ return cacheHash;
177
+ }
178
+ function scoreItemFuzzy(item, query, allowNonContiguousMatches, accessor, cache) {
179
+ if (!item || !query.normalized) {
180
+ return NO_ITEM_SCORE;
181
+ }
182
+ const label = accessor.getItemLabel(item);
183
+ if (!label) {
184
+ return NO_ITEM_SCORE;
185
+ }
186
+ const description = accessor.getItemDescription(item);
187
+ const cacheHash = getCacheHash(label, description, allowNonContiguousMatches, query);
188
+ const cached = cache[cacheHash];
189
+ if (cached) {
190
+ return cached;
191
+ }
192
+ const itemScore = doScoreItemFuzzy(label, description, accessor.getItemPath(item), query, allowNonContiguousMatches);
193
+ cache[cacheHash] = itemScore;
194
+ return itemScore;
195
+ }
196
+ function doScoreItemFuzzy(label, description, path, query, allowNonContiguousMatches) {
197
+ const preferLabelMatches = !path || !query.containsPathSeparator;
198
+ if (path && (isLinux ? query.pathNormalized === path : equalsIgnoreCase(query.pathNormalized, path))) {
199
+ return { score: PATH_IDENTITY_SCORE, labelMatch: [{ start: 0, end: label.length }], descriptionMatch: description ? [{ start: 0, end: description.length }] : undefined };
200
+ }
201
+ if (query.values && query.values.length > 1) {
202
+ return doScoreItemFuzzyMultiple(label, description, path, query.values, preferLabelMatches, allowNonContiguousMatches);
203
+ }
204
+ return doScoreItemFuzzySingle(label, description, path, query, preferLabelMatches, allowNonContiguousMatches);
205
+ }
206
+ function doScoreItemFuzzyMultiple(label, description, path, query, preferLabelMatches, allowNonContiguousMatches) {
207
+ let totalScore = 0;
208
+ const totalLabelMatches = [];
209
+ const totalDescriptionMatches = [];
210
+ for (const queryPiece of query) {
211
+ const { score, labelMatch, descriptionMatch } = doScoreItemFuzzySingle(label, description, path, queryPiece, preferLabelMatches, allowNonContiguousMatches);
212
+ if (score === NO_MATCH) {
213
+ return NO_ITEM_SCORE;
214
+ }
215
+ totalScore += score;
216
+ if (labelMatch) {
217
+ totalLabelMatches.push(...labelMatch);
218
+ }
219
+ if (descriptionMatch) {
220
+ totalDescriptionMatches.push(...descriptionMatch);
221
+ }
222
+ }
223
+ return {
224
+ score: totalScore,
225
+ labelMatch: normalizeMatches(totalLabelMatches),
226
+ descriptionMatch: normalizeMatches(totalDescriptionMatches)
227
+ };
228
+ }
229
+ function doScoreItemFuzzySingle(label, description, path, query, preferLabelMatches, allowNonContiguousMatches) {
230
+ if (preferLabelMatches || !description) {
231
+ const [labelScore, labelPositions] = scoreFuzzy(label, query.normalized, query.normalizedLowercase, allowNonContiguousMatches && !query.expectContiguousMatch);
232
+ if (labelScore) {
233
+ const labelPrefixMatch = matchesPrefix(query.normalized, label);
234
+ let baseScore;
235
+ if (labelPrefixMatch) {
236
+ baseScore = LABEL_PREFIX_SCORE_THRESHOLD;
237
+ const prefixLengthBoost = Math.round((query.normalized.length / label.length) * 100);
238
+ baseScore += prefixLengthBoost;
239
+ }
240
+ else {
241
+ baseScore = LABEL_SCORE_THRESHOLD;
242
+ }
243
+ return { score: baseScore + labelScore, labelMatch: labelPrefixMatch || createMatches(labelPositions) };
244
+ }
245
+ }
246
+ if (description) {
247
+ let descriptionPrefix = description;
248
+ if (!!path) {
249
+ descriptionPrefix = `${description}${sep}`;
250
+ }
251
+ const descriptionPrefixLength = descriptionPrefix.length;
252
+ const descriptionAndLabel = `${descriptionPrefix}${label}`;
253
+ const [labelDescriptionScore, labelDescriptionPositions] = scoreFuzzy(descriptionAndLabel, query.normalized, query.normalizedLowercase, allowNonContiguousMatches && !query.expectContiguousMatch);
254
+ if (labelDescriptionScore) {
255
+ const labelDescriptionMatches = createMatches(labelDescriptionPositions);
256
+ const labelMatch = [];
257
+ const descriptionMatch = [];
258
+ labelDescriptionMatches.forEach(h => {
259
+ if (h.start < descriptionPrefixLength && h.end > descriptionPrefixLength) {
260
+ labelMatch.push({ start: 0, end: h.end - descriptionPrefixLength });
261
+ descriptionMatch.push({ start: h.start, end: descriptionPrefixLength });
262
+ }
263
+ else if (h.start >= descriptionPrefixLength) {
264
+ labelMatch.push({ start: h.start - descriptionPrefixLength, end: h.end - descriptionPrefixLength });
265
+ }
266
+ else {
267
+ descriptionMatch.push(h);
268
+ }
269
+ });
270
+ return { score: labelDescriptionScore, labelMatch, descriptionMatch };
271
+ }
272
+ }
273
+ return NO_ITEM_SCORE;
274
+ }
275
+ function createMatches(offsets) {
276
+ const ret = [];
277
+ if (!offsets) {
278
+ return ret;
279
+ }
280
+ let last;
281
+ for (const pos of offsets) {
282
+ if (last && last.end === pos) {
283
+ last.end += 1;
284
+ }
285
+ else {
286
+ last = { start: pos, end: pos + 1 };
287
+ ret.push(last);
288
+ }
289
+ }
290
+ return ret;
291
+ }
292
+ function normalizeMatches(matches) {
293
+ const sortedMatches = matches.sort((matchA, matchB) => {
294
+ return matchA.start - matchB.start;
295
+ });
296
+ const normalizedMatches = [];
297
+ let currentMatch = undefined;
298
+ for (const match of sortedMatches) {
299
+ if (!currentMatch || !matchOverlaps(currentMatch, match)) {
300
+ currentMatch = match;
301
+ normalizedMatches.push(match);
302
+ }
303
+ else {
304
+ currentMatch.start = Math.min(currentMatch.start, match.start);
305
+ currentMatch.end = Math.max(currentMatch.end, match.end);
306
+ }
307
+ }
308
+ return normalizedMatches;
309
+ }
310
+ function matchOverlaps(matchA, matchB) {
311
+ if (matchA.end < matchB.start) {
312
+ return false;
313
+ }
314
+ if (matchB.end < matchA.start) {
315
+ return false;
316
+ }
317
+ return true;
318
+ }
319
+ function compareItemsByFuzzyScore(itemA, itemB, query, allowNonContiguousMatches, accessor, cache) {
320
+ const itemScoreA = scoreItemFuzzy(itemA, query, allowNonContiguousMatches, accessor, cache);
321
+ const itemScoreB = scoreItemFuzzy(itemB, query, allowNonContiguousMatches, accessor, cache);
322
+ const scoreA = itemScoreA.score;
323
+ const scoreB = itemScoreB.score;
324
+ if (scoreA === PATH_IDENTITY_SCORE || scoreB === PATH_IDENTITY_SCORE) {
325
+ if (scoreA !== scoreB) {
326
+ return scoreA === PATH_IDENTITY_SCORE ? -1 : 1;
327
+ }
328
+ }
329
+ if (scoreA > LABEL_SCORE_THRESHOLD || scoreB > LABEL_SCORE_THRESHOLD) {
330
+ if (scoreA !== scoreB) {
331
+ return scoreA > scoreB ? -1 : 1;
332
+ }
333
+ if (scoreA < LABEL_PREFIX_SCORE_THRESHOLD && scoreB < LABEL_PREFIX_SCORE_THRESHOLD) {
334
+ const comparedByMatchLength = compareByMatchLength(itemScoreA.labelMatch, itemScoreB.labelMatch);
335
+ if (comparedByMatchLength !== 0) {
336
+ return comparedByMatchLength;
337
+ }
338
+ }
339
+ const labelA = accessor.getItemLabel(itemA) || '';
340
+ const labelB = accessor.getItemLabel(itemB) || '';
341
+ if (labelA.length !== labelB.length) {
342
+ return labelA.length - labelB.length;
343
+ }
344
+ }
345
+ if (scoreA !== scoreB) {
346
+ return scoreA > scoreB ? -1 : 1;
347
+ }
348
+ const itemAHasLabelMatches = Array.isArray(itemScoreA.labelMatch) && itemScoreA.labelMatch.length > 0;
349
+ const itemBHasLabelMatches = Array.isArray(itemScoreB.labelMatch) && itemScoreB.labelMatch.length > 0;
350
+ if (itemAHasLabelMatches && !itemBHasLabelMatches) {
351
+ return -1;
352
+ }
353
+ else if (itemBHasLabelMatches && !itemAHasLabelMatches) {
354
+ return 1;
355
+ }
356
+ const itemAMatchDistance = computeLabelAndDescriptionMatchDistance(itemA, itemScoreA, accessor);
357
+ const itemBMatchDistance = computeLabelAndDescriptionMatchDistance(itemB, itemScoreB, accessor);
358
+ if (itemAMatchDistance && itemBMatchDistance && itemAMatchDistance !== itemBMatchDistance) {
359
+ return itemBMatchDistance > itemAMatchDistance ? -1 : 1;
360
+ }
361
+ return fallbackCompare(itemA, itemB, query, accessor);
362
+ }
363
+ function computeLabelAndDescriptionMatchDistance(item, score, accessor) {
364
+ let matchStart = -1;
365
+ let matchEnd = -1;
366
+ if (score.descriptionMatch && score.descriptionMatch.length) {
367
+ matchStart = score.descriptionMatch[0].start;
368
+ }
369
+ else if (score.labelMatch && score.labelMatch.length) {
370
+ matchStart = score.labelMatch[0].start;
371
+ }
372
+ if (score.labelMatch && score.labelMatch.length) {
373
+ matchEnd = score.labelMatch[score.labelMatch.length - 1].end;
374
+ if (score.descriptionMatch && score.descriptionMatch.length) {
375
+ const itemDescription = accessor.getItemDescription(item);
376
+ if (itemDescription) {
377
+ matchEnd += itemDescription.length;
378
+ }
379
+ }
380
+ }
381
+ else if (score.descriptionMatch && score.descriptionMatch.length) {
382
+ matchEnd = score.descriptionMatch[score.descriptionMatch.length - 1].end;
383
+ }
384
+ return matchEnd - matchStart;
385
+ }
386
+ function compareByMatchLength(matchesA, matchesB) {
387
+ if ((!matchesA && !matchesB) || ((!matchesA || !matchesA.length) && (!matchesB || !matchesB.length))) {
388
+ return 0;
389
+ }
390
+ if (!matchesB || !matchesB.length) {
391
+ return -1;
392
+ }
393
+ if (!matchesA || !matchesA.length) {
394
+ return 1;
395
+ }
396
+ const matchStartA = matchesA[0].start;
397
+ const matchEndA = matchesA[matchesA.length - 1].end;
398
+ const matchLengthA = matchEndA - matchStartA;
399
+ const matchStartB = matchesB[0].start;
400
+ const matchEndB = matchesB[matchesB.length - 1].end;
401
+ const matchLengthB = matchEndB - matchStartB;
402
+ return matchLengthA === matchLengthB ? 0 : matchLengthB < matchLengthA ? 1 : -1;
403
+ }
404
+ function fallbackCompare(itemA, itemB, query, accessor) {
405
+ const labelA = accessor.getItemLabel(itemA) || '';
406
+ const labelB = accessor.getItemLabel(itemB) || '';
407
+ const descriptionA = accessor.getItemDescription(itemA);
408
+ const descriptionB = accessor.getItemDescription(itemB);
409
+ const labelDescriptionALength = labelA.length + (descriptionA ? descriptionA.length : 0);
410
+ const labelDescriptionBLength = labelB.length + (descriptionB ? descriptionB.length : 0);
411
+ if (labelDescriptionALength !== labelDescriptionBLength) {
412
+ return labelDescriptionALength - labelDescriptionBLength;
413
+ }
414
+ const pathA = accessor.getItemPath(itemA);
415
+ const pathB = accessor.getItemPath(itemB);
416
+ if (pathA && pathB && pathA.length !== pathB.length) {
417
+ return pathA.length - pathB.length;
418
+ }
419
+ if (labelA !== labelB) {
420
+ return compareAnything(labelA, labelB, query.normalized);
421
+ }
422
+ if (descriptionA && descriptionB && descriptionA !== descriptionB) {
423
+ return compareAnything(descriptionA, descriptionB, query.normalized);
424
+ }
425
+ if (pathA && pathB && pathA !== pathB) {
426
+ return compareAnything(pathA, pathB, query.normalized);
427
+ }
428
+ return 0;
429
+ }
430
+ function queryExpectsExactMatch(query) {
431
+ return query.startsWith('"') && query.endsWith('"');
432
+ }
433
+ const MULTIPLE_QUERY_VALUES_SEPARATOR = ' ';
434
+ function prepareQuery(original) {
435
+ if (typeof original !== 'string') {
436
+ original = '';
437
+ }
438
+ const originalLowercase = original.toLowerCase();
439
+ const { pathNormalized, normalized, normalizedLowercase } = normalizeQuery(original);
440
+ const containsPathSeparator = pathNormalized.indexOf(sep) >= 0;
441
+ const expectExactMatch = queryExpectsExactMatch(original);
442
+ let values = undefined;
443
+ const originalSplit = original.split(MULTIPLE_QUERY_VALUES_SEPARATOR);
444
+ if (originalSplit.length > 1) {
445
+ for (const originalPiece of originalSplit) {
446
+ const expectExactMatchPiece = queryExpectsExactMatch(originalPiece);
447
+ const { pathNormalized: pathNormalizedPiece, normalized: normalizedPiece, normalizedLowercase: normalizedLowercasePiece } = normalizeQuery(originalPiece);
448
+ if (normalizedPiece) {
449
+ if (!values) {
450
+ values = [];
451
+ }
452
+ values.push({
453
+ original: originalPiece,
454
+ originalLowercase: originalPiece.toLowerCase(),
455
+ pathNormalized: pathNormalizedPiece,
456
+ normalized: normalizedPiece,
457
+ normalizedLowercase: normalizedLowercasePiece,
458
+ expectContiguousMatch: expectExactMatchPiece
459
+ });
460
+ }
461
+ }
462
+ }
463
+ return { original, originalLowercase, pathNormalized, normalized, normalizedLowercase, values, containsPathSeparator, expectContiguousMatch: expectExactMatch };
464
+ }
465
+ function normalizeQuery(original) {
466
+ let pathNormalized;
467
+ if (isWindows) {
468
+ pathNormalized = original.replace(/\//g, sep);
469
+ }
470
+ else {
471
+ pathNormalized = original.replace(/\\/g, sep);
472
+ }
473
+ const normalized = stripWildcards(pathNormalized).replace(/\s|"/g, '');
474
+ return {
475
+ pathNormalized,
476
+ normalized,
477
+ normalizedLowercase: normalized.toLowerCase()
478
+ };
479
+ }
480
+ function pieceToQuery(arg1) {
481
+ if (Array.isArray(arg1)) {
482
+ return prepareQuery(( arg1.map(piece => piece.original)).join(MULTIPLE_QUERY_VALUES_SEPARATOR));
483
+ }
484
+ return prepareQuery(arg1.original);
485
+ }
486
+
487
+ export { compareItemsByFuzzyScore, pieceToQuery, prepareQuery, scoreFuzzy, scoreFuzzy2, scoreItemFuzzy };
@@ -0,0 +1,42 @@
1
+ import { CancellationToken } from "@codingame/monaco-vscode-api/vscode/vs/base/common/cancellation";
2
+ import { Disposable, DisposableStore, IDisposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
3
+ import { IKeyMods, IQuickPickDidAcceptEvent, IQuickPickSeparator, IQuickPick, IQuickPickItem } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickInput";
4
+ import { IQuickAccessProvider, IQuickAccessProviderRunOptions } from "@codingame/monaco-vscode-api/vscode/vs/platform/quickinput/common/quickAccess";
5
+ export declare enum TriggerAction {
6
+ NO_ACTION = 0,
7
+ CLOSE_PICKER = 1,
8
+ REFRESH_PICKER = 2,
9
+ REMOVE_ITEM = 3
10
+ }
11
+ export interface IPickerQuickAccessItem extends IQuickPickItem {
12
+ accept?(keyMods: IKeyMods, event: IQuickPickDidAcceptEvent): void;
13
+ trigger?(buttonIndex: number, keyMods: IKeyMods): TriggerAction | Promise<TriggerAction>;
14
+ }
15
+ export interface IPickerQuickAccessSeparator extends IQuickPickSeparator {
16
+ trigger?(buttonIndex: number, keyMods: IKeyMods): TriggerAction | Promise<TriggerAction>;
17
+ }
18
+ export interface IPickerQuickAccessProviderOptions<T extends IPickerQuickAccessItem> {
19
+ readonly canAcceptInBackground?: boolean;
20
+ readonly noResultsPick?: T | ((filter: string) => T);
21
+ readonly shouldSkipTrimPickFilter?: boolean;
22
+ }
23
+ export type Pick<T> = T | IQuickPickSeparator;
24
+ export type PicksWithActive<T> = {
25
+ items: readonly Pick<T>[];
26
+ active?: T;
27
+ };
28
+ export type Picks<T> = readonly Pick<T>[] | PicksWithActive<T>;
29
+ export type FastAndSlowPicks<T> = {
30
+ readonly picks: Picks<T>;
31
+ readonly additionalPicks: Promise<Picks<T>>;
32
+ readonly mergeDelay?: number;
33
+ };
34
+ export declare abstract class PickerQuickAccessProvider<T extends IPickerQuickAccessItem> extends Disposable implements IQuickAccessProvider {
35
+ private prefix;
36
+ protected options?: IPickerQuickAccessProviderOptions<T> | undefined;
37
+ constructor(prefix: string, options?: IPickerQuickAccessProviderOptions<T> | undefined);
38
+ provide(picker: IQuickPick<T, {
39
+ useSeparators: true;
40
+ }>, token: CancellationToken, runOptions?: IQuickAccessProviderRunOptions): IDisposable;
41
+ protected abstract _getPicks(filter: string, disposables: DisposableStore, token: CancellationToken, runOptions?: IQuickAccessProviderRunOptions): Picks<T> | Promise<Picks<T> | FastAndSlowPicks<T>> | FastAndSlowPicks<T> | null;
42
+ }