@lvce-editor/text-search-worker 3.23.0 → 3.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/textSearchWorkerMain.js +199 -126
- package/package.json +1 -1
|
@@ -598,10 +598,10 @@ const create$4 = (method, params) => {
|
|
|
598
598
|
};
|
|
599
599
|
};
|
|
600
600
|
const callbacks = Object.create(null);
|
|
601
|
-
const set$
|
|
601
|
+
const set$2 = (id, fn) => {
|
|
602
602
|
callbacks[id] = fn;
|
|
603
603
|
};
|
|
604
|
-
const get$
|
|
604
|
+
const get$2 = id => {
|
|
605
605
|
return callbacks[id];
|
|
606
606
|
};
|
|
607
607
|
const remove$1 = id => {
|
|
@@ -617,7 +617,7 @@ const registerPromise = () => {
|
|
|
617
617
|
resolve,
|
|
618
618
|
promise
|
|
619
619
|
} = Promise.withResolvers();
|
|
620
|
-
set$
|
|
620
|
+
set$2(id, resolve);
|
|
621
621
|
return {
|
|
622
622
|
id,
|
|
623
623
|
promise
|
|
@@ -774,7 +774,7 @@ const warn = (...args) => {
|
|
|
774
774
|
console.warn(...args);
|
|
775
775
|
};
|
|
776
776
|
const resolve = (id, response) => {
|
|
777
|
-
const fn = get$
|
|
777
|
+
const fn = get$2(id);
|
|
778
778
|
if (!fn) {
|
|
779
779
|
console.log(response);
|
|
780
780
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -1085,22 +1085,26 @@ const clearSearchResults$1 = state => {
|
|
|
1085
1085
|
};
|
|
1086
1086
|
};
|
|
1087
1087
|
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1088
|
+
const RendererWorker = 1;
|
|
1089
|
+
|
|
1090
|
+
const rpcs = Object.create(null);
|
|
1091
|
+
const set$1 = (id, rpc) => {
|
|
1092
|
+
rpcs[id] = rpc;
|
|
1093
|
+
};
|
|
1094
|
+
const get$1 = id => {
|
|
1095
|
+
return rpcs[id];
|
|
1090
1096
|
};
|
|
1097
|
+
|
|
1091
1098
|
const invoke$2 = (method, ...params) => {
|
|
1092
|
-
const rpc =
|
|
1099
|
+
const rpc = get$1(RendererWorker);
|
|
1093
1100
|
// @ts-ignore
|
|
1094
1101
|
return rpc.invoke(method, ...params);
|
|
1095
1102
|
};
|
|
1096
1103
|
const invokeAndTransfer = (method, ...params) => {
|
|
1097
|
-
const rpc =
|
|
1104
|
+
const rpc = get$1(RendererWorker);
|
|
1098
1105
|
// @ts-ignore
|
|
1099
1106
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1100
1107
|
};
|
|
1101
|
-
const setRpc = rpc => {
|
|
1102
|
-
state$2.rpc = rpc;
|
|
1103
|
-
};
|
|
1104
1108
|
|
|
1105
1109
|
const copy = async state => {
|
|
1106
1110
|
const {
|
|
@@ -1192,7 +1196,8 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1192
1196
|
handleOffset: 0,
|
|
1193
1197
|
focusSource: User,
|
|
1194
1198
|
flags: 0,
|
|
1195
|
-
platform
|
|
1199
|
+
platform,
|
|
1200
|
+
searchInputErrorMessage: ''
|
|
1196
1201
|
};
|
|
1197
1202
|
set(uid, state, state);
|
|
1198
1203
|
return state;
|
|
@@ -1200,21 +1205,6 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
1200
1205
|
|
|
1201
1206
|
// based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
|
|
1202
1207
|
|
|
1203
|
-
const insertInto = (array, start, newItems) => {
|
|
1204
|
-
const originalLength = array.length;
|
|
1205
|
-
const newItemsLength = newItems.length;
|
|
1206
|
-
array.length = originalLength + newItemsLength;
|
|
1207
|
-
// Move the items after the start index, start from the end so that we don't overwrite any value.
|
|
1208
|
-
for (let i = originalLength - 1; i >= start; i--) {
|
|
1209
|
-
array[i + newItemsLength] = array[i];
|
|
1210
|
-
}
|
|
1211
|
-
for (let i = 0; i < newItemsLength; i++) {
|
|
1212
|
-
array[i + start] = newItems[i];
|
|
1213
|
-
}
|
|
1214
|
-
};
|
|
1215
|
-
const push = (array, newItems) => {
|
|
1216
|
-
insertInto(array, array.length, newItems);
|
|
1217
|
-
};
|
|
1218
1208
|
const isLastIndex = (array, index) => {
|
|
1219
1209
|
return index === array.length - 1;
|
|
1220
1210
|
};
|
|
@@ -1256,6 +1246,8 @@ const PreserveCase$2 = 'Preserve Case';
|
|
|
1256
1246
|
const Refresh$1 = 'Refresh';
|
|
1257
1247
|
const Replace = 'Replace';
|
|
1258
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}'";
|
|
1259
1251
|
const ToggleReplace$1 = 'Toggle Replace';
|
|
1260
1252
|
const UseRegularExpression$2 = 'Use Regular Expression';
|
|
1261
1253
|
const ViewAsTree = 'View as Tree';
|
|
@@ -1332,6 +1324,24 @@ const confirmReplaceManyOccurrencesInManyFilesNoValue = (matchCount, fileCount)
|
|
|
1332
1324
|
PH2: fileCount
|
|
1333
1325
|
});
|
|
1334
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
|
+
};
|
|
1335
1345
|
const replaceAll$1 = () => {
|
|
1336
1346
|
return i18nString(ReplaceAll$1);
|
|
1337
1347
|
};
|
|
@@ -1524,22 +1534,6 @@ const MatchCase$1 = 1 << 4; // 16
|
|
|
1524
1534
|
const DetailsExpanded = 1 << 5; // 32
|
|
1525
1535
|
const OpenEditors = 1 << 6; // 64
|
|
1526
1536
|
const UseIgnoreFiles = 1 << 7; // 128
|
|
1527
|
-
|
|
1528
|
-
const hasPreserveCase = flags => {
|
|
1529
|
-
return (flags & PreserveCase$1) === PreserveCase$1;
|
|
1530
|
-
};
|
|
1531
|
-
const hasUseRegularExpression = flags => {
|
|
1532
|
-
return (flags & UseRegularExpression$1) === UseRegularExpression$1;
|
|
1533
|
-
};
|
|
1534
|
-
const hasReplaceExpanded = flags => {
|
|
1535
|
-
return (flags & ReplaceExpanded) === ReplaceExpanded;
|
|
1536
|
-
};
|
|
1537
|
-
const hasMatchWholeWord = flags => {
|
|
1538
|
-
return (flags & MatchWholeWord$1) === MatchWholeWord$1;
|
|
1539
|
-
};
|
|
1540
|
-
const hasMatchCase = flags => {
|
|
1541
|
-
return (flags & MatchCase$1) === MatchCase$1;
|
|
1542
|
-
};
|
|
1543
1537
|
const hasDetailsExpanded = flags => {
|
|
1544
1538
|
return (flags & DetailsExpanded) === DetailsExpanded;
|
|
1545
1539
|
};
|
|
@@ -1652,7 +1646,7 @@ const focusSearchValue$1 = state => {
|
|
|
1652
1646
|
};
|
|
1653
1647
|
|
|
1654
1648
|
const focusSearchValueNext = state => {
|
|
1655
|
-
if (
|
|
1649
|
+
if (state.flags & ReplaceExpanded) {
|
|
1656
1650
|
return focusReplaceValue$1(state);
|
|
1657
1651
|
}
|
|
1658
1652
|
return focusMatchCase$1(state);
|
|
@@ -1665,6 +1659,7 @@ const Tree = 'tree';
|
|
|
1665
1659
|
const TreeItem$1 = 'treeitem';
|
|
1666
1660
|
const ToolBar = 'toolbar';
|
|
1667
1661
|
const Button$2 = 'button';
|
|
1662
|
+
const Alert = 'alert';
|
|
1668
1663
|
|
|
1669
1664
|
const Actions = 'Actions';
|
|
1670
1665
|
const Badge = 'Badge';
|
|
@@ -1678,6 +1673,7 @@ const Highlight = 'Highlight';
|
|
|
1678
1673
|
const HighlightDeleted = 'HighlightDeleted';
|
|
1679
1674
|
const HighlightInserted = 'HighlightInserted';
|
|
1680
1675
|
const IconButton = 'IconButton';
|
|
1676
|
+
const SearchInputError = 'SearchInputError';
|
|
1681
1677
|
const Label = 'Label';
|
|
1682
1678
|
const List = 'List';
|
|
1683
1679
|
const MaskIcon = 'MaskIcon';
|
|
@@ -2166,17 +2162,17 @@ const getSearchHeaderDetailsVirtualDom = (flags, message) => {
|
|
|
2166
2162
|
const getInputActionsInput = flags => {
|
|
2167
2163
|
const inside = [{
|
|
2168
2164
|
icon: MaskIconCaseSensitive,
|
|
2169
|
-
checked:
|
|
2165
|
+
checked: Boolean(flags & MatchCase$1),
|
|
2170
2166
|
title: matchCase(),
|
|
2171
2167
|
name: MatchCase
|
|
2172
2168
|
}, {
|
|
2173
2169
|
icon: MaskIconWholeWord,
|
|
2174
|
-
checked:
|
|
2170
|
+
checked: Boolean(flags & MatchWholeWord$1),
|
|
2175
2171
|
title: matchWholeWord(),
|
|
2176
2172
|
name: MatchWholeWord
|
|
2177
2173
|
}, {
|
|
2178
2174
|
icon: MaskIconRegex,
|
|
2179
|
-
checked:
|
|
2175
|
+
checked: Boolean(flags & UseRegularExpression$1),
|
|
2180
2176
|
title: useRegularExpression(),
|
|
2181
2177
|
name: UseRegularExpression
|
|
2182
2178
|
}];
|
|
@@ -2190,7 +2186,7 @@ const getInputActionsInput = flags => {
|
|
|
2190
2186
|
const getInputActionsReplace = flags => {
|
|
2191
2187
|
const inside = [{
|
|
2192
2188
|
icon: MaskIconPreserveCase,
|
|
2193
|
-
checked:
|
|
2189
|
+
checked: Boolean(flags & PreserveCase$1),
|
|
2194
2190
|
title: preserveCase(),
|
|
2195
2191
|
name: PreserveCase
|
|
2196
2192
|
}];
|
|
@@ -2209,16 +2205,16 @@ const getInputActionsReplace = flags => {
|
|
|
2209
2205
|
const getSearchToggleVirtualDom = flags => {
|
|
2210
2206
|
return [{
|
|
2211
2207
|
type: Button,
|
|
2212
|
-
className: mergeClassNames(IconButton, SearchToggleButton,
|
|
2208
|
+
className: mergeClassNames(IconButton, SearchToggleButton, flags & ReplaceExpanded ? SearchToggleButtonExpanded : ''),
|
|
2213
2209
|
title: toggleReplace$1(),
|
|
2214
2210
|
ariaLabel: toggleReplace$1(),
|
|
2215
|
-
ariaExpanded:
|
|
2211
|
+
ariaExpanded: Boolean(flags & ReplaceExpanded),
|
|
2216
2212
|
childCount: 1,
|
|
2217
2213
|
'data-command': 'toggleReplace',
|
|
2218
2214
|
name: ToggleReplace
|
|
2219
2215
|
}, {
|
|
2220
2216
|
type: Div,
|
|
2221
|
-
className: mergeClassNames(MaskIcon,
|
|
2217
|
+
className: mergeClassNames(MaskIcon, flags & ReplaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
|
|
2222
2218
|
childCount: 0
|
|
2223
2219
|
}];
|
|
2224
2220
|
};
|
|
@@ -2235,9 +2231,9 @@ const getSearchHeaderTopVirtualDom = flags => {
|
|
|
2235
2231
|
type: Div,
|
|
2236
2232
|
className: SearchHeaderTopRight,
|
|
2237
2233
|
role: None,
|
|
2238
|
-
childCount:
|
|
2234
|
+
childCount: flags & ReplaceExpanded ? 2 : 1
|
|
2239
2235
|
}, ...getSearchFieldVirtualDom(SearchValue, 'Search', HandleInput, inputActions.inside, inputActions.outside)];
|
|
2240
|
-
if (
|
|
2236
|
+
if (flags & ReplaceExpanded) {
|
|
2241
2237
|
dom.push(...getSearchFieldVirtualDom(ReplaceValue, 'Replace', HandleReplaceInput, replaceActions.inside, replaceActions.outside));
|
|
2242
2238
|
}
|
|
2243
2239
|
return dom;
|
|
@@ -2255,6 +2251,18 @@ const getSearchHeaderVirtualDom = (flags, message) => {
|
|
|
2255
2251
|
return dom;
|
|
2256
2252
|
};
|
|
2257
2253
|
|
|
2254
|
+
const getSearchInputErrorVirtualDom = errorMessage => {
|
|
2255
|
+
if (!errorMessage) {
|
|
2256
|
+
return [];
|
|
2257
|
+
}
|
|
2258
|
+
return [{
|
|
2259
|
+
type: Div,
|
|
2260
|
+
className: SearchInputError,
|
|
2261
|
+
role: Alert,
|
|
2262
|
+
childCount: 1
|
|
2263
|
+
}, text(errorMessage)];
|
|
2264
|
+
};
|
|
2265
|
+
|
|
2258
2266
|
const getBadgeVirtualDom = (className, count) => {
|
|
2259
2267
|
return [{
|
|
2260
2268
|
type: Div,
|
|
@@ -2401,13 +2409,14 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline) => {
|
|
|
2401
2409
|
}, ...visibleItems.flatMap(getSearchResultVirtualDom)];
|
|
2402
2410
|
};
|
|
2403
2411
|
|
|
2404
|
-
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline) => {
|
|
2405
|
-
const
|
|
2412
|
+
const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage) => {
|
|
2413
|
+
const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
|
|
2414
|
+
const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
|
|
2415
|
+
return [{
|
|
2406
2416
|
type: Div,
|
|
2407
2417
|
className: mergeClassNames(Viewlet, Search$1),
|
|
2408
|
-
childCount
|
|
2409
|
-
}, ...getSearchHeaderVirtualDom(flags, message), ...getSearchResultsVirtualDom(visibleItems, focusOutline)];
|
|
2410
|
-
return dom;
|
|
2418
|
+
childCount
|
|
2419
|
+
}, ...getSearchHeaderVirtualDom(flags, message), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline)];
|
|
2411
2420
|
};
|
|
2412
2421
|
|
|
2413
2422
|
const handleError = error => {
|
|
@@ -2441,6 +2450,15 @@ const getNumberOfVisibleItems = (listHeight, itemHeight) => {
|
|
|
2441
2450
|
return Math.ceil(listHeight / itemHeight) + 1;
|
|
2442
2451
|
};
|
|
2443
2452
|
|
|
2453
|
+
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2454
|
+
const getProtocol$1 = uri => {
|
|
2455
|
+
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2456
|
+
if (protocolMatch) {
|
|
2457
|
+
return protocolMatch[1];
|
|
2458
|
+
}
|
|
2459
|
+
return '';
|
|
2460
|
+
};
|
|
2461
|
+
|
|
2444
2462
|
const getTextSearchResultCounts = results => {
|
|
2445
2463
|
let resultCount = 0;
|
|
2446
2464
|
let fileCount = 0;
|
|
@@ -2500,15 +2518,6 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
2500
2518
|
};
|
|
2501
2519
|
};
|
|
2502
2520
|
|
|
2503
|
-
const RE_PROTOCOL = /^([a-z-\d]+):\/\//;
|
|
2504
|
-
const getProtocol$1 = uri => {
|
|
2505
|
-
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2506
|
-
if (protocolMatch) {
|
|
2507
|
-
return protocolMatch[1];
|
|
2508
|
-
}
|
|
2509
|
-
return '';
|
|
2510
|
-
};
|
|
2511
|
-
|
|
2512
2521
|
const textSearch$6 = async (scheme, root, query) => {
|
|
2513
2522
|
string(scheme);
|
|
2514
2523
|
string(query);
|
|
@@ -2711,6 +2720,26 @@ const textSearch = async (root, query, options, assetDir, platform) => {
|
|
|
2711
2720
|
return results;
|
|
2712
2721
|
};
|
|
2713
2722
|
|
|
2723
|
+
// Based on https://github.com/microsoft/vscode/blob/ad375c92764b72a1f28f3e1626563e9e41e5c740/src/vs/workbench/contrib/search/browser/searchWidget.ts#L393 by Microsoft (License MIT)
|
|
2724
|
+
|
|
2725
|
+
const validateSearchInput = (value, flags) => {
|
|
2726
|
+
if (value.length === 0) {
|
|
2727
|
+
return '';
|
|
2728
|
+
}
|
|
2729
|
+
if (!(flags & UseRegularExpression$1)) {
|
|
2730
|
+
return '';
|
|
2731
|
+
}
|
|
2732
|
+
try {
|
|
2733
|
+
new RegExp(value, 'u');
|
|
2734
|
+
} catch (error) {
|
|
2735
|
+
if (error && error instanceof Error) {
|
|
2736
|
+
return error.message;
|
|
2737
|
+
}
|
|
2738
|
+
return '';
|
|
2739
|
+
}
|
|
2740
|
+
return '';
|
|
2741
|
+
};
|
|
2742
|
+
|
|
2714
2743
|
const handleUpdate = async (state, update) => {
|
|
2715
2744
|
const partialNewState = {
|
|
2716
2745
|
...state,
|
|
@@ -2724,7 +2753,9 @@ const handleUpdate = async (state, update) => {
|
|
|
2724
2753
|
headerHeight,
|
|
2725
2754
|
flags,
|
|
2726
2755
|
value,
|
|
2727
|
-
threads
|
|
2756
|
+
threads,
|
|
2757
|
+
includeValue,
|
|
2758
|
+
excludeValue
|
|
2728
2759
|
} = partialNewState;
|
|
2729
2760
|
if (isEmptyString(value)) {
|
|
2730
2761
|
return {
|
|
@@ -2736,14 +2767,30 @@ const handleUpdate = async (state, update) => {
|
|
|
2736
2767
|
listItems: [],
|
|
2737
2768
|
matchCount: 0,
|
|
2738
2769
|
message: '',
|
|
2739
|
-
loaded: true
|
|
2770
|
+
loaded: true,
|
|
2771
|
+
searchInputErrorMessage: ''
|
|
2772
|
+
};
|
|
2773
|
+
}
|
|
2774
|
+
const searchInputErrorMessage = validateSearchInput(value, flags);
|
|
2775
|
+
if (searchInputErrorMessage) {
|
|
2776
|
+
return {
|
|
2777
|
+
...partialNewState,
|
|
2778
|
+
searchInputErrorMessage: searchInputErrorMessage
|
|
2740
2779
|
};
|
|
2741
2780
|
}
|
|
2742
2781
|
const root = state.workspacePath;
|
|
2782
|
+
const scheme = getProtocol$1(root);
|
|
2743
2783
|
const results = await textSearch(root, value, {
|
|
2744
2784
|
threads,
|
|
2745
|
-
isCaseSensitive:
|
|
2746
|
-
useRegularExpression:
|
|
2785
|
+
isCaseSensitive: Boolean(flags & MatchCase$1),
|
|
2786
|
+
useRegularExpression: Boolean(flags & UseRegularExpression$1),
|
|
2787
|
+
exclude: excludeValue,
|
|
2788
|
+
include: includeValue,
|
|
2789
|
+
assetDir: state.assetDir,
|
|
2790
|
+
root,
|
|
2791
|
+
query: value,
|
|
2792
|
+
scheme,
|
|
2793
|
+
flags
|
|
2747
2794
|
}, state.assetDir, state.platform);
|
|
2748
2795
|
if (!Array.isArray(results)) {
|
|
2749
2796
|
throw new TypeError('results must be of type array');
|
|
@@ -2805,70 +2852,100 @@ const noop = state => {
|
|
|
2805
2852
|
return state;
|
|
2806
2853
|
};
|
|
2807
2854
|
|
|
2808
|
-
const
|
|
2809
|
-
|
|
2810
|
-
|
|
2811
|
-
|
|
2812
|
-
|
|
2813
|
-
|
|
2814
|
-
|
|
2855
|
+
const getReplacedMessage = (fileCount, replaceCount, replacement) => {
|
|
2856
|
+
if (replaceCount === 1) {
|
|
2857
|
+
return replacedOneOccurrenceInOneFile(replacement);
|
|
2858
|
+
}
|
|
2859
|
+
if (fileCount === 1) {
|
|
2860
|
+
return replacedManyOccurrencesInOneFile(replaceCount, replacement);
|
|
2861
|
+
}
|
|
2862
|
+
return replacedManyOccurrencesInManyFiles(replaceCount, fileCount, replacement);
|
|
2863
|
+
};
|
|
2864
|
+
|
|
2865
|
+
const getFileName = text => {
|
|
2866
|
+
// TODO make api stricter so that results always have the same shape
|
|
2867
|
+
if (text.startsWith('./')) {
|
|
2868
|
+
return text.slice(2);
|
|
2869
|
+
}
|
|
2870
|
+
return text;
|
|
2871
|
+
};
|
|
2872
|
+
|
|
2873
|
+
const getReplaceElements = (items, workspacePath, replacement) => {
|
|
2874
|
+
let element = {
|
|
2875
|
+
uri: '',
|
|
2876
|
+
changes: []
|
|
2877
|
+
};
|
|
2878
|
+
const bulkChanges = [];
|
|
2879
|
+
let changes = [];
|
|
2880
|
+
// TODO simplify code by first matching files with their elements, then creating bulk edits
|
|
2881
|
+
for (const match of items) {
|
|
2815
2882
|
const {
|
|
2816
2883
|
type,
|
|
2817
|
-
text
|
|
2884
|
+
text,
|
|
2885
|
+
lineNumber,
|
|
2886
|
+
end,
|
|
2887
|
+
start
|
|
2818
2888
|
} = match;
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2889
|
+
if (type === File) {
|
|
2890
|
+
changes = [];
|
|
2891
|
+
const fileName = getFileName(text);
|
|
2892
|
+
const absolutePath = `${workspacePath}/${fileName}`;
|
|
2893
|
+
element = {
|
|
2894
|
+
uri: absolutePath,
|
|
2895
|
+
changes
|
|
2896
|
+
};
|
|
2897
|
+
bulkChanges.push(element);
|
|
2898
|
+
} else {
|
|
2899
|
+
changes.push({
|
|
2900
|
+
text: replacement,
|
|
2901
|
+
startRowIndex: lineNumber - 1,
|
|
2902
|
+
startColumnIndex: start,
|
|
2903
|
+
endRowIndex: lineNumber,
|
|
2904
|
+
endColumnIndex: end
|
|
2905
|
+
});
|
|
2830
2906
|
}
|
|
2831
2907
|
}
|
|
2832
|
-
|
|
2833
|
-
push(ranges, currentRanges);
|
|
2834
|
-
return {
|
|
2835
|
-
files,
|
|
2836
|
-
ranges: ranges.slice(1)
|
|
2837
|
-
};
|
|
2908
|
+
return bulkChanges;
|
|
2838
2909
|
};
|
|
2839
2910
|
|
|
2840
2911
|
const replaceAll = async state => {
|
|
2841
2912
|
const {
|
|
2842
2913
|
workspacePath,
|
|
2843
2914
|
items,
|
|
2844
|
-
replacement
|
|
2915
|
+
replacement,
|
|
2916
|
+
matchCount
|
|
2845
2917
|
} = state;
|
|
2846
|
-
const
|
|
2847
|
-
|
|
2848
|
-
|
|
2849
|
-
|
|
2850
|
-
|
|
2851
|
-
|
|
2918
|
+
const bulkEdits = getReplaceElements(items, workspacePath, replacement);
|
|
2919
|
+
await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
|
|
2920
|
+
const fileCount = bulkEdits.length;
|
|
2921
|
+
const message = getReplacedMessage(fileCount, matchCount, replacement);
|
|
2922
|
+
return {
|
|
2923
|
+
...state,
|
|
2924
|
+
items: [],
|
|
2925
|
+
listItems: [],
|
|
2926
|
+
minLineY: 0,
|
|
2927
|
+
maxLineY: 0,
|
|
2928
|
+
message
|
|
2929
|
+
};
|
|
2852
2930
|
};
|
|
2853
2931
|
|
|
2854
2932
|
const toggleSearchFlag = (state, flag) => {
|
|
2855
|
-
return {
|
|
2856
|
-
...state,
|
|
2933
|
+
return handleUpdate(state, {
|
|
2857
2934
|
flags: state.flags ^ flag
|
|
2858
|
-
};
|
|
2935
|
+
});
|
|
2859
2936
|
};
|
|
2860
2937
|
|
|
2861
|
-
const collapseDetails = state => {
|
|
2938
|
+
const collapseDetails = async state => {
|
|
2862
2939
|
return {
|
|
2863
|
-
...toggleSearchFlag(state, DetailsExpanded),
|
|
2940
|
+
...(await toggleSearchFlag(state, DetailsExpanded)),
|
|
2864
2941
|
focus: FocusSearchInput,
|
|
2865
2942
|
focusSource: Script
|
|
2866
2943
|
};
|
|
2867
2944
|
};
|
|
2868
2945
|
|
|
2869
|
-
const expandDetails = state => {
|
|
2946
|
+
const expandDetails = async state => {
|
|
2870
2947
|
return {
|
|
2871
|
-
...toggleSearchFlag(state, DetailsExpanded),
|
|
2948
|
+
...(await toggleSearchFlag(state, DetailsExpanded)),
|
|
2872
2949
|
focus: FocusSearchIncludeInput,
|
|
2873
2950
|
focusSource: Script
|
|
2874
2951
|
};
|
|
@@ -2967,12 +3044,11 @@ const handleIconThemeChange = async state => {
|
|
|
2967
3044
|
};
|
|
2968
3045
|
};
|
|
2969
3046
|
|
|
2970
|
-
const handleIncludeInput = (state, includeValue) => {
|
|
2971
|
-
return {
|
|
2972
|
-
...state,
|
|
3047
|
+
const handleIncludeInput = (state, includeValue, inputSource = Script) => {
|
|
3048
|
+
return handleUpdate(state, {
|
|
2973
3049
|
includeValue,
|
|
2974
|
-
|
|
2975
|
-
};
|
|
3050
|
+
inputSource
|
|
3051
|
+
});
|
|
2976
3052
|
};
|
|
2977
3053
|
|
|
2978
3054
|
const handleInput = (state, value, inputSource = Script) => {
|
|
@@ -3492,12 +3568,12 @@ const getFocusSelector = focusKey => {
|
|
|
3492
3568
|
|
|
3493
3569
|
const renderItems = {
|
|
3494
3570
|
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;
|
|
3571
|
+
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
3572
|
},
|
|
3497
3573
|
apply(oldState, newState) {
|
|
3498
3574
|
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex);
|
|
3499
3575
|
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3500
|
-
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
|
|
3576
|
+
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline, newState.searchInputErrorMessage);
|
|
3501
3577
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
3502
3578
|
}
|
|
3503
3579
|
};
|
|
@@ -3515,7 +3591,7 @@ const renderValue = {
|
|
|
3515
3591
|
return oldState.value === newState.value || newState.inputSource === User;
|
|
3516
3592
|
},
|
|
3517
3593
|
apply(oldState, newState) {
|
|
3518
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.value,
|
|
3594
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.value, `[name="${SearchValue}"]`];
|
|
3519
3595
|
}
|
|
3520
3596
|
};
|
|
3521
3597
|
const renderReplacement = {
|
|
@@ -3523,8 +3599,7 @@ const renderReplacement = {
|
|
|
3523
3599
|
return oldState.replacement === newState.replacement || newState.inputSource === User;
|
|
3524
3600
|
},
|
|
3525
3601
|
apply(oldState, newState) {
|
|
3526
|
-
|
|
3527
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, selector];
|
|
3602
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.replacement, `[name=${ReplaceValue}]`];
|
|
3528
3603
|
}
|
|
3529
3604
|
};
|
|
3530
3605
|
const renderIncludeValue = {
|
|
@@ -3532,8 +3607,7 @@ const renderIncludeValue = {
|
|
|
3532
3607
|
return oldState.includeValue === newState.includeValue || newState.inputSource === User;
|
|
3533
3608
|
},
|
|
3534
3609
|
apply(oldState, newState) {
|
|
3535
|
-
|
|
3536
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, selector];
|
|
3610
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.includeValue, `[name=${FilesToInclude}]`];
|
|
3537
3611
|
}
|
|
3538
3612
|
};
|
|
3539
3613
|
const renderExcludeValue = {
|
|
@@ -3541,8 +3615,7 @@ const renderExcludeValue = {
|
|
|
3541
3615
|
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
3542
3616
|
},
|
|
3543
3617
|
apply(oldState, newState) {
|
|
3544
|
-
|
|
3545
|
-
return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, selector];
|
|
3618
|
+
return ['Viewlet.send', newState.uid, 'setValue', newState.excludeValue, `[name=${FilesToExclude}]`];
|
|
3546
3619
|
}
|
|
3547
3620
|
};
|
|
3548
3621
|
const render = [renderItems, renderValue, renderIncludeValue, renderExcludeValue, renderReplacement, renderFocus];
|
|
@@ -3667,7 +3740,7 @@ const focusSearchValue = state => {
|
|
|
3667
3740
|
return focusElement(state, FocusSearchInput);
|
|
3668
3741
|
};
|
|
3669
3742
|
const focusMatchCasePrevious = state => {
|
|
3670
|
-
if (
|
|
3743
|
+
if (state.flags & ReplaceExpanded) {
|
|
3671
3744
|
return focusReplaceValue(state);
|
|
3672
3745
|
}
|
|
3673
3746
|
return focusSearchValue(state);
|
|
@@ -3841,7 +3914,7 @@ const listen = async () => {
|
|
|
3841
3914
|
const rpc = await WebWorkerRpcClient.create({
|
|
3842
3915
|
commandMap: commandMap
|
|
3843
3916
|
});
|
|
3844
|
-
|
|
3917
|
+
set$1(RendererWorker, rpc);
|
|
3845
3918
|
};
|
|
3846
3919
|
|
|
3847
3920
|
const main = async () => {
|