@lvce-editor/quick-pick-worker 4.21.1 → 4.22.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 +106 -87
- 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,
|
|
@@ -2469,6 +2475,7 @@ const Dash = '-';
|
|
|
2469
2475
|
const Dot = '.';
|
|
2470
2476
|
const EmptyString = '';
|
|
2471
2477
|
const Space = ' ';
|
|
2478
|
+
const Slash = '/';
|
|
2472
2479
|
const Underline = '_';
|
|
2473
2480
|
const T = 't';
|
|
2474
2481
|
const isLowerCase = char => {
|
|
@@ -2484,6 +2491,7 @@ const isGap = (columnCharBefore, columnChar) => {
|
|
|
2484
2491
|
case Dash:
|
|
2485
2492
|
case Dot:
|
|
2486
2493
|
case EmptyString:
|
|
2494
|
+
case Slash:
|
|
2487
2495
|
case Space:
|
|
2488
2496
|
case T:
|
|
2489
2497
|
case Underline:
|
|
@@ -3417,13 +3425,23 @@ const getPath = uri => {
|
|
|
3417
3425
|
if (uri.startsWith(remoteSshScheme)) {
|
|
3418
3426
|
const pathStart = getRemoteSshPathStart(uri);
|
|
3419
3427
|
if (pathStart !== -1) {
|
|
3420
|
-
|
|
3428
|
+
const path = decodePath(uri.slice(pathStart));
|
|
3429
|
+
let end = path.length;
|
|
3430
|
+
while (end > 1 && path[end - 1] === '/') {
|
|
3431
|
+
end--;
|
|
3432
|
+
}
|
|
3433
|
+
return path.slice(0, end);
|
|
3421
3434
|
}
|
|
3435
|
+
return '/';
|
|
3422
3436
|
}
|
|
3423
3437
|
return uri;
|
|
3424
3438
|
};
|
|
3425
3439
|
const getLabel = uri => {
|
|
3426
3440
|
const path = getPath(uri);
|
|
3441
|
+
if (path === '/' && uri.startsWith(remoteSshScheme)) {
|
|
3442
|
+
const pathStart = getRemoteSshPathStart(uri);
|
|
3443
|
+
return uri.slice(remoteSshScheme.length, pathStart === -1 ? uri.length : pathStart);
|
|
3444
|
+
}
|
|
3427
3445
|
if (path.startsWith('/')) {
|
|
3428
3446
|
return pathBaseName(path);
|
|
3429
3447
|
}
|
|
@@ -3435,7 +3453,8 @@ const getDescription = uri => {
|
|
|
3435
3453
|
const directory = pathDirName(path);
|
|
3436
3454
|
if (uri.startsWith(remoteSshScheme)) {
|
|
3437
3455
|
const pathStart = getRemoteSshPathStart(uri);
|
|
3438
|
-
|
|
3456
|
+
const authority = pathStart === -1 ? uri : uri.slice(0, pathStart);
|
|
3457
|
+
return `${authority}${path === '/' ? '/' : directory}`;
|
|
3439
3458
|
}
|
|
3440
3459
|
return directory;
|
|
3441
3460
|
}
|