@optique/core 1.0.0-dev.1303 → 1.0.0-dev.1309
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/suggestion.cjs +18 -7
- package/dist/suggestion.js +18 -7
- package/package.json +1 -1
package/dist/suggestion.cjs
CHANGED
|
@@ -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
|
@@ -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
|