@lvce-editor/text-search-worker 2.7.0 → 2.9.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 +202 -71
- package/package.json +1 -1
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const commands = Object.create(null);
|
|
2
|
-
const registerCommand = (key, fn) => {
|
|
3
|
-
commands[key] = fn;
|
|
4
|
-
};
|
|
5
2
|
const register = commandMap => {
|
|
6
|
-
|
|
7
|
-
registerCommand(key, value);
|
|
8
|
-
}
|
|
3
|
+
Object.assign(commands, commandMap);
|
|
9
4
|
};
|
|
10
5
|
const getCommand = key => {
|
|
11
6
|
return commands[key];
|
|
@@ -30,9 +25,6 @@ const clearSearchResults$1 = state => {
|
|
|
30
25
|
};
|
|
31
26
|
|
|
32
27
|
const state$3 = {
|
|
33
|
-
/**
|
|
34
|
-
* @type {any}
|
|
35
|
-
*/
|
|
36
28
|
ipc: undefined
|
|
37
29
|
};
|
|
38
30
|
const get$2 = () => {
|
|
@@ -468,7 +460,7 @@ const FocusSearchWholeWord = 34;
|
|
|
468
460
|
const FocusSearchReplaceAll = 35;
|
|
469
461
|
const FocusSearchPreserveCase = 36;
|
|
470
462
|
|
|
471
|
-
const create = (uid, x, y, width, height, workspacePath) => {
|
|
463
|
+
const create = (uid, x, y, width, height, workspacePath, assetDir) => {
|
|
472
464
|
const state = {
|
|
473
465
|
uid,
|
|
474
466
|
searchResults: [],
|
|
@@ -505,12 +497,13 @@ const create = (uid, x, y, width, height, workspacePath) => {
|
|
|
505
497
|
message: '',
|
|
506
498
|
collapsedPaths: [],
|
|
507
499
|
icons: [],
|
|
508
|
-
assetDir
|
|
500
|
+
assetDir,
|
|
509
501
|
deltaY: 0,
|
|
510
502
|
finalDeltaY: 0,
|
|
511
503
|
focused: false,
|
|
512
504
|
focusedIndex: -1,
|
|
513
|
-
handleOffset: 0
|
|
505
|
+
handleOffset: 0,
|
|
506
|
+
focusSource: User
|
|
514
507
|
};
|
|
515
508
|
set(uid, state, state);
|
|
516
509
|
};
|
|
@@ -585,6 +578,12 @@ const number = value => {
|
|
|
585
578
|
throw new AssertionError('expected value to be of type number');
|
|
586
579
|
}
|
|
587
580
|
};
|
|
581
|
+
const array = value => {
|
|
582
|
+
const type = getType(value);
|
|
583
|
+
if (type !== 'array') {
|
|
584
|
+
throw new AssertionError('expected value to be of type array');
|
|
585
|
+
}
|
|
586
|
+
};
|
|
588
587
|
const string = value => {
|
|
589
588
|
const type = getType(value);
|
|
590
589
|
if (type !== 'string') {
|
|
@@ -650,6 +649,49 @@ const manyResultsInManyFiles = (resultCount, fileResultCount) => {
|
|
|
650
649
|
PH2: fileResultCount
|
|
651
650
|
});
|
|
652
651
|
};
|
|
652
|
+
const confirmReplaceOneOccurrenceInOneFile = replacement => {
|
|
653
|
+
return i18nString(UiStrings.ConfirmReplaceOneOccurrenceInOneFile, {
|
|
654
|
+
PH1: replacement
|
|
655
|
+
});
|
|
656
|
+
};
|
|
657
|
+
const confirmReplaceOneOccurrenceInOneFileNoValue = () => {
|
|
658
|
+
return i18nString(UiStrings.ConfirmReplaceOneOccurrenceInOneFileNoValue);
|
|
659
|
+
};
|
|
660
|
+
const confirmReplaceManyOccurrencesInOneFile = (matchCount, replacement) => {
|
|
661
|
+
return i18nString(UiStrings.ConfirmReplaceManyOccurrencesInOneFile, {
|
|
662
|
+
PH1: matchCount,
|
|
663
|
+
PH2: replacement
|
|
664
|
+
});
|
|
665
|
+
};
|
|
666
|
+
const confirmReplaceManyOccurrencesInOneFileNoValue = matchCount => {
|
|
667
|
+
return i18nString(UiStrings.ConfirmReplaceManyOccurrencesInOneFileNoValue, {
|
|
668
|
+
PH1: matchCount
|
|
669
|
+
});
|
|
670
|
+
};
|
|
671
|
+
const confirmReplaceManyOccurrencesInManyFiles = (matchCount, fileCount, replacement) => {
|
|
672
|
+
number(matchCount);
|
|
673
|
+
number(fileCount);
|
|
674
|
+
string(replacement);
|
|
675
|
+
return i18nString(UiStrings.ConfirmReplaceManyOccurrencesInManyFiles, {
|
|
676
|
+
PH1: matchCount,
|
|
677
|
+
PH2: fileCount,
|
|
678
|
+
PH3: replacement
|
|
679
|
+
});
|
|
680
|
+
};
|
|
681
|
+
const confirmReplaceManyOccurrencesInManyFilesNoValue = (matchCount, fileCount) => {
|
|
682
|
+
number(matchCount);
|
|
683
|
+
number(fileCount);
|
|
684
|
+
return i18nString(UiStrings.ConfirmReplaceManyOccurrencesInManyFilesNoValue, {
|
|
685
|
+
PH1: matchCount,
|
|
686
|
+
PH2: fileCount
|
|
687
|
+
});
|
|
688
|
+
};
|
|
689
|
+
const replaceAll$1 = () => {
|
|
690
|
+
return i18nString(UiStrings.ReplaceAll);
|
|
691
|
+
};
|
|
692
|
+
const replace = () => {
|
|
693
|
+
return i18nString(UiStrings.Replace);
|
|
694
|
+
};
|
|
653
695
|
const refresh$1 = () => {
|
|
654
696
|
return i18nString(UiStrings.Refresh);
|
|
655
697
|
};
|
|
@@ -849,16 +891,18 @@ const Tree = 'tree';
|
|
|
849
891
|
const TreeItem$1 = 'treeitem';
|
|
850
892
|
const ToolBar = 'toolbar';
|
|
851
893
|
|
|
894
|
+
const Actions = 'Actions';
|
|
895
|
+
const Badge = 'Badge';
|
|
852
896
|
const Chevron = 'Chevron';
|
|
853
897
|
const CloseMaskIcon = 'MaskIcon MaskIconClose';
|
|
854
898
|
const Empty = '';
|
|
855
899
|
const FileIcon = 'FileIcon';
|
|
856
|
-
const IconButton = 'IconButton';
|
|
857
|
-
const Actions = 'Actions';
|
|
858
900
|
const FocusOutline = 'FocusOutline';
|
|
901
|
+
const Grow = 'Grow';
|
|
859
902
|
const Highlight = 'Highlight';
|
|
860
903
|
const HighlightDeleted = 'HighlightDeleted';
|
|
861
904
|
const HighlightInserted = 'HighlightInserted';
|
|
905
|
+
const IconButton = 'IconButton';
|
|
862
906
|
const Label = 'Label';
|
|
863
907
|
const List = 'List';
|
|
864
908
|
const MaskIcon = 'MaskIcon';
|
|
@@ -867,11 +911,16 @@ const MaskIconChevronRight = 'MaskIconChevronRight';
|
|
|
867
911
|
const MultilineInputBox = 'MultilineInputBox';
|
|
868
912
|
const Search$1 = 'Search';
|
|
869
913
|
const SearchField = 'SearchField';
|
|
914
|
+
const SearchFieldButton = 'SearchFieldButton';
|
|
915
|
+
const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
|
|
870
916
|
const SearchFieldButtons = 'SearchFieldButtons';
|
|
871
917
|
const SearchFieldContainer = 'SearchFieldContainer';
|
|
872
918
|
const SearchHeader = 'SearchHeader';
|
|
919
|
+
const SearchHeaderDetails = 'SearchHeaderDetails';
|
|
873
920
|
const SearchHeaderTop = 'SearchHeaderTop';
|
|
921
|
+
const SearchHeaderTopRight = 'SearchHeaderTopRight';
|
|
874
922
|
const SearchRemove = 'SearchRemove';
|
|
923
|
+
const SearchToggleButton = 'SearchToggleButton';
|
|
875
924
|
const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
|
|
876
925
|
const SourceControlBadge = 'SourceControlBadge';
|
|
877
926
|
const TreeItem = 'TreeItem';
|
|
@@ -891,10 +940,14 @@ const Ins = 20;
|
|
|
891
940
|
const Del = 21;
|
|
892
941
|
const TextArea = 62;
|
|
893
942
|
|
|
943
|
+
const mergeClassNames = (...classNames) => {
|
|
944
|
+
return classNames.filter(Boolean).join(' ');
|
|
945
|
+
};
|
|
946
|
+
|
|
894
947
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
895
948
|
return {
|
|
896
949
|
type,
|
|
897
|
-
className:
|
|
950
|
+
className: mergeClassNames(MaskIcon, `MaskIcon${icon}`),
|
|
898
951
|
role: None,
|
|
899
952
|
childCount: 0
|
|
900
953
|
};
|
|
@@ -1085,7 +1138,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1085
1138
|
} = button;
|
|
1086
1139
|
return [{
|
|
1087
1140
|
type: Div,
|
|
1088
|
-
className:
|
|
1141
|
+
className: mergeClassNames(SearchFieldButton, checked ? SearchFieldButtonChecked : ''),
|
|
1089
1142
|
title,
|
|
1090
1143
|
role: CheckBox,
|
|
1091
1144
|
ariaChecked: checked,
|
|
@@ -1093,7 +1146,7 @@ const getSearchFieldButtonVirtualDom = button => {
|
|
|
1093
1146
|
childCount: 1
|
|
1094
1147
|
}, {
|
|
1095
1148
|
type: Div,
|
|
1096
|
-
className:
|
|
1149
|
+
className: mergeClassNames(MaskIcon, icon),
|
|
1097
1150
|
childCount: 0
|
|
1098
1151
|
}];
|
|
1099
1152
|
};
|
|
@@ -1155,7 +1208,7 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
|
|
|
1155
1208
|
childCount: 2
|
|
1156
1209
|
}, {
|
|
1157
1210
|
type: Button,
|
|
1158
|
-
className:
|
|
1211
|
+
className: mergeClassNames(IconButton, SearchToggleButton, replaceExpanded ? SearchToggleButtonExpanded : ''),
|
|
1159
1212
|
title: 'Toggle Replace',
|
|
1160
1213
|
ariaLabel: 'Toggle Replace',
|
|
1161
1214
|
ariaExpanded: replaceExpanded,
|
|
@@ -1163,11 +1216,11 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
|
|
|
1163
1216
|
'data-command': 'toggleReplace'
|
|
1164
1217
|
}, {
|
|
1165
1218
|
type: Div,
|
|
1166
|
-
className:
|
|
1219
|
+
className: mergeClassNames(MaskIcon, replaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
|
|
1167
1220
|
childCount: 0
|
|
1168
1221
|
}, {
|
|
1169
1222
|
type: Div,
|
|
1170
|
-
className:
|
|
1223
|
+
className: SearchHeaderTopRight,
|
|
1171
1224
|
role: None,
|
|
1172
1225
|
childCount: replaceExpanded ? 2 : 1
|
|
1173
1226
|
}, ...getSearchFieldVirtualDom('search-value', 'Search', 'handleInput', [{
|
|
@@ -1198,10 +1251,11 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
|
|
|
1198
1251
|
console.log({
|
|
1199
1252
|
detailsExpanded
|
|
1200
1253
|
});
|
|
1254
|
+
// @ts-ignore
|
|
1201
1255
|
dom[0].childCount++;
|
|
1202
1256
|
dom.push({
|
|
1203
1257
|
type: Div,
|
|
1204
|
-
className:
|
|
1258
|
+
className: SearchHeaderDetails,
|
|
1205
1259
|
childCount: 4
|
|
1206
1260
|
}, text('files to include'), {
|
|
1207
1261
|
type: Input,
|
|
@@ -1217,7 +1271,7 @@ const getSearchHeaderVirtualDom = (replaceExpanded, matchCase, matchWholeWord, u
|
|
|
1217
1271
|
const getBadgeVirtualDom = (className, count) => {
|
|
1218
1272
|
return [{
|
|
1219
1273
|
type: Div,
|
|
1220
|
-
className:
|
|
1274
|
+
className: mergeClassNames(Badge, className),
|
|
1221
1275
|
childCount: 1
|
|
1222
1276
|
}, text(`${count}`)];
|
|
1223
1277
|
};
|
|
@@ -1225,7 +1279,7 @@ const getBadgeVirtualDom = (className, count) => {
|
|
|
1225
1279
|
const getChevronDownVirtualDom = (extraClassName = '') => {
|
|
1226
1280
|
return {
|
|
1227
1281
|
type: Div,
|
|
1228
|
-
className:
|
|
1282
|
+
className: mergeClassNames(Chevron, MaskIconChevronDown, extraClassName),
|
|
1229
1283
|
childCount: 0
|
|
1230
1284
|
};
|
|
1231
1285
|
};
|
|
@@ -1255,29 +1309,30 @@ const highlighted = {
|
|
|
1255
1309
|
className: Highlight,
|
|
1256
1310
|
childCount: 1
|
|
1257
1311
|
};
|
|
1312
|
+
const label1 = {
|
|
1313
|
+
type: Div,
|
|
1314
|
+
className: mergeClassNames(Label, Grow),
|
|
1315
|
+
childCount: 1
|
|
1316
|
+
};
|
|
1317
|
+
const label3 = {
|
|
1318
|
+
...label1,
|
|
1319
|
+
childCount: 3
|
|
1320
|
+
};
|
|
1321
|
+
const label4 = {
|
|
1322
|
+
...label1,
|
|
1323
|
+
childCount: 4
|
|
1324
|
+
};
|
|
1258
1325
|
const getLabelVirtualDom = (displayText, matchLength, matchStart, replacement) => {
|
|
1259
|
-
const dom = [];
|
|
1260
|
-
const label = {
|
|
1261
|
-
type: Div,
|
|
1262
|
-
className: Label + ' Grow',
|
|
1263
|
-
childCount: 1
|
|
1264
|
-
};
|
|
1265
|
-
dom.push(label);
|
|
1266
1326
|
if (matchLength) {
|
|
1267
1327
|
const before = displayText.slice(0, matchStart);
|
|
1268
1328
|
const highlight = displayText.slice(matchStart, matchStart + matchLength);
|
|
1269
1329
|
const after = displayText.slice(matchStart + matchLength);
|
|
1270
1330
|
if (replacement) {
|
|
1271
|
-
|
|
1272
|
-
label.childCount = 4;
|
|
1273
|
-
} else {
|
|
1274
|
-
label.childCount = 3;
|
|
1275
|
-
dom.push(text(before), highlighted, text(highlight), text(after));
|
|
1331
|
+
return [label4, text(before), deleted, text(highlight), inserted, text(replacement), text(after)];
|
|
1276
1332
|
}
|
|
1277
|
-
|
|
1278
|
-
dom.push(text(displayText));
|
|
1333
|
+
return [label3, text(before), highlighted, text(highlight), text(after)];
|
|
1279
1334
|
}
|
|
1280
|
-
return
|
|
1335
|
+
return [label1, text(displayText)];
|
|
1281
1336
|
};
|
|
1282
1337
|
|
|
1283
1338
|
const PaddingRight = '12px';
|
|
@@ -1348,14 +1403,7 @@ const getSearchResultsVirtualDom = visibleItems => {
|
|
|
1348
1403
|
return visibleItems.flatMap(getSearchResultVirtualDom);
|
|
1349
1404
|
};
|
|
1350
1405
|
|
|
1351
|
-
const mergeClassNames = (...classNames) => {
|
|
1352
|
-
return classNames.filter(Boolean).join(' ');
|
|
1353
|
-
};
|
|
1354
|
-
|
|
1355
1406
|
const getSearchVirtualDom = (visibleItems, replaceExpanded, matchCase, matchWholeWord, useRegularExpression, message, detailsExpanded, focusOutline) => {
|
|
1356
|
-
/**
|
|
1357
|
-
* @type {any[]}
|
|
1358
|
-
*/
|
|
1359
1407
|
const dom = [];
|
|
1360
1408
|
dom.push({
|
|
1361
1409
|
type: Div,
|
|
@@ -1394,7 +1442,7 @@ const handleIconThemeChange = state => {
|
|
|
1394
1442
|
};
|
|
1395
1443
|
};
|
|
1396
1444
|
|
|
1397
|
-
const handleError =
|
|
1445
|
+
const handleError = error => {
|
|
1398
1446
|
console.error(`[text-search-worker] ${error}`);
|
|
1399
1447
|
};
|
|
1400
1448
|
|
|
@@ -1445,13 +1493,6 @@ const isEmptyString = string => {
|
|
|
1445
1493
|
return string === EmptyString;
|
|
1446
1494
|
};
|
|
1447
1495
|
|
|
1448
|
-
/**
|
|
1449
|
-
*
|
|
1450
|
-
* @param {number} size
|
|
1451
|
-
* @param {number} contentSize
|
|
1452
|
-
* @param {number} minimumSliderSize
|
|
1453
|
-
* @returns
|
|
1454
|
-
*/
|
|
1455
1496
|
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
1456
1497
|
if (size >= contentSize) {
|
|
1457
1498
|
return 0;
|
|
@@ -1486,7 +1527,7 @@ const getNewDeltaPercent = (height, scrollBarHeight, relativeY) => {
|
|
|
1486
1527
|
};
|
|
1487
1528
|
};
|
|
1488
1529
|
|
|
1489
|
-
const RE_PROTOCOL = /^([a-z
|
|
1530
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
1490
1531
|
const getProtocol = uri => {
|
|
1491
1532
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
1492
1533
|
if (protocolMatch) {
|
|
@@ -1910,9 +1951,8 @@ const state = {
|
|
|
1910
1951
|
const getHandleDb = async () => {
|
|
1911
1952
|
// @ts-ignore
|
|
1912
1953
|
const db = await openDB('handle', state.dbVersion, {
|
|
1913
|
-
async upgrade(db
|
|
1954
|
+
async upgrade(db) {
|
|
1914
1955
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
1915
|
-
// @ts-ignore
|
|
1916
1956
|
await db.createObjectStore('file-handles-store', {});
|
|
1917
1957
|
}
|
|
1918
1958
|
}
|
|
@@ -2360,7 +2400,7 @@ const getFileIndex = (items, index) => {
|
|
|
2360
2400
|
}
|
|
2361
2401
|
return -1;
|
|
2362
2402
|
};
|
|
2363
|
-
const selectIndexFile =
|
|
2403
|
+
const selectIndexFile = (state, searchResult, index) => {
|
|
2364
2404
|
const {
|
|
2365
2405
|
collapsedPaths
|
|
2366
2406
|
} = state;
|
|
@@ -2397,7 +2437,7 @@ const selectIndexPreview = async (state, searchResult, index) => {
|
|
|
2397
2437
|
listFocused: false
|
|
2398
2438
|
};
|
|
2399
2439
|
};
|
|
2400
|
-
const selectIndex = async (state, index
|
|
2440
|
+
const selectIndex = async (state, index) => {
|
|
2401
2441
|
if (index === -1) {
|
|
2402
2442
|
return {
|
|
2403
2443
|
...state,
|
|
@@ -2608,11 +2648,11 @@ const getSelector = focusKey => {
|
|
|
2608
2648
|
};
|
|
2609
2649
|
const renderFocus = {
|
|
2610
2650
|
isEqual(oldState, newState) {
|
|
2611
|
-
return oldState.focus === newState.focus;
|
|
2651
|
+
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
2612
2652
|
},
|
|
2613
2653
|
apply(newState) {
|
|
2614
2654
|
const selector = getSelector(newState.focus);
|
|
2615
|
-
return ['Viewlet.send', newState.uid, 'setFocus', selector];
|
|
2655
|
+
return ['Viewlet.send', newState.uid, 'setFocus', selector, newState.focusSource];
|
|
2616
2656
|
}
|
|
2617
2657
|
};
|
|
2618
2658
|
const render = [renderItems, renderFocus];
|
|
@@ -2630,6 +2670,86 @@ const doRender = uid => {
|
|
|
2630
2670
|
return commands;
|
|
2631
2671
|
};
|
|
2632
2672
|
|
|
2673
|
+
const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
|
|
2674
|
+
if (matchCount === 1) {
|
|
2675
|
+
if (replacement) {
|
|
2676
|
+
return confirmReplaceOneOccurrenceInOneFile(replacement);
|
|
2677
|
+
}
|
|
2678
|
+
return confirmReplaceOneOccurrenceInOneFileNoValue();
|
|
2679
|
+
}
|
|
2680
|
+
if (fileCount === 1) {
|
|
2681
|
+
if (replacement) {
|
|
2682
|
+
return confirmReplaceManyOccurrencesInOneFile(matchCount, replacement);
|
|
2683
|
+
}
|
|
2684
|
+
return confirmReplaceManyOccurrencesInOneFileNoValue(matchCount);
|
|
2685
|
+
}
|
|
2686
|
+
if (replacement) {
|
|
2687
|
+
return confirmReplaceManyOccurrencesInManyFiles(matchCount, fileCount, replacement);
|
|
2688
|
+
}
|
|
2689
|
+
return confirmReplaceManyOccurrencesInManyFilesNoValue(matchCount, fileCount);
|
|
2690
|
+
};
|
|
2691
|
+
|
|
2692
|
+
const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount, fileCount) => {
|
|
2693
|
+
string(workspacePath);
|
|
2694
|
+
array(items);
|
|
2695
|
+
string(replacement);
|
|
2696
|
+
number(matchCount);
|
|
2697
|
+
number(fileCount);
|
|
2698
|
+
const confirmTitle = replaceAll$1();
|
|
2699
|
+
const confirmAccept = replace();
|
|
2700
|
+
const confirmText = getReplaceAllConfirmText(matchCount, fileCount, replacement);
|
|
2701
|
+
const shouldReplace = await execute('ConfirmPrompt.prompt', confirmText, {
|
|
2702
|
+
title: confirmTitle,
|
|
2703
|
+
confirmMessage: confirmAccept
|
|
2704
|
+
});
|
|
2705
|
+
if (!shouldReplace) {
|
|
2706
|
+
return false;
|
|
2707
|
+
}
|
|
2708
|
+
// TODO
|
|
2709
|
+
// await TextSearchReplaceAll.replaceAll(workspacePath, items, replacement)
|
|
2710
|
+
return true;
|
|
2711
|
+
};
|
|
2712
|
+
|
|
2713
|
+
const getBulkReplacementEdits = (workspacePath, matches) => {
|
|
2714
|
+
string(workspacePath);
|
|
2715
|
+
array(matches);
|
|
2716
|
+
const files = [];
|
|
2717
|
+
const ranges = [];
|
|
2718
|
+
let currentRanges = [];
|
|
2719
|
+
for (const match of matches) {
|
|
2720
|
+
const {
|
|
2721
|
+
type,
|
|
2722
|
+
text
|
|
2723
|
+
} = match;
|
|
2724
|
+
switch (type) {
|
|
2725
|
+
case File$1:
|
|
2726
|
+
ranges.push(currentRanges.length);
|
|
2727
|
+
push(ranges, currentRanges);
|
|
2728
|
+
const absolutePath = `${workspacePath}/${text.slice(2)}`;
|
|
2729
|
+
files.push(absolutePath); // TODO
|
|
2730
|
+
currentRanges = [];
|
|
2731
|
+
break;
|
|
2732
|
+
case Match:
|
|
2733
|
+
currentRanges.push(match.lineNumber - 1, match.matchStart, match.lineNumber - 1, match.matchStart + match.matchLength);
|
|
2734
|
+
break;
|
|
2735
|
+
}
|
|
2736
|
+
}
|
|
2737
|
+
ranges.push(currentRanges.length);
|
|
2738
|
+
push(ranges, currentRanges);
|
|
2739
|
+
return {
|
|
2740
|
+
files,
|
|
2741
|
+
ranges: ranges.slice(1)
|
|
2742
|
+
};
|
|
2743
|
+
};
|
|
2744
|
+
|
|
2745
|
+
const replaceAll = async (workspacePath, items, replacement) => {
|
|
2746
|
+
const {
|
|
2747
|
+
files,
|
|
2748
|
+
ranges
|
|
2749
|
+
} = getBulkReplacementEdits(workspacePath, items);
|
|
2750
|
+
await invoke$1('BulkReplacement.applyBulkReplacement', files, ranges, replacement);
|
|
2751
|
+
};
|
|
2752
|
+
|
|
2633
2753
|
const saveState = uid => {
|
|
2634
2754
|
const {
|
|
2635
2755
|
newState
|
|
@@ -2672,7 +2792,8 @@ const getSearchFocusKey = key => {
|
|
|
2672
2792
|
const focusSearchValue = state => {
|
|
2673
2793
|
return {
|
|
2674
2794
|
...state,
|
|
2675
|
-
focus: FocusSearchInput
|
|
2795
|
+
focus: FocusSearchInput,
|
|
2796
|
+
focusSource: Script
|
|
2676
2797
|
};
|
|
2677
2798
|
};
|
|
2678
2799
|
const focusMatchCasePrevious = state => {
|
|
@@ -2693,37 +2814,43 @@ const focusRegexNext = state => {
|
|
|
2693
2814
|
const focusReplaceValue = state => {
|
|
2694
2815
|
return {
|
|
2695
2816
|
...state,
|
|
2696
|
-
focus: FocusSearchReplaceInput
|
|
2817
|
+
focus: FocusSearchReplaceInput,
|
|
2818
|
+
focusSource: Script
|
|
2697
2819
|
};
|
|
2698
2820
|
};
|
|
2699
2821
|
const focusMatchCase = state => {
|
|
2700
2822
|
return {
|
|
2701
2823
|
...state,
|
|
2702
|
-
focus: FocusSearchMatchCase
|
|
2824
|
+
focus: FocusSearchMatchCase,
|
|
2825
|
+
focusSource: Script
|
|
2703
2826
|
};
|
|
2704
2827
|
};
|
|
2705
2828
|
const focusPreserveCase = state => {
|
|
2706
2829
|
return {
|
|
2707
2830
|
...state,
|
|
2708
|
-
focus: FocusSearchPreserveCase
|
|
2831
|
+
focus: FocusSearchPreserveCase,
|
|
2832
|
+
focusSource: Script
|
|
2709
2833
|
};
|
|
2710
2834
|
};
|
|
2711
2835
|
const focusMatchWholeWord = state => {
|
|
2712
2836
|
return {
|
|
2713
2837
|
...state,
|
|
2714
|
-
focus: FocusSearchWholeWord
|
|
2838
|
+
focus: FocusSearchWholeWord,
|
|
2839
|
+
focusSource: Script
|
|
2715
2840
|
};
|
|
2716
2841
|
};
|
|
2717
2842
|
const focusRegex = state => {
|
|
2718
2843
|
return {
|
|
2719
2844
|
...state,
|
|
2720
|
-
focus: FocusSearchRegex
|
|
2845
|
+
focus: FocusSearchRegex,
|
|
2846
|
+
focusSource: Script
|
|
2721
2847
|
};
|
|
2722
2848
|
};
|
|
2723
2849
|
const focusReplaceAll = state => {
|
|
2724
2850
|
return {
|
|
2725
2851
|
...state,
|
|
2726
|
-
focus: FocusSearchReplaceAll
|
|
2852
|
+
focus: FocusSearchReplaceAll,
|
|
2853
|
+
focusSource: Script
|
|
2727
2854
|
};
|
|
2728
2855
|
};
|
|
2729
2856
|
const handleFocusIn = (state, key) => {
|
|
@@ -2731,10 +2858,11 @@ const handleFocusIn = (state, key) => {
|
|
|
2731
2858
|
if (state.focus === focusKey) {
|
|
2732
2859
|
return state;
|
|
2733
2860
|
}
|
|
2734
|
-
setFocus(focusKey);
|
|
2861
|
+
void setFocus(focusKey);
|
|
2735
2862
|
return {
|
|
2736
2863
|
...state,
|
|
2737
|
-
focus: focusKey
|
|
2864
|
+
focus: focusKey,
|
|
2865
|
+
focusSource: User
|
|
2738
2866
|
};
|
|
2739
2867
|
};
|
|
2740
2868
|
|
|
@@ -2763,6 +2891,7 @@ const show = async (x, y, id, ...args) => {
|
|
|
2763
2891
|
number(y);
|
|
2764
2892
|
number(id);
|
|
2765
2893
|
// TODO
|
|
2894
|
+
await invoke$1('ContextMenu.show', x, y, id, ...args);
|
|
2766
2895
|
};
|
|
2767
2896
|
|
|
2768
2897
|
const Search = 18;
|
|
@@ -2802,7 +2931,6 @@ const wrapCommand = fn => {
|
|
|
2802
2931
|
const commandMap = {
|
|
2803
2932
|
'TextSearch.clearSearchResults': wrapCommand(clearSearchResults$1),
|
|
2804
2933
|
'TextSearch.copy': wrapCommand(copy),
|
|
2805
|
-
'TextSearch.handleInput': wrapCommand(handleInput),
|
|
2806
2934
|
'TextSearch.dismissItem': wrapCommand(dismissItem),
|
|
2807
2935
|
'TextSearch.focusFirst': wrapCommand(focusFirst),
|
|
2808
2936
|
'TextSearch.focusIndex': wrapCommand(focusIndex),
|
|
@@ -2830,12 +2958,15 @@ const commandMap = {
|
|
|
2830
2958
|
'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
|
|
2831
2959
|
'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
|
|
2832
2960
|
'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
|
|
2961
|
+
'TextSearch.handleInput': wrapCommand(handleInput),
|
|
2833
2962
|
'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
|
|
2834
2963
|
'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
2835
2964
|
'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
2836
2965
|
'TextSearch.handleWheel': wrapCommand(handleWheel),
|
|
2837
2966
|
'TextSearch.loadContent': wrapCommand(loadContent),
|
|
2838
2967
|
'TextSearch.refresh': wrapCommand(refresh),
|
|
2968
|
+
'TextSearch.replaceAllAndPrompt': wrapCommand(replaceAllAndPrompt),
|
|
2969
|
+
'TextSearch.replaceAll': wrapCommand(replaceAll),
|
|
2839
2970
|
'TextSearch.submit': wrapCommand(submit),
|
|
2840
2971
|
'TextSearch.toggleReplace': wrapCommand(toggleReplace),
|
|
2841
2972
|
// not wrapped
|
|
@@ -2852,7 +2983,7 @@ const requiresSocket = () => {
|
|
|
2852
2983
|
const preparePrettyError = error => {
|
|
2853
2984
|
return error;
|
|
2854
2985
|
};
|
|
2855
|
-
const logError =
|
|
2986
|
+
const logError = () => {
|
|
2856
2987
|
// handled by renderer worker
|
|
2857
2988
|
};
|
|
2858
2989
|
const handleMessage = event => {
|