@lvce-editor/quick-pick-worker 4.24.6 → 4.25.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/quickPickWorkerMain.js +12 -2
- package/package.json +1 -1
|
@@ -2651,13 +2651,23 @@ const filterQuickPickItem = (pattern, word) => {
|
|
|
2651
2651
|
return matches;
|
|
2652
2652
|
};
|
|
2653
2653
|
|
|
2654
|
-
const getMatchRank = (label, value) => {
|
|
2654
|
+
const getMatchRank = (label, matches, value) => {
|
|
2655
2655
|
if (label === value) {
|
|
2656
2656
|
return 4;
|
|
2657
2657
|
}
|
|
2658
2658
|
if (label.startsWith(value)) {
|
|
2659
2659
|
return 3;
|
|
2660
2660
|
}
|
|
2661
|
+
let wordStartMatches = 0;
|
|
2662
|
+
for (let i = 1; i < matches.length; i += 2) {
|
|
2663
|
+
const start = matches[i];
|
|
2664
|
+
if (start === 0 || !/[\p{L}\p{N}]/u.test(label[start - 1])) {
|
|
2665
|
+
wordStartMatches++;
|
|
2666
|
+
if (wordStartMatches >= 2) {
|
|
2667
|
+
return 2;
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2661
2671
|
let index = label.indexOf(value);
|
|
2662
2672
|
if (index === -1) {
|
|
2663
2673
|
return 0;
|
|
@@ -2674,7 +2684,7 @@ const rankCommandPicks = (items, value) => {
|
|
|
2674
2684
|
const normalizedValue = value.toLowerCase();
|
|
2675
2685
|
const ranked = items.map(item => ({
|
|
2676
2686
|
item,
|
|
2677
|
-
rank: getMatchRank(item.label.toLowerCase(), normalizedValue)
|
|
2687
|
+
rank: getMatchRank(item.label.toLowerCase(), item.matches, normalizedValue)
|
|
2678
2688
|
}));
|
|
2679
2689
|
// The first match entry is the fuzzy score; the remaining entries describe highlights.
|
|
2680
2690
|
ranked.sort((a, b) => b.rank - a.rank || b.item.matches[0] - a.item.matches[0]);
|