@optique/core 1.0.0-dev.1303 → 1.0.0-dev.1313
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/modifiers.cjs +1 -1
- package/dist/modifiers.js +1 -1
- package/dist/suggestion.cjs +19 -8
- package/dist/suggestion.js +19 -8
- package/package.json +1 -1
package/dist/modifiers.cjs
CHANGED
|
@@ -628,7 +628,7 @@ function multiple(parser, options = {}) {
|
|
|
628
628
|
suggestion.type,
|
|
629
629
|
suggestion.pattern ?? "",
|
|
630
630
|
suggestion.includeHidden === true,
|
|
631
|
-
suggestion.extensions == null ? "" : suggestion.extensions.join("\0"),
|
|
631
|
+
suggestion.extensions == null ? "" : suggestion.extensions.toSorted().join("\0"),
|
|
632
632
|
description
|
|
633
633
|
]);
|
|
634
634
|
};
|
package/dist/modifiers.js
CHANGED
|
@@ -628,7 +628,7 @@ function multiple(parser, options = {}) {
|
|
|
628
628
|
suggestion.type,
|
|
629
629
|
suggestion.pattern ?? "",
|
|
630
630
|
suggestion.includeHidden === true,
|
|
631
|
-
suggestion.extensions == null ? "" : suggestion.extensions.join("\0"),
|
|
631
|
+
suggestion.extensions == null ? "" : suggestion.extensions.toSorted().join("\0"),
|
|
632
632
|
description
|
|
633
633
|
]);
|
|
634
634
|
};
|
package/dist/suggestion.cjs
CHANGED
|
@@ -192,7 +192,7 @@ function createErrorWithSuggestions(baseError, invalidInput, usage, type = "both
|
|
|
192
192
|
*/
|
|
193
193
|
function getSuggestionKey(suggestion) {
|
|
194
194
|
if (suggestion.kind === "literal") return suggestion.text;
|
|
195
|
-
return `__FILE__:${suggestion.type}:${suggestion.extensions?.join(",") ?? ""}:${suggestion.pattern ?? ""}`;
|
|
195
|
+
return `__FILE__:${suggestion.type}:${suggestion.extensions?.toSorted().join(",") ?? ""}:${suggestion.pattern ?? ""}`;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* Removes duplicate suggestions from an array while preserving order.
|
|
@@ -201,7 +201,11 @@ function getSuggestionKey(suggestion) {
|
|
|
201
201
|
* - Literal suggestions: same text
|
|
202
202
|
* - File suggestions: same type, extensions, and pattern
|
|
203
203
|
*
|
|
204
|
-
* The first occurrence of each unique suggestion is kept.
|
|
204
|
+
* The first occurrence of each unique suggestion is kept. For file
|
|
205
|
+
* suggestions, `includeHidden` is merged across duplicates: if any
|
|
206
|
+
* duplicate has `includeHidden: true`, the kept suggestion is upgraded
|
|
207
|
+
* to `includeHidden: true` because it is a superset of the non-hidden
|
|
208
|
+
* variant.
|
|
205
209
|
*
|
|
206
210
|
* @param suggestions Array of suggestions that may contain duplicates
|
|
207
211
|
* @returns A new array with duplicates removed, preserving order of first occurrences
|
|
@@ -220,13 +224,20 @@ function getSuggestionKey(suggestion) {
|
|
|
220
224
|
* @since 0.9.0
|
|
221
225
|
*/
|
|
222
226
|
function deduplicateSuggestions(suggestions) {
|
|
223
|
-
const
|
|
224
|
-
|
|
227
|
+
const entries = /* @__PURE__ */ new Map();
|
|
228
|
+
const order = [];
|
|
229
|
+
for (const suggestion of suggestions) {
|
|
225
230
|
const key = getSuggestionKey(suggestion);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
const existing = entries.get(key);
|
|
232
|
+
if (existing == null) {
|
|
233
|
+
entries.set(key, suggestion);
|
|
234
|
+
order.push(key);
|
|
235
|
+
} else if (suggestion.kind === "file" && existing.kind === "file" && suggestion.includeHidden === true && existing.includeHidden !== true) entries.set(key, {
|
|
236
|
+
...existing,
|
|
237
|
+
includeHidden: true
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return order.map((key) => entries.get(key));
|
|
230
241
|
}
|
|
231
242
|
|
|
232
243
|
//#endregion
|
package/dist/suggestion.js
CHANGED
|
@@ -192,7 +192,7 @@ function createErrorWithSuggestions(baseError, invalidInput, usage, type = "both
|
|
|
192
192
|
*/
|
|
193
193
|
function getSuggestionKey(suggestion) {
|
|
194
194
|
if (suggestion.kind === "literal") return suggestion.text;
|
|
195
|
-
return `__FILE__:${suggestion.type}:${suggestion.extensions?.join(",") ?? ""}:${suggestion.pattern ?? ""}`;
|
|
195
|
+
return `__FILE__:${suggestion.type}:${suggestion.extensions?.toSorted().join(",") ?? ""}:${suggestion.pattern ?? ""}`;
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
198
|
* Removes duplicate suggestions from an array while preserving order.
|
|
@@ -201,7 +201,11 @@ function getSuggestionKey(suggestion) {
|
|
|
201
201
|
* - Literal suggestions: same text
|
|
202
202
|
* - File suggestions: same type, extensions, and pattern
|
|
203
203
|
*
|
|
204
|
-
* The first occurrence of each unique suggestion is kept.
|
|
204
|
+
* The first occurrence of each unique suggestion is kept. For file
|
|
205
|
+
* suggestions, `includeHidden` is merged across duplicates: if any
|
|
206
|
+
* duplicate has `includeHidden: true`, the kept suggestion is upgraded
|
|
207
|
+
* to `includeHidden: true` because it is a superset of the non-hidden
|
|
208
|
+
* variant.
|
|
205
209
|
*
|
|
206
210
|
* @param suggestions Array of suggestions that may contain duplicates
|
|
207
211
|
* @returns A new array with duplicates removed, preserving order of first occurrences
|
|
@@ -220,13 +224,20 @@ function getSuggestionKey(suggestion) {
|
|
|
220
224
|
* @since 0.9.0
|
|
221
225
|
*/
|
|
222
226
|
function deduplicateSuggestions(suggestions) {
|
|
223
|
-
const
|
|
224
|
-
|
|
227
|
+
const entries = /* @__PURE__ */ new Map();
|
|
228
|
+
const order = [];
|
|
229
|
+
for (const suggestion of suggestions) {
|
|
225
230
|
const key = getSuggestionKey(suggestion);
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
231
|
+
const existing = entries.get(key);
|
|
232
|
+
if (existing == null) {
|
|
233
|
+
entries.set(key, suggestion);
|
|
234
|
+
order.push(key);
|
|
235
|
+
} else if (suggestion.kind === "file" && existing.kind === "file" && suggestion.includeHidden === true && existing.includeHidden !== true) entries.set(key, {
|
|
236
|
+
...existing,
|
|
237
|
+
includeHidden: true
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
return order.map((key) => entries.get(key));
|
|
230
241
|
}
|
|
231
242
|
|
|
232
243
|
//#endregion
|