@lvce-editor/text-search-worker 3.31.0 → 3.33.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/textSearchWorkerMain.js +131 -109
- package/package.json +1 -1
|
@@ -1695,6 +1695,7 @@ const Search$1 = 'Search';
|
|
|
1695
1695
|
const SearchField = 'SearchField';
|
|
1696
1696
|
const SearchFieldButton = 'SearchFieldButton';
|
|
1697
1697
|
const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
|
|
1698
|
+
const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
|
|
1698
1699
|
const SearchFieldButtons = 'SearchFieldButtons';
|
|
1699
1700
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
1700
1701
|
const SearchFieldError = 'SearchFieldError';
|
|
@@ -1900,6 +1901,18 @@ const getMatchCount = (results, startIndex) => {
|
|
|
1900
1901
|
return results.length - startIndex - 1;
|
|
1901
1902
|
};
|
|
1902
1903
|
|
|
1904
|
+
const getChildCount = (expanded, matchCount) => {
|
|
1905
|
+
let childCount = 1;
|
|
1906
|
+
if (expanded === Expanded || expanded === Collapsed) {
|
|
1907
|
+
childCount += 2;
|
|
1908
|
+
}
|
|
1909
|
+
if (matchCount) {
|
|
1910
|
+
childCount++;
|
|
1911
|
+
}
|
|
1912
|
+
childCount++;
|
|
1913
|
+
return childCount;
|
|
1914
|
+
};
|
|
1915
|
+
|
|
1903
1916
|
// TODO this should be in FileSystem module
|
|
1904
1917
|
const pathBaseName = path => {
|
|
1905
1918
|
return path.slice(path.lastIndexOf('/') + 1);
|
|
@@ -1911,12 +1924,55 @@ const getAbsolutePath = relativePath => {
|
|
|
1911
1924
|
return `/${relativePath}`; // TODO support windows paths
|
|
1912
1925
|
};
|
|
1913
1926
|
|
|
1914
|
-
const
|
|
1927
|
+
const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults) => {
|
|
1928
|
+
const path = text;
|
|
1929
|
+
const absolutePath = getAbsolutePath(path);
|
|
1930
|
+
const baseName = pathBaseName(path);
|
|
1931
|
+
const index = originalResults.indexOf(results[i]);
|
|
1932
|
+
const matchCount = getMatchCount(results, index);
|
|
1933
|
+
const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
|
|
1934
|
+
const childCount = getChildCount(expanded, matchCount);
|
|
1935
|
+
const badgeText = `${matchCount}`;
|
|
1936
|
+
return {
|
|
1937
|
+
badgeText,
|
|
1938
|
+
childCount,
|
|
1939
|
+
depth: 0,
|
|
1940
|
+
expanded,
|
|
1941
|
+
focused,
|
|
1942
|
+
icon: fileIcons[relativeIndex],
|
|
1943
|
+
matchLength: 0,
|
|
1944
|
+
matchStart: 0,
|
|
1945
|
+
posInSet,
|
|
1946
|
+
replacement: '',
|
|
1947
|
+
setSize,
|
|
1948
|
+
text: baseName,
|
|
1949
|
+
title: absolutePath
|
|
1950
|
+
};
|
|
1951
|
+
};
|
|
1952
|
+
|
|
1953
|
+
const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused) => {
|
|
1954
|
+
return {
|
|
1955
|
+
badgeText: '',
|
|
1956
|
+
childCount: getChildCount(None, 0),
|
|
1957
|
+
depth: 1,
|
|
1958
|
+
expanded: None,
|
|
1959
|
+
focused,
|
|
1960
|
+
icon: '',
|
|
1961
|
+
matchLength: searchTermLength,
|
|
1962
|
+
matchStart: start,
|
|
1963
|
+
posInSet,
|
|
1964
|
+
replacement,
|
|
1965
|
+
setSize,
|
|
1966
|
+
text: text,
|
|
1967
|
+
title: text
|
|
1968
|
+
};
|
|
1969
|
+
};
|
|
1970
|
+
|
|
1971
|
+
const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY, originalResults) => {
|
|
1915
1972
|
const result = results[i];
|
|
1916
1973
|
const {
|
|
1917
1974
|
type,
|
|
1918
1975
|
text,
|
|
1919
|
-
lineNumber,
|
|
1920
1976
|
start
|
|
1921
1977
|
} = result;
|
|
1922
1978
|
const posInSet = i + 1;
|
|
@@ -1924,52 +1980,20 @@ const getDisplayResult = (results, fileIcons, i, setSize, searchTermLength, repl
|
|
|
1924
1980
|
const relativeIndex = i - minLineY;
|
|
1925
1981
|
switch (type) {
|
|
1926
1982
|
case File:
|
|
1927
|
-
|
|
1928
|
-
const absolutePath = getAbsolutePath(path);
|
|
1929
|
-
const baseName = pathBaseName(path);
|
|
1930
|
-
const matchCount = getMatchCount(results, i);
|
|
1931
|
-
return {
|
|
1932
|
-
title: absolutePath,
|
|
1933
|
-
text: baseName,
|
|
1934
|
-
icon: fileIcons[relativeIndex],
|
|
1935
|
-
posInSet,
|
|
1936
|
-
setSize,
|
|
1937
|
-
lineNumber,
|
|
1938
|
-
matchStart: 0,
|
|
1939
|
-
matchLength: 0,
|
|
1940
|
-
replacement: '',
|
|
1941
|
-
depth: 0,
|
|
1942
|
-
matchCount,
|
|
1943
|
-
focused,
|
|
1944
|
-
expanded: collapsedPaths.includes(path) ? Collapsed : Expanded
|
|
1945
|
-
};
|
|
1983
|
+
return getSearchDisplayResultFile(results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults);
|
|
1946
1984
|
case Match:
|
|
1947
|
-
return
|
|
1948
|
-
title: text,
|
|
1949
|
-
text: text,
|
|
1950
|
-
icon: '',
|
|
1951
|
-
posInSet,
|
|
1952
|
-
setSize,
|
|
1953
|
-
lineNumber,
|
|
1954
|
-
matchStart: start,
|
|
1955
|
-
matchLength: searchTermLength,
|
|
1956
|
-
replacement,
|
|
1957
|
-
depth: 1,
|
|
1958
|
-
matchCount: 0,
|
|
1959
|
-
focused,
|
|
1960
|
-
expanded: None
|
|
1961
|
-
};
|
|
1985
|
+
return getDisplayResultMatch(setSize, searchTermLength, replacement, text, posInSet, start, focused);
|
|
1962
1986
|
default:
|
|
1963
1987
|
throw new Error('unexpected search result type');
|
|
1964
1988
|
}
|
|
1965
1989
|
};
|
|
1966
1990
|
|
|
1967
|
-
const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLineY, maxLineY, replacement, fileIcons, focusedIndex, collapsedPaths) => {
|
|
1991
|
+
const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLineY, maxLineY, replacement, fileIcons, focusedIndex, collapsedPaths, originalResults) => {
|
|
1968
1992
|
const displayResults = [];
|
|
1969
1993
|
const setSize = resultCount;
|
|
1970
1994
|
const searchTermLength = searchTerm.length;
|
|
1971
1995
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
1972
|
-
const displayResult = getDisplayResult(results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY);
|
|
1996
|
+
const displayResult = getDisplayResult(results, fileIcons, i, setSize, searchTermLength, replacement, focusedIndex, collapsedPaths, minLineY, originalResults);
|
|
1973
1997
|
displayResults.push(displayResult);
|
|
1974
1998
|
}
|
|
1975
1999
|
return displayResults;
|
|
@@ -2073,16 +2097,20 @@ const getInputActionsInclude = flags => {
|
|
|
2073
2097
|
};
|
|
2074
2098
|
};
|
|
2075
2099
|
|
|
2100
|
+
const getClassName = (checked, disabled) => {
|
|
2101
|
+
return mergeClassNames(SearchFieldButton, checked ? SearchFieldButtonChecked : '', disabled ? SearchFieldButtonDisabled : '');
|
|
2102
|
+
};
|
|
2076
2103
|
const getSearchFieldButtonVirtualDom = button => {
|
|
2077
2104
|
const {
|
|
2078
2105
|
icon,
|
|
2079
2106
|
checked,
|
|
2080
2107
|
title,
|
|
2081
|
-
name
|
|
2108
|
+
name,
|
|
2109
|
+
disabled
|
|
2082
2110
|
} = button;
|
|
2083
2111
|
return [{
|
|
2084
|
-
type:
|
|
2085
|
-
className:
|
|
2112
|
+
type: Button,
|
|
2113
|
+
className: getClassName(checked, disabled),
|
|
2086
2114
|
name,
|
|
2087
2115
|
title,
|
|
2088
2116
|
role: CheckBox,
|
|
@@ -2090,7 +2118,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
2090
2118
|
tabIndex: 0,
|
|
2091
2119
|
childCount: 1
|
|
2092
2120
|
}, {
|
|
2093
|
-
type:
|
|
2121
|
+
type: Span,
|
|
2094
2122
|
className: mergeClassNames(MaskIcon, icon),
|
|
2095
2123
|
childCount: 0
|
|
2096
2124
|
}];
|
|
@@ -2197,7 +2225,7 @@ const getInputActionsInput = flags => {
|
|
|
2197
2225
|
};
|
|
2198
2226
|
};
|
|
2199
2227
|
|
|
2200
|
-
const getInputActionsReplace = flags => {
|
|
2228
|
+
const getInputActionsReplace = (flags, matchCount) => {
|
|
2201
2229
|
const inside = [{
|
|
2202
2230
|
icon: MaskIconPreserveCase,
|
|
2203
2231
|
checked: Boolean(flags & PreserveCase$1),
|
|
@@ -2208,7 +2236,8 @@ const getInputActionsReplace = flags => {
|
|
|
2208
2236
|
icon: MaskIconReplaceAll,
|
|
2209
2237
|
checked: false,
|
|
2210
2238
|
title: replaceAll$1(),
|
|
2211
|
-
name: ReplaceAll
|
|
2239
|
+
name: ReplaceAll,
|
|
2240
|
+
disabled: matchCount === 0
|
|
2212
2241
|
}];
|
|
2213
2242
|
return {
|
|
2214
2243
|
inside,
|
|
@@ -2233,9 +2262,9 @@ const getSearchToggleVirtualDom = flags => {
|
|
|
2233
2262
|
}];
|
|
2234
2263
|
};
|
|
2235
2264
|
|
|
2236
|
-
const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage
|
|
2265
|
+
const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount) => {
|
|
2237
2266
|
const inputActions = getInputActionsInput(flags);
|
|
2238
|
-
const replaceActions = getInputActionsReplace(flags);
|
|
2267
|
+
const replaceActions = getInputActionsReplace(flags, matchCount);
|
|
2239
2268
|
const dom = [{
|
|
2240
2269
|
type: Div,
|
|
2241
2270
|
className: SearchHeaderTop,
|
|
@@ -2253,7 +2282,7 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage = '') => {
|
|
|
2253
2282
|
return dom;
|
|
2254
2283
|
};
|
|
2255
2284
|
|
|
2256
|
-
const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage) => {
|
|
2285
|
+
const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount) => {
|
|
2257
2286
|
const dom = [{
|
|
2258
2287
|
type: Div,
|
|
2259
2288
|
className: SearchHeader,
|
|
@@ -2261,7 +2290,7 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage) => {
|
|
|
2261
2290
|
childCount: 2,
|
|
2262
2291
|
onClick: HandleHeaderClick2,
|
|
2263
2292
|
onFocusIn: HandleHeaderFocusIn
|
|
2264
|
-
}, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage), ...getSearchHeaderDetailsVirtualDom(flags, message)];
|
|
2293
|
+
}, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount), ...getSearchHeaderDetailsVirtualDom(flags, message)];
|
|
2265
2294
|
return dom;
|
|
2266
2295
|
};
|
|
2267
2296
|
|
|
@@ -2313,12 +2342,15 @@ const getAriaExpanded = expanded => {
|
|
|
2313
2342
|
}
|
|
2314
2343
|
};
|
|
2315
2344
|
|
|
2316
|
-
const getBadgeVirtualDom = (className,
|
|
2345
|
+
const getBadgeVirtualDom = (className, badgeText) => {
|
|
2346
|
+
if (!badgeText) {
|
|
2347
|
+
return [];
|
|
2348
|
+
}
|
|
2317
2349
|
return [{
|
|
2318
2350
|
type: Div,
|
|
2319
2351
|
className: mergeClassNames(Badge, className),
|
|
2320
2352
|
childCount: 1
|
|
2321
|
-
}, text(
|
|
2353
|
+
}, text(badgeText)];
|
|
2322
2354
|
};
|
|
2323
2355
|
|
|
2324
2356
|
const chevronDownVirtualDom = {
|
|
@@ -2396,6 +2428,16 @@ const getSearchResultClassName = focused => {
|
|
|
2396
2428
|
|
|
2397
2429
|
const PaddingRight = '12px';
|
|
2398
2430
|
|
|
2431
|
+
const getIconsVirtualDom = (expanded, icon) => {
|
|
2432
|
+
switch (expanded) {
|
|
2433
|
+
case Expanded:
|
|
2434
|
+
return [chevronDownVirtualDom, getFileIconVirtualDom(icon)];
|
|
2435
|
+
case Collapsed:
|
|
2436
|
+
return [chevronRightVirtualDom, getFileIconVirtualDom(icon)];
|
|
2437
|
+
default:
|
|
2438
|
+
return [];
|
|
2439
|
+
}
|
|
2440
|
+
};
|
|
2399
2441
|
const getSearchResultVirtualDom = rowInfo => {
|
|
2400
2442
|
const {
|
|
2401
2443
|
matchStart,
|
|
@@ -2407,11 +2449,12 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
2407
2449
|
posInSet,
|
|
2408
2450
|
depth,
|
|
2409
2451
|
replacement,
|
|
2410
|
-
matchCount,
|
|
2411
2452
|
focused,
|
|
2412
|
-
expanded
|
|
2453
|
+
expanded,
|
|
2454
|
+
childCount,
|
|
2455
|
+
badgeText
|
|
2413
2456
|
} = rowInfo;
|
|
2414
|
-
const
|
|
2457
|
+
const dom = [{
|
|
2415
2458
|
type: Div,
|
|
2416
2459
|
role: TreeItem$1,
|
|
2417
2460
|
className: getSearchResultClassName(focused),
|
|
@@ -2421,29 +2464,11 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
2421
2464
|
ariaPosInSet: posInSet,
|
|
2422
2465
|
ariaLabel: title,
|
|
2423
2466
|
ariaDescription: '',
|
|
2424
|
-
childCount
|
|
2467
|
+
childCount,
|
|
2425
2468
|
paddingLeft: getPaddingLeft(depth),
|
|
2426
2469
|
paddingRight: PaddingRight,
|
|
2427
2470
|
ariaExpanded: getAriaExpanded(expanded)
|
|
2428
|
-
}
|
|
2429
|
-
const dom = [];
|
|
2430
|
-
dom.push(treeItem);
|
|
2431
|
-
if (expanded === Expanded) {
|
|
2432
|
-
// TODO move childcount computation to getDisplaySearchresults
|
|
2433
|
-
// TODO add chevronIcon and fileIcon properties to getDisplaySearchResults
|
|
2434
|
-
treeItem.childCount += 2;
|
|
2435
|
-
dom.push(chevronDownVirtualDom, getFileIconVirtualDom(icon));
|
|
2436
|
-
} else if (expanded === Collapsed) {
|
|
2437
|
-
treeItem.childCount += 2;
|
|
2438
|
-
dom.push(chevronRightVirtualDom, getFileIconVirtualDom(icon));
|
|
2439
|
-
}
|
|
2440
|
-
dom.push(...getLabelVirtualDom(displayText, matchLength, matchStart, replacement));
|
|
2441
|
-
if (matchCount) {
|
|
2442
|
-
treeItem.childCount++;
|
|
2443
|
-
dom.push(...getBadgeVirtualDom(SourceControlBadge, matchCount));
|
|
2444
|
-
}
|
|
2445
|
-
treeItem.childCount++;
|
|
2446
|
-
dom.push({
|
|
2471
|
+
}, ...getIconsVirtualDom(expanded, icon), ...getLabelVirtualDom(displayText, matchLength, matchStart, replacement), ...getBadgeVirtualDom(SourceControlBadge, badgeText), {
|
|
2447
2472
|
type: Div,
|
|
2448
2473
|
className: SearchRemove,
|
|
2449
2474
|
childCount: 1
|
|
@@ -2451,7 +2476,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
2451
2476
|
type: Div,
|
|
2452
2477
|
className: CloseMaskIcon,
|
|
2453
2478
|
childCount: 0
|
|
2454
|
-
}
|
|
2479
|
+
}];
|
|
2455
2480
|
return dom;
|
|
2456
2481
|
};
|
|
2457
2482
|
|
|
@@ -2480,14 +2505,14 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
|
|
|
2480
2505
|
}, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
|
|
2481
2506
|
};
|
|
2482
2507
|
|
|
2483
|
-
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight) => {
|
|
2508
|
+
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount) => {
|
|
2484
2509
|
const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
|
|
2485
2510
|
const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
|
|
2486
2511
|
return [{
|
|
2487
2512
|
type: Div,
|
|
2488
2513
|
className: mergeClassNames(Viewlet, Search$1),
|
|
2489
2514
|
childCount
|
|
2490
|
-
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
|
|
2515
|
+
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
|
|
2491
2516
|
};
|
|
2492
2517
|
|
|
2493
2518
|
const handleError = error => {
|
|
@@ -3056,31 +3081,22 @@ const toggleUseRegularExpression = state => {
|
|
|
3056
3081
|
const getClickHandler = name => {
|
|
3057
3082
|
switch (name) {
|
|
3058
3083
|
case MatchCase:
|
|
3059
|
-
// @ts-ignore
|
|
3060
3084
|
return toggleMatchCase;
|
|
3061
3085
|
case ToggleReplace:
|
|
3062
|
-
// @ts-ignore
|
|
3063
3086
|
return toggleReplace;
|
|
3064
3087
|
case UseRegularExpression:
|
|
3065
|
-
// @ts-ignore
|
|
3066
3088
|
return toggleUseRegularExpression;
|
|
3067
3089
|
case ReplaceAll:
|
|
3068
|
-
// @ts-ignore
|
|
3069
3090
|
return replaceAll;
|
|
3070
3091
|
case MatchWholeWord:
|
|
3071
|
-
// @ts-ignore
|
|
3072
3092
|
return toggleMatchWholeWord;
|
|
3073
3093
|
case PreserveCase:
|
|
3074
|
-
// @ts-ignore
|
|
3075
3094
|
return togglePreserveCase;
|
|
3076
3095
|
case ToggleSearchDetails:
|
|
3077
|
-
// @ts-ignore
|
|
3078
3096
|
return toggleDetailsExpanded;
|
|
3079
3097
|
case SearchOnlyOpenEditors:
|
|
3080
|
-
// @ts-ignore
|
|
3081
3098
|
return toggleOpenEditors;
|
|
3082
3099
|
case UseExcludeSettings:
|
|
3083
|
-
// @ts-ignore
|
|
3084
3100
|
return toggleUseIgnoreFiles;
|
|
3085
3101
|
case SearchValue:
|
|
3086
3102
|
case ReplaceValue:
|
|
@@ -3356,6 +3372,7 @@ const selectIndexFile = async (state, searchResult, index) => {
|
|
|
3356
3372
|
const path = searchResult.text;
|
|
3357
3373
|
const newCollapsedPaths = toggleCollapsedPath(collapsedPaths, path);
|
|
3358
3374
|
const filteredResults = getFilteredResults(items, newCollapsedPaths);
|
|
3375
|
+
const icons = await getFileIcons(filteredResults);
|
|
3359
3376
|
const total = filteredResults.length;
|
|
3360
3377
|
const listHeight = height - headerHeight;
|
|
3361
3378
|
const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
@@ -3366,7 +3383,8 @@ const selectIndexFile = async (state, searchResult, index) => {
|
|
|
3366
3383
|
listFocusedIndex: index,
|
|
3367
3384
|
listFocused: true,
|
|
3368
3385
|
listItems: filteredResults,
|
|
3369
|
-
maxLineY
|
|
3386
|
+
maxLineY,
|
|
3387
|
+
icons
|
|
3370
3388
|
};
|
|
3371
3389
|
};
|
|
3372
3390
|
|
|
@@ -3427,9 +3445,9 @@ const selectIndex = async (state, index) => {
|
|
|
3427
3445
|
};
|
|
3428
3446
|
}
|
|
3429
3447
|
const {
|
|
3430
|
-
|
|
3448
|
+
listItems
|
|
3431
3449
|
} = state;
|
|
3432
|
-
const searchResult =
|
|
3450
|
+
const searchResult = listItems[index];
|
|
3433
3451
|
const fn = getSelectHandler(searchResult.type);
|
|
3434
3452
|
return fn(state, searchResult, index);
|
|
3435
3453
|
};
|
|
@@ -3467,7 +3485,8 @@ const setDeltaY = (state, value) => {
|
|
|
3467
3485
|
finalDeltaY,
|
|
3468
3486
|
deltaY,
|
|
3469
3487
|
height,
|
|
3470
|
-
headerHeight
|
|
3488
|
+
headerHeight,
|
|
3489
|
+
listItems
|
|
3471
3490
|
} = state;
|
|
3472
3491
|
const listHeight = height - headerHeight;
|
|
3473
3492
|
const newDeltaY = clamp(value, 0, finalDeltaY);
|
|
@@ -3476,7 +3495,7 @@ const setDeltaY = (state, value) => {
|
|
|
3476
3495
|
}
|
|
3477
3496
|
// TODO when it only moves by one px, extensions don't need to be rerendered, only negative margin
|
|
3478
3497
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
3479
|
-
const maxLineY = minLineY + getNumberOfVisibleItems(listHeight, itemHeight);
|
|
3498
|
+
const maxLineY = Math.min(minLineY + getNumberOfVisibleItems(listHeight, itemHeight), listItems.length);
|
|
3480
3499
|
|
|
3481
3500
|
// TODO update icons
|
|
3482
3501
|
return {
|
|
@@ -3663,11 +3682,11 @@ const renderItems = {
|
|
|
3663
3682
|
return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.replacement === newState.replacement && oldState.flags === newState.flags && oldState.message === newState.message && oldState.loaded === newState.loaded && oldState.collapsedPaths === newState.collapsedPaths && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.listFocused === newState.listFocused && oldState.icons === newState.icons && oldState.searchInputErrorMessage === newState.searchInputErrorMessage && oldState.deltaY === newState.deltaY;
|
|
3664
3683
|
},
|
|
3665
3684
|
apply(oldState, newState) {
|
|
3666
|
-
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths);
|
|
3685
|
+
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex, newState.collapsedPaths, newState.items);
|
|
3667
3686
|
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3668
3687
|
const scrollBarValue = newState.deltaY / newState.finalDeltaY * 100;
|
|
3669
3688
|
const scrollBarY = getScrollBarY(newState.deltaY, newState.finalDeltaY, newState.height - newState.headerHeight, newState.scrollBarHeight);
|
|
3670
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight);
|
|
3689
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage, newState.scrollBarHeight, scrollBarY, scrollBarValue, newState.deltaY, newState.itemHeight, newState.matchCount);
|
|
3671
3690
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3672
3691
|
}
|
|
3673
3692
|
};
|
|
@@ -3677,7 +3696,7 @@ const renderFocus = {
|
|
|
3677
3696
|
},
|
|
3678
3697
|
apply(oldState, newState) {
|
|
3679
3698
|
const name = newState.focusSource === User ? '' : getFocusSelector(newState.focus);
|
|
3680
|
-
return ['Viewlet.focusElementByName', name];
|
|
3699
|
+
return ['Viewlet.focusElementByName', newState.uid, name];
|
|
3681
3700
|
}
|
|
3682
3701
|
};
|
|
3683
3702
|
const renderValue = {
|
|
@@ -3787,10 +3806,6 @@ const saveState = uid => {
|
|
|
3787
3806
|
};
|
|
3788
3807
|
};
|
|
3789
3808
|
|
|
3790
|
-
const setFocus = async focusKey => {
|
|
3791
|
-
await invoke$2('Focus.setFocus', focusKey);
|
|
3792
|
-
};
|
|
3793
|
-
|
|
3794
3809
|
const focusElement = (state, focusKey) => {
|
|
3795
3810
|
return {
|
|
3796
3811
|
...state,
|
|
@@ -3799,6 +3814,10 @@ const focusElement = (state, focusKey) => {
|
|
|
3799
3814
|
};
|
|
3800
3815
|
};
|
|
3801
3816
|
|
|
3817
|
+
const setFocus = async focusKey => {
|
|
3818
|
+
await invoke$2('Focus.setFocus', focusKey);
|
|
3819
|
+
};
|
|
3820
|
+
|
|
3802
3821
|
const getSearchFocusKey = key => {
|
|
3803
3822
|
switch (key) {
|
|
3804
3823
|
case SearchValue:
|
|
@@ -3825,11 +3844,26 @@ const getSearchFocusKey = key => {
|
|
|
3825
3844
|
return FocusSearchOpenEditors;
|
|
3826
3845
|
case UseExcludeSettings:
|
|
3827
3846
|
return FocusIgnoreFiles;
|
|
3847
|
+
case ToggleReplace:
|
|
3848
|
+
return FocusToggleReplace;
|
|
3828
3849
|
default:
|
|
3829
3850
|
return Empty$1;
|
|
3830
3851
|
}
|
|
3831
3852
|
};
|
|
3832
3853
|
|
|
3854
|
+
const handleFocusIn = (state, key) => {
|
|
3855
|
+
const focusKey = getSearchFocusKey(key);
|
|
3856
|
+
if (state.focus === focusKey) {
|
|
3857
|
+
return state;
|
|
3858
|
+
}
|
|
3859
|
+
void setFocus(FocusSearch);
|
|
3860
|
+
return {
|
|
3861
|
+
...state,
|
|
3862
|
+
focus: focusKey,
|
|
3863
|
+
focusSource: User
|
|
3864
|
+
};
|
|
3865
|
+
};
|
|
3866
|
+
|
|
3833
3867
|
const focusSearchValue = state => {
|
|
3834
3868
|
return focusElement(state, FocusSearchInput);
|
|
3835
3869
|
};
|
|
@@ -3869,18 +3903,6 @@ const focusRegex = state => {
|
|
|
3869
3903
|
const focusReplaceAll = state => {
|
|
3870
3904
|
return focusElement(state, FocusSearchReplaceAll);
|
|
3871
3905
|
};
|
|
3872
|
-
const handleFocusIn = (state, key) => {
|
|
3873
|
-
const focusKey = getSearchFocusKey(key);
|
|
3874
|
-
if (state.focus === focusKey) {
|
|
3875
|
-
return state;
|
|
3876
|
-
}
|
|
3877
|
-
void setFocus(FocusSearch);
|
|
3878
|
-
return {
|
|
3879
|
-
...state,
|
|
3880
|
-
focus: focusKey,
|
|
3881
|
-
focusSource: User
|
|
3882
|
-
};
|
|
3883
|
-
};
|
|
3884
3906
|
|
|
3885
3907
|
const submit = state => {
|
|
3886
3908
|
return handleUpdate(state, {
|