@lvce-editor/quick-pick-worker 4.21.0 → 4.21.1
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/quickPickWorkerMain.js +36 -4
- package/package.json +1 -1
|
@@ -2613,7 +2613,39 @@ const filterQuickPickItem = (pattern, word) => {
|
|
|
2613
2613
|
return matches;
|
|
2614
2614
|
};
|
|
2615
2615
|
|
|
2616
|
-
const
|
|
2616
|
+
const getMatchRank = (label, value) => {
|
|
2617
|
+
if (label === value) {
|
|
2618
|
+
return 4;
|
|
2619
|
+
}
|
|
2620
|
+
if (label.startsWith(value)) {
|
|
2621
|
+
return 3;
|
|
2622
|
+
}
|
|
2623
|
+
let index = label.indexOf(value);
|
|
2624
|
+
if (index === -1) {
|
|
2625
|
+
return 0;
|
|
2626
|
+
}
|
|
2627
|
+
while (index !== -1) {
|
|
2628
|
+
if (!/[\p{L}\p{N}]/u.test(label[index - 1])) {
|
|
2629
|
+
return 2;
|
|
2630
|
+
}
|
|
2631
|
+
index = label.indexOf(value, index + 1);
|
|
2632
|
+
}
|
|
2633
|
+
return 1;
|
|
2634
|
+
};
|
|
2635
|
+
const rankCommandPicks = (items, value) => {
|
|
2636
|
+
const normalizedValue = value.toLowerCase();
|
|
2637
|
+
const ranked = items.map(item => ({
|
|
2638
|
+
item,
|
|
2639
|
+
rank: getMatchRank(item.label.toLowerCase(), normalizedValue)
|
|
2640
|
+
}));
|
|
2641
|
+
// The first match entry is the fuzzy score; the remaining entries describe highlights.
|
|
2642
|
+
ranked.sort((a, b) => b.rank - a.rank || b.item.matches[0] - a.item.matches[0]);
|
|
2643
|
+
return ranked.map(({
|
|
2644
|
+
item
|
|
2645
|
+
}) => item);
|
|
2646
|
+
};
|
|
2647
|
+
|
|
2648
|
+
const filterQuickPickItems = (items, value, rankCommands = false) => {
|
|
2617
2649
|
if (!value) {
|
|
2618
2650
|
return items;
|
|
2619
2651
|
}
|
|
@@ -2628,7 +2660,7 @@ const filterQuickPickItems = (items, value) => {
|
|
|
2628
2660
|
});
|
|
2629
2661
|
}
|
|
2630
2662
|
}
|
|
2631
|
-
return results;
|
|
2663
|
+
return rankCommands ? rankCommandPicks(results, value) : results;
|
|
2632
2664
|
};
|
|
2633
2665
|
|
|
2634
2666
|
const Command = '>';
|
|
@@ -3786,7 +3818,7 @@ const setValue = async (state, newValue) => {
|
|
|
3786
3818
|
platform
|
|
3787
3819
|
});
|
|
3788
3820
|
const filterValue = quickInput ? '' : getFilterValue(providerId, subId, newValue);
|
|
3789
|
-
const items = filterQuickPickItems(newPicks, filterValue);
|
|
3821
|
+
const items = filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
|
|
3790
3822
|
const focusedIndex = items.length === 0 ? -1 : 0;
|
|
3791
3823
|
const sliced = items.slice(minLineY, maxLineY);
|
|
3792
3824
|
const {
|
|
@@ -4057,7 +4089,7 @@ const getLoadedState = async state => {
|
|
|
4057
4089
|
});
|
|
4058
4090
|
array(newPicks);
|
|
4059
4091
|
const filterValue = getFilterValue(id, subId, value);
|
|
4060
|
-
const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue);
|
|
4092
|
+
const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
|
|
4061
4093
|
const minLineY = 0;
|
|
4062
4094
|
const maxLineY = Math.min(minLineY + maxVisibleItems, newPicks.length);
|
|
4063
4095
|
const sliced = newPicks.slice(minLineY, maxLineY);
|