@lvce-editor/text-search-worker 3.24.0 → 3.26.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 +159 -76
- package/package.json +1 -1
|
@@ -1196,7 +1196,8 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1196
1196
|
handleOffset: 0,
|
|
1197
1197
|
focusSource: User,
|
|
1198
1198
|
flags: 0,
|
|
1199
|
-
platform
|
|
1199
|
+
platform,
|
|
1200
|
+
searchInputErrorMessage: ''
|
|
1200
1201
|
};
|
|
1201
1202
|
set(uid, state, state);
|
|
1202
1203
|
return state;
|
|
@@ -1245,6 +1246,8 @@ const PreserveCase$2 = 'Preserve Case';
|
|
|
1245
1246
|
const Refresh$1 = 'Refresh';
|
|
1246
1247
|
const Replace = 'Replace';
|
|
1247
1248
|
const ReplaceAll$1 = 'Replace All';
|
|
1249
|
+
const ReplacedManyOccurrencesInManyFiles = "Replaced {PH1} occurrences across {PH2} files with '{PH3}'";
|
|
1250
|
+
const ReplacedOneOccurrenceInOneFile = "Replaced 1 occurrence across 1 file with '{PH1}'";
|
|
1248
1251
|
const ToggleReplace$1 = 'Toggle Replace';
|
|
1249
1252
|
const UseRegularExpression$2 = 'Use Regular Expression';
|
|
1250
1253
|
const ViewAsTree = 'View as Tree';
|
|
@@ -1321,6 +1324,24 @@ const confirmReplaceManyOccurrencesInManyFilesNoValue = (matchCount, fileCount)
|
|
|
1321
1324
|
PH2: fileCount
|
|
1322
1325
|
});
|
|
1323
1326
|
};
|
|
1327
|
+
const replacedOneOccurrenceInOneFile = replacement => {
|
|
1328
|
+
return i18nString(ReplacedOneOccurrenceInOneFile, {
|
|
1329
|
+
PH1: replacement
|
|
1330
|
+
});
|
|
1331
|
+
};
|
|
1332
|
+
const replacedManyOccurrencesInOneFile = (matchCount, replacement) => {
|
|
1333
|
+
return i18nString(ReplacedOneOccurrenceInOneFile, {
|
|
1334
|
+
PH1: matchCount,
|
|
1335
|
+
PH2: replacement
|
|
1336
|
+
});
|
|
1337
|
+
};
|
|
1338
|
+
const replacedManyOccurrencesInManyFiles = (matchCount, fileCount, replacement) => {
|
|
1339
|
+
return i18nString(ReplacedManyOccurrencesInManyFiles, {
|
|
1340
|
+
PH1: matchCount,
|
|
1341
|
+
PH2: fileCount,
|
|
1342
|
+
PH3: replacement
|
|
1343
|
+
});
|
|
1344
|
+
};
|
|
1324
1345
|
const replaceAll$1 = () => {
|
|
1325
1346
|
return i18nString(ReplaceAll$1);
|
|
1326
1347
|
};
|
|
@@ -1513,22 +1534,6 @@ const MatchCase$1 = 1 << 4; // 16
|
|
|
1513
1534
|
const DetailsExpanded = 1 << 5; // 32
|
|
1514
1535
|
const OpenEditors = 1 << 6; // 64
|
|
1515
1536
|
const UseIgnoreFiles = 1 << 7; // 128
|
|
1516
|
-
|
|
1517
|
-
const hasPreserveCase = flags => {
|
|
1518
|
-
return (flags & PreserveCase$1) === PreserveCase$1;
|
|
1519
|
-
};
|
|
1520
|
-
const hasUseRegularExpression = flags => {
|
|
1521
|
-
return (flags & UseRegularExpression$1) === UseRegularExpression$1;
|
|
1522
|
-
};
|
|
1523
|
-
const hasReplaceExpanded = flags => {
|
|
1524
|
-
return (flags & ReplaceExpanded) === ReplaceExpanded;
|
|
1525
|
-
};
|
|
1526
|
-
const hasMatchWholeWord = flags => {
|
|
1527
|
-
return (flags & MatchWholeWord$1) === MatchWholeWord$1;
|
|
1528
|
-
};
|
|
1529
|
-
const hasMatchCase = flags => {
|
|
1530
|
-
return (flags & MatchCase$1) === MatchCase$1;
|
|
1531
|
-
};
|
|
1532
1537
|
const hasDetailsExpanded = flags => {
|
|
1533
1538
|
return (flags & DetailsExpanded) === DetailsExpanded;
|
|
1534
1539
|
};
|
|
@@ -1641,7 +1646,7 @@ const focusSearchValue$1 = state => {
|
|
|
1641
1646
|
};
|
|
1642
1647
|
|
|
1643
1648
|
const focusSearchValueNext = state => {
|
|
1644
|
-
if (
|
|
1649
|
+
if (state.flags & ReplaceExpanded) {
|
|
1645
1650
|
return focusReplaceValue$1(state);
|
|
1646
1651
|
}
|
|
1647
1652
|
return focusMatchCase$1(state);
|
|
@@ -1654,6 +1659,7 @@ const Tree = 'tree';
|
|
|
1654
1659
|
const TreeItem$1 = 'treeitem';
|
|
1655
1660
|
const ToolBar = 'toolbar';
|
|
1656
1661
|
const Button$2 = 'button';
|
|
1662
|
+
const Alert = 'alert';
|
|
1657
1663
|
|
|
1658
1664
|
const Actions = 'Actions';
|
|
1659
1665
|
const Badge = 'Badge';
|
|
@@ -1687,6 +1693,7 @@ const SearchFieldButton = 'SearchFieldButton';
|
|
|
1687
1693
|
const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
|
|
1688
1694
|
const SearchFieldButtons = 'SearchFieldButtons';
|
|
1689
1695
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
1696
|
+
const SearchFieldError = 'SearchFieldError';
|
|
1690
1697
|
const SearchHeader = 'SearchHeader';
|
|
1691
1698
|
const SearchHeaderDetails = 'SearchHeaderDetails';
|
|
1692
1699
|
const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
|
|
@@ -1694,6 +1701,7 @@ const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
|
|
|
1694
1701
|
const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
|
|
1695
1702
|
const SearchHeaderTop = 'SearchHeaderTop';
|
|
1696
1703
|
const SearchHeaderTopRight = 'SearchHeaderTopRight';
|
|
1704
|
+
const SearchInputError = 'SearchInputError';
|
|
1697
1705
|
const SearchRemove = 'SearchRemove';
|
|
1698
1706
|
const SearchToggleButton = 'SearchToggleButton';
|
|
1699
1707
|
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
@@ -2094,14 +2102,16 @@ const getOutSideButtonsDom = outsideButtons => {
|
|
|
2094
2102
|
postNodes: outsideButtons.flatMap(getSearchFieldButtonVirtualDom)
|
|
2095
2103
|
};
|
|
2096
2104
|
};
|
|
2097
|
-
|
|
2105
|
+
|
|
2106
|
+
const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, outsideButtons, onFocus = '', hasError = false) => {
|
|
2098
2107
|
const {
|
|
2099
2108
|
preNodes,
|
|
2100
2109
|
postNodes
|
|
2101
2110
|
} = getOutSideButtonsDom(outsideButtons);
|
|
2111
|
+
const searchFieldClassName = hasError ? mergeClassNames(SearchField, SearchFieldError) : SearchField;
|
|
2102
2112
|
const dom = [...preNodes, {
|
|
2103
2113
|
type: Div,
|
|
2104
|
-
className:
|
|
2114
|
+
className: searchFieldClassName,
|
|
2105
2115
|
role: None,
|
|
2106
2116
|
childCount: 2
|
|
2107
2117
|
}, {
|
|
@@ -2155,17 +2165,17 @@ const getSearchHeaderDetailsVirtualDom = (flags, message) => {
|
|
|
2155
2165
|
const getInputActionsInput = flags => {
|
|
2156
2166
|
const inside = [{
|
|
2157
2167
|
icon: MaskIconCaseSensitive,
|
|
2158
|
-
checked:
|
|
2168
|
+
checked: Boolean(flags & MatchCase$1),
|
|
2159
2169
|
title: matchCase(),
|
|
2160
2170
|
name: MatchCase
|
|
2161
2171
|
}, {
|
|
2162
2172
|
icon: MaskIconWholeWord,
|
|
2163
|
-
checked:
|
|
2173
|
+
checked: Boolean(flags & MatchWholeWord$1),
|
|
2164
2174
|
title: matchWholeWord(),
|
|
2165
2175
|
name: MatchWholeWord
|
|
2166
2176
|
}, {
|
|
2167
2177
|
icon: MaskIconRegex,
|
|
2168
|
-
checked:
|
|
2178
|
+
checked: Boolean(flags & UseRegularExpression$1),
|
|
2169
2179
|
title: useRegularExpression(),
|
|
2170
2180
|
name: UseRegularExpression
|
|
2171
2181
|
}];
|
|
@@ -2179,7 +2189,7 @@ const getInputActionsInput = flags => {
|
|
|
2179
2189
|
const getInputActionsReplace = flags => {
|
|
2180
2190
|
const inside = [{
|
|
2181
2191
|
icon: MaskIconPreserveCase,
|
|
2182
|
-
checked:
|
|
2192
|
+
checked: Boolean(flags & PreserveCase$1),
|
|
2183
2193
|
title: preserveCase(),
|
|
2184
2194
|
name: PreserveCase
|
|
2185
2195
|
}];
|
|
@@ -2198,21 +2208,21 @@ const getInputActionsReplace = flags => {
|
|
|
2198
2208
|
const getSearchToggleVirtualDom = flags => {
|
|
2199
2209
|
return [{
|
|
2200
2210
|
type: Button,
|
|
2201
|
-
className: mergeClassNames(IconButton, SearchToggleButton,
|
|
2211
|
+
className: mergeClassNames(IconButton, SearchToggleButton, flags & ReplaceExpanded ? SearchToggleButtonExpanded : ''),
|
|
2202
2212
|
title: toggleReplace$1(),
|
|
2203
2213
|
ariaLabel: toggleReplace$1(),
|
|
2204
|
-
ariaExpanded:
|
|
2214
|
+
ariaExpanded: Boolean(flags & ReplaceExpanded),
|
|
2205
2215
|
childCount: 1,
|
|
2206
2216
|
'data-command': 'toggleReplace',
|
|
2207
2217
|
name: ToggleReplace
|
|
2208
2218
|
}, {
|
|
2209
2219
|
type: Div,
|
|
2210
|
-
className: mergeClassNames(MaskIcon,
|
|
2220
|
+
className: mergeClassNames(MaskIcon, flags & ReplaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
|
|
2211
2221
|
childCount: 0
|
|
2212
2222
|
}];
|
|
2213
2223
|
};
|
|
2214
2224
|
|
|
2215
|
-
const getSearchHeaderTopVirtualDom = flags => {
|
|
2225
|
+
const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage = '') => {
|
|
2216
2226
|
const inputActions = getInputActionsInput(flags);
|
|
2217
2227
|
const replaceActions = getInputActionsReplace(flags);
|
|
2218
2228
|
const dom = [{
|
|
@@ -2224,15 +2234,15 @@ const getSearchHeaderTopVirtualDom = flags => {
|
|
|
2224
2234
|
type: Div,
|
|
2225
2235
|
className: SearchHeaderTopRight,
|
|
2226
2236
|
role: None,
|
|
2227
|
-
childCount:
|
|
2228
|
-
}, ...getSearchFieldVirtualDom(SearchValue, 'Search', HandleInput, inputActions.inside, inputActions.outside)];
|
|
2229
|
-
if (
|
|
2237
|
+
childCount: flags & ReplaceExpanded ? 2 : 1
|
|
2238
|
+
}, ...getSearchFieldVirtualDom(SearchValue, 'Search', HandleInput, inputActions.inside, inputActions.outside, '', Boolean(searchInputErrorMessage))];
|
|
2239
|
+
if (flags & ReplaceExpanded) {
|
|
2230
2240
|
dom.push(...getSearchFieldVirtualDom(ReplaceValue, 'Replace', HandleReplaceInput, replaceActions.inside, replaceActions.outside));
|
|
2231
2241
|
}
|
|
2232
2242
|
return dom;
|
|
2233
2243
|
};
|
|
2234
2244
|
|
|
2235
|
-
const getSearchHeaderVirtualDom = (flags, message) => {
|
|
2245
|
+
const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage) => {
|
|
2236
2246
|
const dom = [{
|
|
2237
2247
|
type: Div,
|
|
2238
2248
|
className: SearchHeader,
|
|
@@ -2240,10 +2250,22 @@ const getSearchHeaderVirtualDom = (flags, message) => {
|
|
|
2240
2250
|
childCount: 2,
|
|
2241
2251
|
onClick: HandleHeaderClick,
|
|
2242
2252
|
onFocusIn: HandleHeaderFocusIn
|
|
2243
|
-
}, ...getSearchHeaderTopVirtualDom(flags), ...getSearchHeaderDetailsVirtualDom(flags, message)];
|
|
2253
|
+
}, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage), ...getSearchHeaderDetailsVirtualDom(flags, message)];
|
|
2244
2254
|
return dom;
|
|
2245
2255
|
};
|
|
2246
2256
|
|
|
2257
|
+
const getSearchInputErrorVirtualDom = errorMessage => {
|
|
2258
|
+
if (!errorMessage) {
|
|
2259
|
+
return [];
|
|
2260
|
+
}
|
|
2261
|
+
return [{
|
|
2262
|
+
type: Div,
|
|
2263
|
+
className: SearchInputError,
|
|
2264
|
+
role: Alert,
|
|
2265
|
+
childCount: 1
|
|
2266
|
+
}, text(errorMessage)];
|
|
2267
|
+
};
|
|
2268
|
+
|
|
2247
2269
|
const getBadgeVirtualDom = (className, count) => {
|
|
2248
2270
|
return [{
|
|
2249
2271
|
type: Div,
|
|
@@ -2390,13 +2412,14 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline) => {
|
|
|
2390
2412
|
}, ...visibleItems.flatMap(getSearchResultVirtualDom)];
|
|
2391
2413
|
};
|
|
2392
2414
|
|
|
2393
|
-
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
|
|
2394
|
-
const
|
|
2415
|
+
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage) => {
|
|
2416
|
+
const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
|
|
2417
|
+
const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
|
|
2418
|
+
return [{
|
|
2395
2419
|
type: Div,
|
|
2396
2420
|
className: mergeClassNames(Viewlet, Search$1),
|
|
2397
|
-
childCount
|
|
2398
|
-
}, ...getSearchHeaderVirtualDom(flags, message), ...getSearchResultsVirtualDom(visibleItems, focusOutline)];
|
|
2399
|
-
return dom;
|
|
2421
|
+
childCount
|
|
2422
|
+
}, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline)];
|
|
2400
2423
|
};
|
|
2401
2424
|
|
|
2402
2425
|
const handleError = error => {
|
|
@@ -2430,6 +2453,15 @@ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
|
2430
2453
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
2431
2454
|
};
|
|
2432
2455
|
|
|
2456
|
+
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2457
|
+
const getProtocol$1 = uri => {
|
|
2458
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2459
|
+
if (protocolMatch) {
|
|
2460
|
+
return protocolMatch[1];
|
|
2461
|
+
}
|
|
2462
|
+
return '';
|
|
2463
|
+
};
|
|
2464
|
+
|
|
2433
2465
|
const getTextSearchResultCounts = results => {
|
|
2434
2466
|
let resultCount = 0;
|
|
2435
2467
|
let fileCount = 0;
|
|
@@ -2489,15 +2521,6 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
2489
2521
|
};
|
|
2490
2522
|
};
|
|
2491
2523
|
|
|
2492
|
-
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2493
|
-
const getProtocol$1 = uri => {
|
|
2494
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2495
|
-
if (protocolMatch) {
|
|
2496
|
-
return protocolMatch[1];
|
|
2497
|
-
}
|
|
2498
|
-
return '';
|
|
2499
|
-
};
|
|
2500
|
-
|
|
2501
2524
|
const textSearch$6 = async (scheme, root, query) => {
|
|
2502
2525
|
string(scheme);
|
|
2503
2526
|
string(query);
|
|
@@ -2700,6 +2723,26 @@ const textSearch = async (root, query, options, assetDir, platform) => {
|
|
|
2700
2723
|
return results;
|
|
2701
2724
|
};
|
|
2702
2725
|
|
|
2726
|
+
// Based on https://github.com/microsoft/vscode/blob/ad375c92764b72a1f28f3e1626563e9e41e5c740/src/vs/workbench/contrib/search/browser/searchWidget.ts#L393 by Microsoft (License MIT)
|
|
2727
|
+
|
|
2728
|
+
const validateSearchInput = (value, flags) => {
|
|
2729
|
+
if (value.length === 0) {
|
|
2730
|
+
return '';
|
|
2731
|
+
}
|
|
2732
|
+
if (!(flags & UseRegularExpression$1)) {
|
|
2733
|
+
return '';
|
|
2734
|
+
}
|
|
2735
|
+
try {
|
|
2736
|
+
new RegExp(value, 'u');
|
|
2737
|
+
} catch (error) {
|
|
2738
|
+
if (error && error instanceof Error) {
|
|
2739
|
+
return error.message;
|
|
2740
|
+
}
|
|
2741
|
+
return '';
|
|
2742
|
+
}
|
|
2743
|
+
return '';
|
|
2744
|
+
};
|
|
2745
|
+
|
|
2703
2746
|
const handleUpdate = async (state, update) => {
|
|
2704
2747
|
const partialNewState = {
|
|
2705
2748
|
...state,
|
|
@@ -2713,7 +2756,9 @@ const handleUpdate = async (state, update) => {
|
|
|
2713
2756
|
headerHeight,
|
|
2714
2757
|
flags,
|
|
2715
2758
|
value,
|
|
2716
|
-
threads
|
|
2759
|
+
threads,
|
|
2760
|
+
includeValue,
|
|
2761
|
+
excludeValue
|
|
2717
2762
|
} = partialNewState;
|
|
2718
2763
|
if (isEmptyString(value)) {
|
|
2719
2764
|
return {
|
|
@@ -2725,14 +2770,30 @@ const handleUpdate = async (state, update) => {
|
|
|
2725
2770
|
listItems: [],
|
|
2726
2771
|
matchCount: 0,
|
|
2727
2772
|
message: '',
|
|
2728
|
-
loaded: true
|
|
2773
|
+
loaded: true,
|
|
2774
|
+
searchInputErrorMessage: ''
|
|
2775
|
+
};
|
|
2776
|
+
}
|
|
2777
|
+
const searchInputErrorMessage = validateSearchInput(value, flags);
|
|
2778
|
+
if (searchInputErrorMessage) {
|
|
2779
|
+
return {
|
|
2780
|
+
...partialNewState,
|
|
2781
|
+
searchInputErrorMessage: searchInputErrorMessage
|
|
2729
2782
|
};
|
|
2730
2783
|
}
|
|
2731
2784
|
const root = state.workspacePath;
|
|
2785
|
+
const scheme = getProtocol$1(root);
|
|
2732
2786
|
const results = await textSearch(root, value, {
|
|
2733
2787
|
threads,
|
|
2734
|
-
isCaseSensitive:
|
|
2735
|
-
useRegularExpression:
|
|
2788
|
+
isCaseSensitive: Boolean(flags & MatchCase$1),
|
|
2789
|
+
useRegularExpression: Boolean(flags & UseRegularExpression$1),
|
|
2790
|
+
exclude: excludeValue,
|
|
2791
|
+
include: includeValue,
|
|
2792
|
+
assetDir: state.assetDir,
|
|
2793
|
+
root,
|
|
2794
|
+
query: value,
|
|
2795
|
+
scheme,
|
|
2796
|
+
flags
|
|
2736
2797
|
}, state.assetDir, state.platform);
|
|
2737
2798
|
if (!Array.isArray(results)) {
|
|
2738
2799
|
throw new TypeError('results must be of type array');
|
|
@@ -2766,7 +2827,8 @@ const handleUpdate = async (state, update) => {
|
|
|
2766
2827
|
fileCount,
|
|
2767
2828
|
matchCount: resultCount,
|
|
2768
2829
|
loaded: true,
|
|
2769
|
-
icons
|
|
2830
|
+
icons,
|
|
2831
|
+
searchInputErrorMessage: ''
|
|
2770
2832
|
};
|
|
2771
2833
|
} catch (error) {
|
|
2772
2834
|
handleError(error);
|
|
@@ -2794,6 +2856,16 @@ const noop = state => {
|
|
|
2794
2856
|
return state;
|
|
2795
2857
|
};
|
|
2796
2858
|
|
|
2859
|
+
const getReplacedMessage = (fileCount, replaceCount, replacement) => {
|
|
2860
|
+
if (replaceCount === 1) {
|
|
2861
|
+
return replacedOneOccurrenceInOneFile(replacement);
|
|
2862
|
+
}
|
|
2863
|
+
if (fileCount === 1) {
|
|
2864
|
+
return replacedManyOccurrencesInOneFile(replaceCount, replacement);
|
|
2865
|
+
}
|
|
2866
|
+
return replacedManyOccurrencesInManyFiles(replaceCount, fileCount, replacement);
|
|
2867
|
+
};
|
|
2868
|
+
|
|
2797
2869
|
const getFileName = text => {
|
|
2798
2870
|
// TODO make api stricter so that results always have the same shape
|
|
2799
2871
|
if (text.startsWith('./')) {
|
|
@@ -2844,31 +2916,40 @@ const replaceAll = async state => {
|
|
|
2844
2916
|
const {
|
|
2845
2917
|
workspacePath,
|
|
2846
2918
|
items,
|
|
2847
|
-
replacement
|
|
2919
|
+
replacement,
|
|
2920
|
+
matchCount
|
|
2848
2921
|
} = state;
|
|
2849
2922
|
const bulkEdits = getReplaceElements(items, workspacePath, replacement);
|
|
2850
2923
|
await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
|
|
2851
|
-
|
|
2924
|
+
const fileCount = bulkEdits.length;
|
|
2925
|
+
const message = getReplacedMessage(fileCount, matchCount, replacement);
|
|
2926
|
+
return {
|
|
2927
|
+
...state,
|
|
2928
|
+
items: [],
|
|
2929
|
+
listItems: [],
|
|
2930
|
+
minLineY: 0,
|
|
2931
|
+
maxLineY: 0,
|
|
2932
|
+
message
|
|
2933
|
+
};
|
|
2852
2934
|
};
|
|
2853
2935
|
|
|
2854
2936
|
const toggleSearchFlag = (state, flag) => {
|
|
2855
|
-
return {
|
|
2856
|
-
...state,
|
|
2937
|
+
return handleUpdate(state, {
|
|
2857
2938
|
flags: state.flags ^ flag
|
|
2858
|
-
};
|
|
2939
|
+
});
|
|
2859
2940
|
};
|
|
2860
2941
|
|
|
2861
|
-
const collapseDetails = state => {
|
|
2942
|
+
const collapseDetails = async state => {
|
|
2862
2943
|
return {
|
|
2863
|
-
...toggleSearchFlag(state, DetailsExpanded),
|
|
2944
|
+
...(await toggleSearchFlag(state, DetailsExpanded)),
|
|
2864
2945
|
focus: FocusSearchInput,
|
|
2865
2946
|
focusSource: Script
|
|
2866
2947
|
};
|
|
2867
2948
|
};
|
|
2868
2949
|
|
|
2869
|
-
const expandDetails = state => {
|
|
2950
|
+
const expandDetails = async state => {
|
|
2870
2951
|
return {
|
|
2871
|
-
...toggleSearchFlag(state, DetailsExpanded),
|
|
2952
|
+
...(await toggleSearchFlag(state, DetailsExpanded)),
|
|
2872
2953
|
focus: FocusSearchIncludeInput,
|
|
2873
2954
|
focusSource: Script
|
|
2874
2955
|
};
|
|
@@ -2967,12 +3048,11 @@ const handleIconThemeChange = async state => {
|
|
|
2967
3048
|
};
|
|
2968
3049
|
};
|
|
2969
3050
|
|
|
2970
|
-
const handleIncludeInput = (state, includeValue) => {
|
|
2971
|
-
return {
|
|
2972
|
-
...state,
|
|
3051
|
+
const handleIncludeInput = (state, includeValue, inputSource = Script) => {
|
|
3052
|
+
return handleUpdate(state, {
|
|
2973
3053
|
includeValue,
|
|
2974
|
-
|
|
2975
|
-
};
|
|
3054
|
+
inputSource
|
|
3055
|
+
});
|
|
2976
3056
|
};
|
|
2977
3057
|
|
|
2978
3058
|
const handleInput = (state, value, inputSource = Script) => {
|
|
@@ -3167,6 +3247,12 @@ const getTopHeight = flags => {
|
|
|
3167
3247
|
return 61;
|
|
3168
3248
|
};
|
|
3169
3249
|
|
|
3250
|
+
const addCollapsedPath = (collapsedPaths, path) => {
|
|
3251
|
+
const pathWithDot = `.${path}`;
|
|
3252
|
+
const newCollapsedPaths = [...collapsedPaths, path, pathWithDot];
|
|
3253
|
+
return newCollapsedPaths;
|
|
3254
|
+
};
|
|
3255
|
+
|
|
3170
3256
|
const getFilteredResults = (results, collapsedPaths) => {
|
|
3171
3257
|
if (collapsedPaths.length === 0) {
|
|
3172
3258
|
return results;
|
|
@@ -3195,9 +3281,7 @@ const selectIndexFile = (state, searchResult, index) => {
|
|
|
3195
3281
|
maxLineY
|
|
3196
3282
|
} = state;
|
|
3197
3283
|
const path = getAbsolutePath(searchResult.text);
|
|
3198
|
-
|
|
3199
|
-
const pathWithDot = `.${path}`;
|
|
3200
|
-
const newCollapsedPaths = [...collapsedPaths, path, pathWithDot];
|
|
3284
|
+
const newCollapsedPaths = addCollapsedPath(collapsedPaths, path);
|
|
3201
3285
|
const filteredResults = getFilteredResults(items, collapsedPaths);
|
|
3202
3286
|
const newMaxLineY = Math.min(maxLineY, filteredResults.length);
|
|
3203
3287
|
return {
|
|
@@ -3492,12 +3576,12 @@ const getFocusSelector = focusKey => {
|
|
|
3492
3576
|
|
|
3493
3577
|
const renderItems = {
|
|
3494
3578
|
isEqual(oldState, newState) {
|
|
3495
|
-
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;
|
|
3579
|
+
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;
|
|
3496
3580
|
},
|
|
3497
3581
|
apply(oldState, newState) {
|
|
3498
3582
|
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex);
|
|
3499
3583
|
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3500
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
|
|
3584
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage);
|
|
3501
3585
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3502
3586
|
}
|
|
3503
3587
|
};
|
|
@@ -3531,8 +3615,7 @@ const renderIncludeValue = {
|
|
|
3531
3615
|
return oldState.includeValue === newState.includeValue || newState.inputSource === User;
|
|
3532
3616
|
},
|
|
3533
3617
|
apply(oldState, newState) {
|
|
3534
|
-
|
|
3535
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, selector];
|
|
3618
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, `[name=${FilesToInclude}]`];
|
|
3536
3619
|
}
|
|
3537
3620
|
};
|
|
3538
3621
|
const renderExcludeValue = {
|
|
@@ -3540,8 +3623,7 @@ const renderExcludeValue = {
|
|
|
3540
3623
|
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
3541
3624
|
},
|
|
3542
3625
|
apply(oldState, newState) {
|
|
3543
|
-
|
|
3544
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, selector];
|
|
3626
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
|
|
3545
3627
|
}
|
|
3546
3628
|
};
|
|
3547
3629
|
const render = [renderItems, renderValue, renderIncludeValue, renderExcludeValue, renderReplacement, renderFocus];
|
|
@@ -3666,7 +3748,7 @@ const focusSearchValue = state => {
|
|
|
3666
3748
|
return focusElement(state, FocusSearchInput);
|
|
3667
3749
|
};
|
|
3668
3750
|
const focusMatchCasePrevious = state => {
|
|
3669
|
-
if (
|
|
3751
|
+
if (state.flags & ReplaceExpanded) {
|
|
3670
3752
|
return focusReplaceValue(state);
|
|
3671
3753
|
}
|
|
3672
3754
|
return focusSearchValue(state);
|
|
@@ -3816,6 +3898,7 @@ const commandMap = {
|
|
|
3816
3898
|
'TextSearch.refresh': wrapCommand(refresh),
|
|
3817
3899
|
'TextSearch.replaceAll': wrapCommand(replaceAll),
|
|
3818
3900
|
'TextSearch.replaceAllAndPrompt': wrapCommand(replaceAllAndPrompt),
|
|
3901
|
+
'TextSearch.selectIndex': wrapCommand(selectIndex),
|
|
3819
3902
|
'TextSearch.submit': wrapCommand(submit),
|
|
3820
3903
|
'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
3821
3904
|
'TextSearch.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord),
|