@lvce-editor/quick-pick-worker 4.21.0 → 4.22.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 +127 -89
- package/package.json +1 -1
|
@@ -1804,6 +1804,87 @@ const getListHeight$1 = (itemsLength, itemHeight, maxHeight) => {
|
|
|
1804
1804
|
return Math.min(totalHeight, maxHeight);
|
|
1805
1805
|
};
|
|
1806
1806
|
|
|
1807
|
+
const getIconsCached = (paths, fileIconCache) => {
|
|
1808
|
+
return paths.map(path => fileIconCache[path]);
|
|
1809
|
+
};
|
|
1810
|
+
|
|
1811
|
+
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
1812
|
+
const missingRequests = [];
|
|
1813
|
+
for (const dirent of dirents) {
|
|
1814
|
+
if (!dirent.path) {
|
|
1815
|
+
continue;
|
|
1816
|
+
}
|
|
1817
|
+
if (!(dirent.path in fileIconCache)) {
|
|
1818
|
+
missingRequests.push({
|
|
1819
|
+
name: dirent.name,
|
|
1820
|
+
path: dirent.path,
|
|
1821
|
+
type: dirent.type
|
|
1822
|
+
});
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
return missingRequests;
|
|
1826
|
+
};
|
|
1827
|
+
|
|
1828
|
+
const getPath$1 = dirent => {
|
|
1829
|
+
return dirent.path;
|
|
1830
|
+
};
|
|
1831
|
+
|
|
1832
|
+
const None$2 = 0;
|
|
1833
|
+
const Directory = 3;
|
|
1834
|
+
const File = 7;
|
|
1835
|
+
|
|
1836
|
+
const requestFileIcon = async request => {
|
|
1837
|
+
if (!request.name) {
|
|
1838
|
+
return '';
|
|
1839
|
+
}
|
|
1840
|
+
return request.type === File ? getFileIcon({
|
|
1841
|
+
name: request.name
|
|
1842
|
+
}) : getFolderIcon({
|
|
1843
|
+
name: request.name
|
|
1844
|
+
});
|
|
1845
|
+
};
|
|
1846
|
+
const requestFileIcons = async requests => {
|
|
1847
|
+
const promises = requests.map(requestFileIcon);
|
|
1848
|
+
return Promise.all(promises);
|
|
1849
|
+
};
|
|
1850
|
+
|
|
1851
|
+
const toDirent = pick => {
|
|
1852
|
+
const dirent = {
|
|
1853
|
+
name: pick.iconName || pick.label,
|
|
1854
|
+
path: pick.uri,
|
|
1855
|
+
type: pick.direntType
|
|
1856
|
+
};
|
|
1857
|
+
return dirent;
|
|
1858
|
+
};
|
|
1859
|
+
|
|
1860
|
+
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
1861
|
+
if (missingRequests.length === 0) {
|
|
1862
|
+
return iconCache;
|
|
1863
|
+
}
|
|
1864
|
+
const newFileIconCache = {
|
|
1865
|
+
...iconCache
|
|
1866
|
+
};
|
|
1867
|
+
for (let i = 0; i < missingRequests.length; i++) {
|
|
1868
|
+
const request = missingRequests[i];
|
|
1869
|
+
const icon = newIcons[i];
|
|
1870
|
+
newFileIconCache[request.path] = icon;
|
|
1871
|
+
}
|
|
1872
|
+
return newFileIconCache;
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
const getQuickPickFileIcons = async (items, fileIconCache) => {
|
|
1876
|
+
const dirents = items.map(toDirent);
|
|
1877
|
+
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
1878
|
+
const newIcons = await requestFileIcons(missingRequests);
|
|
1879
|
+
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
1880
|
+
const paths = dirents.map(getPath$1);
|
|
1881
|
+
const icons = getIconsCached(paths, newFileIconCache);
|
|
1882
|
+
return {
|
|
1883
|
+
icons,
|
|
1884
|
+
newFileIconCache
|
|
1885
|
+
};
|
|
1886
|
+
};
|
|
1887
|
+
|
|
1807
1888
|
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
1808
1889
|
if (size >= contentSize) {
|
|
1809
1890
|
return 0;
|
|
@@ -1878,7 +1959,7 @@ const getScrollBarTop = (state, scrollBarHeight) => {
|
|
|
1878
1959
|
const getRelativePointerY = (state, clientY) => {
|
|
1879
1960
|
return clientY - state.top - state.headerHeight;
|
|
1880
1961
|
};
|
|
1881
|
-
const setDeltaY = (state, deltaY) => {
|
|
1962
|
+
const setDeltaY = async (state, deltaY) => {
|
|
1882
1963
|
object(state);
|
|
1883
1964
|
number(deltaY);
|
|
1884
1965
|
const {
|
|
@@ -1902,20 +1983,26 @@ const setDeltaY = (state, deltaY) => {
|
|
|
1902
1983
|
const maxLineY = minLineY + Math.round(listHeight / itemHeight);
|
|
1903
1984
|
number(minLineY);
|
|
1904
1985
|
number(maxLineY);
|
|
1986
|
+
const {
|
|
1987
|
+
icons,
|
|
1988
|
+
newFileIconCache
|
|
1989
|
+
} = await getQuickPickFileIcons(items.slice(minLineY, maxLineY), state.fileIconCache);
|
|
1905
1990
|
return {
|
|
1906
1991
|
...state,
|
|
1907
1992
|
deltaY,
|
|
1993
|
+
fileIconCache: newFileIconCache,
|
|
1994
|
+
icons,
|
|
1908
1995
|
maxLineY,
|
|
1909
1996
|
minLineY
|
|
1910
1997
|
};
|
|
1911
1998
|
};
|
|
1912
|
-
const handleWheel = (state, deltaMode, deltaY) => {
|
|
1999
|
+
const handleWheel = async (state, deltaMode, deltaY) => {
|
|
1913
2000
|
object(state);
|
|
1914
2001
|
number(deltaMode);
|
|
1915
2002
|
number(deltaY);
|
|
1916
2003
|
return setDeltaY(state, state.deltaY + deltaY);
|
|
1917
2004
|
};
|
|
1918
|
-
const handleScrollBarPointerDown = (state, clientY, pointerId) => {
|
|
2005
|
+
const handleScrollBarPointerDown = async (state, clientY, pointerId) => {
|
|
1919
2006
|
object(state);
|
|
1920
2007
|
number(clientY);
|
|
1921
2008
|
number(pointerId);
|
|
@@ -1934,7 +2021,7 @@ const handleScrollBarPointerDown = (state, clientY, pointerId) => {
|
|
|
1934
2021
|
};
|
|
1935
2022
|
return handleScrollBarPointerMove(newState, clientY, pointerId);
|
|
1936
2023
|
};
|
|
1937
|
-
const handleScrollBarPointerMove = (state, clientY, pointerId) => {
|
|
2024
|
+
const handleScrollBarPointerMove = async (state, clientY, pointerId) => {
|
|
1938
2025
|
object(state);
|
|
1939
2026
|
number(clientY);
|
|
1940
2027
|
number(pointerId);
|
|
@@ -2081,87 +2168,6 @@ const focusPick = (id, pick) => {
|
|
|
2081
2168
|
return fn(pick);
|
|
2082
2169
|
};
|
|
2083
2170
|
|
|
2084
|
-
const getIconsCached = (paths, fileIconCache) => {
|
|
2085
|
-
return paths.map(path => fileIconCache[path]);
|
|
2086
|
-
};
|
|
2087
|
-
|
|
2088
|
-
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
2089
|
-
const missingRequests = [];
|
|
2090
|
-
for (const dirent of dirents) {
|
|
2091
|
-
if (!dirent.path) {
|
|
2092
|
-
continue;
|
|
2093
|
-
}
|
|
2094
|
-
if (!(dirent.path in fileIconCache)) {
|
|
2095
|
-
missingRequests.push({
|
|
2096
|
-
name: dirent.name,
|
|
2097
|
-
path: dirent.path,
|
|
2098
|
-
type: dirent.type
|
|
2099
|
-
});
|
|
2100
|
-
}
|
|
2101
|
-
}
|
|
2102
|
-
return missingRequests;
|
|
2103
|
-
};
|
|
2104
|
-
|
|
2105
|
-
const getPath$1 = dirent => {
|
|
2106
|
-
return dirent.path;
|
|
2107
|
-
};
|
|
2108
|
-
|
|
2109
|
-
const None$2 = 0;
|
|
2110
|
-
const Directory = 3;
|
|
2111
|
-
const File = 7;
|
|
2112
|
-
|
|
2113
|
-
const requestFileIcon = async request => {
|
|
2114
|
-
if (!request.name) {
|
|
2115
|
-
return '';
|
|
2116
|
-
}
|
|
2117
|
-
return request.type === File ? getFileIcon({
|
|
2118
|
-
name: request.name
|
|
2119
|
-
}) : getFolderIcon({
|
|
2120
|
-
name: request.name
|
|
2121
|
-
});
|
|
2122
|
-
};
|
|
2123
|
-
const requestFileIcons = async requests => {
|
|
2124
|
-
const promises = requests.map(requestFileIcon);
|
|
2125
|
-
return Promise.all(promises);
|
|
2126
|
-
};
|
|
2127
|
-
|
|
2128
|
-
const toDirent = pick => {
|
|
2129
|
-
const dirent = {
|
|
2130
|
-
name: pick.iconName || pick.label,
|
|
2131
|
-
path: pick.uri,
|
|
2132
|
-
type: pick.direntType
|
|
2133
|
-
};
|
|
2134
|
-
return dirent;
|
|
2135
|
-
};
|
|
2136
|
-
|
|
2137
|
-
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
2138
|
-
if (missingRequests.length === 0) {
|
|
2139
|
-
return iconCache;
|
|
2140
|
-
}
|
|
2141
|
-
const newFileIconCache = {
|
|
2142
|
-
...iconCache
|
|
2143
|
-
};
|
|
2144
|
-
for (let i = 0; i < missingRequests.length; i++) {
|
|
2145
|
-
const request = missingRequests[i];
|
|
2146
|
-
const icon = newIcons[i];
|
|
2147
|
-
newFileIconCache[request.path] = icon;
|
|
2148
|
-
}
|
|
2149
|
-
return newFileIconCache;
|
|
2150
|
-
};
|
|
2151
|
-
|
|
2152
|
-
const getQuickPickFileIcons = async (items, fileIconCache) => {
|
|
2153
|
-
const dirents = items.map(toDirent);
|
|
2154
|
-
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
2155
|
-
const newIcons = await requestFileIcons(missingRequests);
|
|
2156
|
-
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
2157
|
-
const paths = dirents.map(getPath$1);
|
|
2158
|
-
const icons = getIconsCached(paths, newFileIconCache);
|
|
2159
|
-
return {
|
|
2160
|
-
icons,
|
|
2161
|
-
newFileIconCache
|
|
2162
|
-
};
|
|
2163
|
-
};
|
|
2164
|
-
|
|
2165
2171
|
const focusIndex = async (state, index) => {
|
|
2166
2172
|
const {
|
|
2167
2173
|
fileIconCache,
|
|
@@ -2613,7 +2619,39 @@ const filterQuickPickItem = (pattern, word) => {
|
|
|
2613
2619
|
return matches;
|
|
2614
2620
|
};
|
|
2615
2621
|
|
|
2616
|
-
const
|
|
2622
|
+
const getMatchRank = (label, value) => {
|
|
2623
|
+
if (label === value) {
|
|
2624
|
+
return 4;
|
|
2625
|
+
}
|
|
2626
|
+
if (label.startsWith(value)) {
|
|
2627
|
+
return 3;
|
|
2628
|
+
}
|
|
2629
|
+
let index = label.indexOf(value);
|
|
2630
|
+
if (index === -1) {
|
|
2631
|
+
return 0;
|
|
2632
|
+
}
|
|
2633
|
+
while (index !== -1) {
|
|
2634
|
+
if (!/[\p{L}\p{N}]/u.test(label[index - 1])) {
|
|
2635
|
+
return 2;
|
|
2636
|
+
}
|
|
2637
|
+
index = label.indexOf(value, index + 1);
|
|
2638
|
+
}
|
|
2639
|
+
return 1;
|
|
2640
|
+
};
|
|
2641
|
+
const rankCommandPicks = (items, value) => {
|
|
2642
|
+
const normalizedValue = value.toLowerCase();
|
|
2643
|
+
const ranked = items.map(item => ({
|
|
2644
|
+
item,
|
|
2645
|
+
rank: getMatchRank(item.label.toLowerCase(), normalizedValue)
|
|
2646
|
+
}));
|
|
2647
|
+
// The first match entry is the fuzzy score; the remaining entries describe highlights.
|
|
2648
|
+
ranked.sort((a, b) => b.rank - a.rank || b.item.matches[0] - a.item.matches[0]);
|
|
2649
|
+
return ranked.map(({
|
|
2650
|
+
item
|
|
2651
|
+
}) => item);
|
|
2652
|
+
};
|
|
2653
|
+
|
|
2654
|
+
const filterQuickPickItems = (items, value, rankCommands = false) => {
|
|
2617
2655
|
if (!value) {
|
|
2618
2656
|
return items;
|
|
2619
2657
|
}
|
|
@@ -2628,7 +2666,7 @@ const filterQuickPickItems = (items, value) => {
|
|
|
2628
2666
|
});
|
|
2629
2667
|
}
|
|
2630
2668
|
}
|
|
2631
|
-
return results;
|
|
2669
|
+
return rankCommands ? rankCommandPicks(results, value) : results;
|
|
2632
2670
|
};
|
|
2633
2671
|
|
|
2634
2672
|
const Command = '>';
|
|
@@ -3786,7 +3824,7 @@ const setValue = async (state, newValue) => {
|
|
|
3786
3824
|
platform
|
|
3787
3825
|
});
|
|
3788
3826
|
const filterValue = quickInput ? '' : getFilterValue(providerId, subId, newValue);
|
|
3789
|
-
const items = filterQuickPickItems(newPicks, filterValue);
|
|
3827
|
+
const items = filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
|
|
3790
3828
|
const focusedIndex = items.length === 0 ? -1 : 0;
|
|
3791
3829
|
const sliced = items.slice(minLineY, maxLineY);
|
|
3792
3830
|
const {
|
|
@@ -4057,7 +4095,7 @@ const getLoadedState = async state => {
|
|
|
4057
4095
|
});
|
|
4058
4096
|
array(newPicks);
|
|
4059
4097
|
const filterValue = getFilterValue(id, subId, value);
|
|
4060
|
-
const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue);
|
|
4098
|
+
const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
|
|
4061
4099
|
const minLineY = 0;
|
|
4062
4100
|
const maxLineY = Math.min(minLineY + maxVisibleItems, newPicks.length);
|
|
4063
4101
|
const sliced = newPicks.slice(minLineY, maxLineY);
|