@lvce-editor/text-search-worker 3.11.0 → 3.13.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 +604 -144
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const Two = '2.0';
|
|
2
|
-
const create$4 = (method, params) => {
|
|
2
|
+
const create$4$1 = (method, params) => {
|
|
3
3
|
return {
|
|
4
4
|
jsonrpc: Two,
|
|
5
5
|
method,
|
|
@@ -19,14 +19,14 @@ const remove$1 = id => {
|
|
|
19
19
|
delete state$2.callbacks[id];
|
|
20
20
|
};
|
|
21
21
|
let id = 0;
|
|
22
|
-
const create$3 = () => {
|
|
22
|
+
const create$3$1 = () => {
|
|
23
23
|
return ++id;
|
|
24
24
|
};
|
|
25
25
|
const warn = (...args) => {
|
|
26
26
|
console.warn(...args);
|
|
27
27
|
};
|
|
28
28
|
const registerPromise = () => {
|
|
29
|
-
const id = create$3();
|
|
29
|
+
const id = create$3$1();
|
|
30
30
|
const {
|
|
31
31
|
resolve,
|
|
32
32
|
promise
|
|
@@ -47,7 +47,7 @@ const resolve = (id, response) => {
|
|
|
47
47
|
fn(response);
|
|
48
48
|
remove$1(id);
|
|
49
49
|
};
|
|
50
|
-
const create$2 = (method, params) => {
|
|
50
|
+
const create$2$1 = (method, params) => {
|
|
51
51
|
const {
|
|
52
52
|
id,
|
|
53
53
|
promise
|
|
@@ -237,7 +237,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
237
237
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
238
238
|
return create$1$2(message, errorProperty);
|
|
239
239
|
};
|
|
240
|
-
const create$
|
|
240
|
+
const create$6 = (message, result) => {
|
|
241
241
|
return {
|
|
242
242
|
jsonrpc: Two,
|
|
243
243
|
id: message.id,
|
|
@@ -246,7 +246,7 @@ const create$5 = (message, result) => {
|
|
|
246
246
|
};
|
|
247
247
|
const getSuccessResponse = (message, result) => {
|
|
248
248
|
const resultProperty = result ?? null;
|
|
249
|
-
return create$
|
|
249
|
+
return create$6(message, resultProperty);
|
|
250
250
|
};
|
|
251
251
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
252
252
|
try {
|
|
@@ -326,7 +326,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
326
326
|
const {
|
|
327
327
|
message,
|
|
328
328
|
promise
|
|
329
|
-
} = create$2(method, params);
|
|
329
|
+
} = create$2$1(method, params);
|
|
330
330
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
331
331
|
ipc.sendAndTransfer(message);
|
|
332
332
|
} else {
|
|
@@ -336,13 +336,13 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
336
336
|
return unwrapJsonRpcResult(responseMessage);
|
|
337
337
|
};
|
|
338
338
|
const send = (transport, method, ...params) => {
|
|
339
|
-
const message = create$4(method, params);
|
|
339
|
+
const message = create$4$1(method, params);
|
|
340
340
|
transport.send(message);
|
|
341
341
|
};
|
|
342
342
|
const invoke$2 = (ipc, method, ...params) => {
|
|
343
343
|
return invokeHelper(ipc, method, params, false);
|
|
344
344
|
};
|
|
345
|
-
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
345
|
+
const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
346
346
|
return invokeHelper(ipc, method, params, true);
|
|
347
347
|
};
|
|
348
348
|
|
|
@@ -639,7 +639,7 @@ let VError$1 = class VError extends Error {
|
|
|
639
639
|
}
|
|
640
640
|
}
|
|
641
641
|
};
|
|
642
|
-
class IpcError extends VError$1 {
|
|
642
|
+
let IpcError$1 = class IpcError extends VError$1 {
|
|
643
643
|
// @ts-ignore
|
|
644
644
|
constructor(betterMessage, stdout = '', stderr = '') {
|
|
645
645
|
if (stdout || stderr) {
|
|
@@ -664,7 +664,7 @@ class IpcError extends VError$1 {
|
|
|
664
664
|
// @ts-ignore
|
|
665
665
|
this.stderr = stderr;
|
|
666
666
|
}
|
|
667
|
-
}
|
|
667
|
+
};
|
|
668
668
|
const withResolvers = () => {
|
|
669
669
|
let _resolve;
|
|
670
670
|
const promise = new Promise(resolve => {
|
|
@@ -693,7 +693,7 @@ const listen$1$1 = async () => {
|
|
|
693
693
|
const parentIpc = wrap$5(parentIpcRaw);
|
|
694
694
|
const firstMessage = await waitForFirstMessage(parentIpc);
|
|
695
695
|
if (firstMessage.method !== 'initialize') {
|
|
696
|
-
throw new IpcError('unexpected first message');
|
|
696
|
+
throw new IpcError$1('unexpected first message');
|
|
697
697
|
}
|
|
698
698
|
const type = firstMessage.params[0];
|
|
699
699
|
if (type === 'message-port') {
|
|
@@ -756,7 +756,7 @@ const createRpc = ipc => {
|
|
|
756
756
|
return invoke$2(ipc, method, ...params);
|
|
757
757
|
},
|
|
758
758
|
invokeAndTransfer(method, ...params) {
|
|
759
|
-
return invokeAndTransfer(ipc, method, ...params);
|
|
759
|
+
return invokeAndTransfer$1(ipc, method, ...params);
|
|
760
760
|
}
|
|
761
761
|
};
|
|
762
762
|
return rpc;
|
|
@@ -800,16 +800,21 @@ const WebWorkerRpcClient = {
|
|
|
800
800
|
};
|
|
801
801
|
|
|
802
802
|
const Empty$1 = 0;
|
|
803
|
+
const FocusIgnoreFiles = 1012;
|
|
804
|
+
const FocusSearch = 1013;
|
|
805
|
+
const FocusSearchExcludeInput = 1008;
|
|
806
|
+
const FocusSearchIncludeInput = 1007;
|
|
803
807
|
const FocusSearchInput = 21;
|
|
804
|
-
const FocusSearchReplaceInput = 31;
|
|
805
808
|
const FocusSearchMatchCase = 32;
|
|
809
|
+
const FocusSearchOpenEditors = 1011;
|
|
810
|
+
const FocusSearchPreserveCase = 36;
|
|
806
811
|
const FocusSearchRegex = 33;
|
|
807
|
-
const FocusSearchWholeWord = 34;
|
|
808
812
|
const FocusSearchReplaceAll = 35;
|
|
809
|
-
const
|
|
810
|
-
const FocusSearchIncludeInput = 1007;
|
|
811
|
-
const FocusSearchExcludeInput = 1008;
|
|
813
|
+
const FocusSearchReplaceInput = 31;
|
|
812
814
|
const FocusSearchResults = 22;
|
|
815
|
+
const FocusSearchWholeWord = 34;
|
|
816
|
+
const FocusToggleDetails = 1010;
|
|
817
|
+
const FocusToggleReplace = 1020;
|
|
813
818
|
|
|
814
819
|
const User = 1;
|
|
815
820
|
const Script = 2;
|
|
@@ -835,6 +840,11 @@ const invoke$1 = (method, ...params) => {
|
|
|
835
840
|
// @ts-ignore
|
|
836
841
|
return rpc.invoke(method, ...params);
|
|
837
842
|
};
|
|
843
|
+
const invokeAndTransfer = (method, ...params) => {
|
|
844
|
+
const rpc = state$1.rpc;
|
|
845
|
+
// @ts-ignore
|
|
846
|
+
return rpc.invokeAndTransfer(method, ...params);
|
|
847
|
+
};
|
|
838
848
|
const setRpc = rpc => {
|
|
839
849
|
state$1.rpc = rpc;
|
|
840
850
|
};
|
|
@@ -865,7 +875,7 @@ const set = (uid, oldState, newState) => {
|
|
|
865
875
|
};
|
|
866
876
|
};
|
|
867
877
|
|
|
868
|
-
const create$
|
|
878
|
+
const create$5 = ({
|
|
869
879
|
itemHeight,
|
|
870
880
|
headerHeight = 0,
|
|
871
881
|
minimumSliderSize = 20
|
|
@@ -878,6 +888,7 @@ const create$1 = ({
|
|
|
878
888
|
itemHeight,
|
|
879
889
|
headerHeight,
|
|
880
890
|
items: [],
|
|
891
|
+
listItems: [],
|
|
881
892
|
minimumSliderSize,
|
|
882
893
|
focusedIndex: -1,
|
|
883
894
|
touchOffsetY: 0,
|
|
@@ -888,7 +899,7 @@ const create$1 = ({
|
|
|
888
899
|
};
|
|
889
900
|
};
|
|
890
901
|
|
|
891
|
-
const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '') => {
|
|
902
|
+
const create$4 = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '') => {
|
|
892
903
|
const state = {
|
|
893
904
|
uid,
|
|
894
905
|
searchResults: [],
|
|
@@ -901,7 +912,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
901
912
|
y,
|
|
902
913
|
width,
|
|
903
914
|
height,
|
|
904
|
-
...create$
|
|
915
|
+
...create$5({
|
|
905
916
|
itemHeight: itemHeight || 22,
|
|
906
917
|
minimumSliderSize: minimumSliderSize,
|
|
907
918
|
headerHeight: 61 // TODO
|
|
@@ -1269,49 +1280,141 @@ const focusMatchCase$1 = state => {
|
|
|
1269
1280
|
};
|
|
1270
1281
|
};
|
|
1271
1282
|
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1274
|
-
...state,
|
|
1275
|
-
focus: FocusSearchReplaceInput,
|
|
1276
|
-
focusSource: Script
|
|
1277
|
-
};
|
|
1278
|
-
};
|
|
1279
|
-
|
|
1280
|
-
const focusSearchValue$1 = state => {
|
|
1281
|
-
return {
|
|
1282
|
-
...state,
|
|
1283
|
-
focus: FocusSearchInput
|
|
1284
|
-
};
|
|
1285
|
-
};
|
|
1286
|
-
|
|
1287
|
-
const PreserveCase = 1 << 0; // 1
|
|
1288
|
-
const UseRegularExpression = 1 << 1; // 2
|
|
1283
|
+
const PreserveCase$1 = 1 << 0; // 1
|
|
1284
|
+
const UseRegularExpression$1 = 1 << 1; // 2
|
|
1289
1285
|
const ReplaceExpanded = 1 << 2; // 4
|
|
1290
|
-
const MatchWholeWord = 1 << 3; // 8
|
|
1291
|
-
const MatchCase = 1 << 4; // 16
|
|
1286
|
+
const MatchWholeWord$1 = 1 << 3; // 8
|
|
1287
|
+
const MatchCase$1 = 1 << 4; // 16
|
|
1292
1288
|
const DetailsExpanded = 1 << 5; // 32
|
|
1293
1289
|
const OpenEditors = 1 << 6; // 64
|
|
1294
1290
|
const UseIgnoreFiles = 1 << 7; // 128
|
|
1295
1291
|
|
|
1296
1292
|
const hasPreserveCase = flags => {
|
|
1297
|
-
return (flags & PreserveCase) === PreserveCase;
|
|
1293
|
+
return (flags & PreserveCase$1) === PreserveCase$1;
|
|
1298
1294
|
};
|
|
1299
1295
|
const hasUseRegularExpression = flags => {
|
|
1300
|
-
return (flags & UseRegularExpression) === UseRegularExpression;
|
|
1296
|
+
return (flags & UseRegularExpression$1) === UseRegularExpression$1;
|
|
1301
1297
|
};
|
|
1302
1298
|
const hasReplaceExpanded = flags => {
|
|
1303
1299
|
return (flags & ReplaceExpanded) === ReplaceExpanded;
|
|
1304
1300
|
};
|
|
1305
1301
|
const hasMatchWholeWord = flags => {
|
|
1306
|
-
return (flags & MatchWholeWord) === MatchWholeWord;
|
|
1302
|
+
return (flags & MatchWholeWord$1) === MatchWholeWord$1;
|
|
1307
1303
|
};
|
|
1308
1304
|
const hasMatchCase = flags => {
|
|
1309
|
-
return (flags & MatchCase) === MatchCase;
|
|
1305
|
+
return (flags & MatchCase$1) === MatchCase$1;
|
|
1310
1306
|
};
|
|
1311
1307
|
const hasDetailsExpanded = flags => {
|
|
1312
1308
|
return (flags & DetailsExpanded) === DetailsExpanded;
|
|
1313
1309
|
};
|
|
1314
1310
|
|
|
1311
|
+
const getNextFocus = (focus, flags) => {
|
|
1312
|
+
switch (focus) {
|
|
1313
|
+
case FocusToggleReplace:
|
|
1314
|
+
return FocusSearchInput;
|
|
1315
|
+
case FocusSearchInput:
|
|
1316
|
+
if (flags & ReplaceExpanded) {
|
|
1317
|
+
return FocusSearchReplaceInput;
|
|
1318
|
+
}
|
|
1319
|
+
return FocusSearchMatchCase;
|
|
1320
|
+
case FocusSearchMatchCase:
|
|
1321
|
+
return FocusSearchWholeWord;
|
|
1322
|
+
case FocusSearchWholeWord:
|
|
1323
|
+
return FocusSearchRegex;
|
|
1324
|
+
case FocusSearchRegex:
|
|
1325
|
+
if (flags & ReplaceExpanded) {
|
|
1326
|
+
return FocusSearchPreserveCase;
|
|
1327
|
+
}
|
|
1328
|
+
return FocusToggleDetails;
|
|
1329
|
+
case FocusSearchReplaceInput:
|
|
1330
|
+
return FocusSearchMatchCase;
|
|
1331
|
+
case FocusSearchPreserveCase:
|
|
1332
|
+
return FocusSearchReplaceAll;
|
|
1333
|
+
case FocusSearchReplaceAll:
|
|
1334
|
+
return FocusToggleDetails;
|
|
1335
|
+
case FocusSearchIncludeInput:
|
|
1336
|
+
return FocusSearchOpenEditors;
|
|
1337
|
+
case FocusSearchOpenEditors:
|
|
1338
|
+
return FocusSearchExcludeInput;
|
|
1339
|
+
case FocusSearchExcludeInput:
|
|
1340
|
+
return FocusIgnoreFiles;
|
|
1341
|
+
case FocusToggleDetails:
|
|
1342
|
+
return FocusSearchIncludeInput;
|
|
1343
|
+
default:
|
|
1344
|
+
return focus;
|
|
1345
|
+
}
|
|
1346
|
+
};
|
|
1347
|
+
|
|
1348
|
+
const focusNextInput = state => {
|
|
1349
|
+
const nextFocus = getNextFocus(state.focus, state.flags);
|
|
1350
|
+
return {
|
|
1351
|
+
...state,
|
|
1352
|
+
focus: nextFocus,
|
|
1353
|
+
focusSource: Script
|
|
1354
|
+
};
|
|
1355
|
+
};
|
|
1356
|
+
|
|
1357
|
+
const getPreviousFocus = (focus, flags) => {
|
|
1358
|
+
switch (focus) {
|
|
1359
|
+
case FocusSearchInput:
|
|
1360
|
+
return FocusToggleReplace;
|
|
1361
|
+
case FocusSearchMatchCase:
|
|
1362
|
+
if (flags & ReplaceExpanded) {
|
|
1363
|
+
return FocusSearchReplaceInput;
|
|
1364
|
+
}
|
|
1365
|
+
return FocusSearchInput;
|
|
1366
|
+
case FocusSearchWholeWord:
|
|
1367
|
+
return FocusSearchMatchCase;
|
|
1368
|
+
case FocusSearchRegex:
|
|
1369
|
+
return FocusSearchWholeWord;
|
|
1370
|
+
case FocusSearchPreserveCase:
|
|
1371
|
+
return FocusSearchRegex;
|
|
1372
|
+
case FocusSearchReplaceInput:
|
|
1373
|
+
return FocusSearchInput;
|
|
1374
|
+
case FocusSearchReplaceAll:
|
|
1375
|
+
return FocusSearchPreserveCase;
|
|
1376
|
+
case FocusToggleDetails:
|
|
1377
|
+
if (flags & ReplaceExpanded) {
|
|
1378
|
+
return FocusSearchReplaceAll;
|
|
1379
|
+
}
|
|
1380
|
+
return FocusSearchRegex;
|
|
1381
|
+
case FocusSearchOpenEditors:
|
|
1382
|
+
return FocusSearchIncludeInput;
|
|
1383
|
+
case FocusSearchExcludeInput:
|
|
1384
|
+
return FocusSearchOpenEditors;
|
|
1385
|
+
case FocusIgnoreFiles:
|
|
1386
|
+
return FocusSearchExcludeInput;
|
|
1387
|
+
case FocusSearchIncludeInput:
|
|
1388
|
+
return FocusToggleDetails;
|
|
1389
|
+
default:
|
|
1390
|
+
return focus;
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
const focusPreviousInput = state => {
|
|
1395
|
+
const previousFocus = getPreviousFocus(state.focus, state.flags);
|
|
1396
|
+
return {
|
|
1397
|
+
...state,
|
|
1398
|
+
focus: previousFocus,
|
|
1399
|
+
focusSource: Script
|
|
1400
|
+
};
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
const focusReplaceValue$1 = state => {
|
|
1404
|
+
return {
|
|
1405
|
+
...state,
|
|
1406
|
+
focus: FocusSearchReplaceInput,
|
|
1407
|
+
focusSource: Script
|
|
1408
|
+
};
|
|
1409
|
+
};
|
|
1410
|
+
|
|
1411
|
+
const focusSearchValue$1 = state => {
|
|
1412
|
+
return {
|
|
1413
|
+
...state,
|
|
1414
|
+
focus: FocusSearchInput
|
|
1415
|
+
};
|
|
1416
|
+
};
|
|
1417
|
+
|
|
1315
1418
|
const focusSearchValueNext = state => {
|
|
1316
1419
|
if (hasReplaceExpanded(state.flags)) {
|
|
1317
1420
|
return focusReplaceValue$1(state);
|
|
@@ -1451,7 +1554,15 @@ const getKeyBindings = () => {
|
|
|
1451
1554
|
return [{
|
|
1452
1555
|
key: CtrlCmd | Alt | Enter,
|
|
1453
1556
|
command: 'Search.replaceAll',
|
|
1454
|
-
when:
|
|
1557
|
+
when: FocusSearch
|
|
1558
|
+
}, {
|
|
1559
|
+
key: Tab,
|
|
1560
|
+
command: 'Search.focusNextInput',
|
|
1561
|
+
when: FocusSearch
|
|
1562
|
+
}, {
|
|
1563
|
+
key: Shift | Tab,
|
|
1564
|
+
command: 'Search.focusPreviousInput',
|
|
1565
|
+
when: FocusSearch
|
|
1455
1566
|
}, {
|
|
1456
1567
|
key: DownArrow,
|
|
1457
1568
|
command: 'Search.focusNext',
|
|
@@ -1476,30 +1587,6 @@ const getKeyBindings = () => {
|
|
|
1476
1587
|
key: CtrlCmd | KeyC,
|
|
1477
1588
|
command: 'Search.copy',
|
|
1478
1589
|
when: FocusSearchResults
|
|
1479
|
-
}, {
|
|
1480
|
-
key: Tab,
|
|
1481
|
-
command: 'Search.focusSearchValueNext',
|
|
1482
|
-
when: FocusSearchInput
|
|
1483
|
-
}, {
|
|
1484
|
-
key: Shift | Tab,
|
|
1485
|
-
command: 'Search.focusReplaceValuePrevious',
|
|
1486
|
-
when: FocusSearchReplaceInput
|
|
1487
|
-
}, {
|
|
1488
|
-
key: Tab,
|
|
1489
|
-
command: 'Search.focusReplaceValueNext',
|
|
1490
|
-
when: FocusSearchReplaceInput
|
|
1491
|
-
}, {
|
|
1492
|
-
key: Shift | Tab,
|
|
1493
|
-
command: 'Search.focusMatchCasePrevious',
|
|
1494
|
-
when: FocusSearchMatchCase
|
|
1495
|
-
}, {
|
|
1496
|
-
key: Tab,
|
|
1497
|
-
command: 'Search.focusRegexNext',
|
|
1498
|
-
when: FocusSearchRegex
|
|
1499
|
-
}, {
|
|
1500
|
-
key: Shift | Tab,
|
|
1501
|
-
command: 'Search.focusPreserveCasePrevious',
|
|
1502
|
-
when: FocusSearchPreserveCase
|
|
1503
1590
|
}, {
|
|
1504
1591
|
key: Enter,
|
|
1505
1592
|
command: 'Search.submit',
|
|
@@ -1610,26 +1697,8 @@ const getDisplayResult = (result, fileIcons, fileIconIndex, itemHeight, i, setSi
|
|
|
1610
1697
|
}
|
|
1611
1698
|
};
|
|
1612
1699
|
|
|
1613
|
-
const
|
|
1614
|
-
const filteredResults = [];
|
|
1615
|
-
let isExcluded = false;
|
|
1616
|
-
for (const result of results) {
|
|
1617
|
-
if (result.type === File$1) {
|
|
1618
|
-
if (collapsedPaths.includes(result.text)) {
|
|
1619
|
-
isExcluded = true;
|
|
1620
|
-
} else {
|
|
1621
|
-
isExcluded = false;
|
|
1622
|
-
}
|
|
1623
|
-
}
|
|
1624
|
-
if (!isExcluded) {
|
|
1625
|
-
filteredResults.push(result);
|
|
1626
|
-
}
|
|
1627
|
-
}
|
|
1628
|
-
return filteredResults;
|
|
1629
|
-
};
|
|
1630
|
-
const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLineY, maxLineY, replacement, collapsedPaths, fileIcons, focusedIndex) => {
|
|
1700
|
+
const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLineY, maxLineY, replacement, fileIcons, focusedIndex) => {
|
|
1631
1701
|
const displayResults = [];
|
|
1632
|
-
const filteredResults = getFilteredResults(results, collapsedPaths);
|
|
1633
1702
|
const setSize = resultCount;
|
|
1634
1703
|
const searchTermLength = searchTerm.length;
|
|
1635
1704
|
let fileResult = {
|
|
@@ -1637,7 +1706,7 @@ const getDisplayResults = (results, itemHeight, resultCount, searchTerm, minLine
|
|
|
1637
1706
|
};
|
|
1638
1707
|
let fileIconIndex = 0;
|
|
1639
1708
|
for (let i = minLineY; i < maxLineY; i++) {
|
|
1640
|
-
const result =
|
|
1709
|
+
const result = results[i];
|
|
1641
1710
|
const displayResult = getDisplayResult(result, fileIcons, fileIconIndex, itemHeight, i, setSize, searchTermLength, replacement, focusedIndex);
|
|
1642
1711
|
displayResults.push(displayResult);
|
|
1643
1712
|
if (result.type === File$1) {
|
|
@@ -1764,18 +1833,34 @@ const getSearchFieldVirtualDom = (name, placeholder, onInput, insideButtons, out
|
|
|
1764
1833
|
return dom;
|
|
1765
1834
|
};
|
|
1766
1835
|
|
|
1767
|
-
const
|
|
1836
|
+
const FilesToExclude = 'FilesToExclude';
|
|
1837
|
+
const FilesToInclude = 'FilesToInclude';
|
|
1838
|
+
const MatchCase = 'MatchCase';
|
|
1839
|
+
const MatchWholeWord = 'MatchWholeWord';
|
|
1840
|
+
const PreserveCase = 'PreserveCase';
|
|
1841
|
+
const ReplaceAll = 'ReplaceAll';
|
|
1842
|
+
const ReplaceValue = 'ReplaceValue';
|
|
1843
|
+
const SearchOnlyOpenEditors = 'SearchOnlyOpenEditors';
|
|
1844
|
+
const SearchValue = 'SearchValue';
|
|
1845
|
+
const ToggleReplace = 'ToggleReplace';
|
|
1846
|
+
const ToggleSearchDetails = 'ToggleSearchDetails';
|
|
1847
|
+
const UseExcludeSettings = 'UseExcludeSettings';
|
|
1848
|
+
const UseRegularExpression = 'UseRegularExpression';
|
|
1849
|
+
|
|
1850
|
+
const getSearchHeaderDetailsExpandedVirtualDom = (flags, message) => {
|
|
1768
1851
|
const includeButtons = [{
|
|
1769
1852
|
icon: MaskIconBook,
|
|
1770
1853
|
title: searchOnlyOpenEditors(),
|
|
1771
1854
|
command: 'searchOnlyOpenEditors',
|
|
1772
|
-
checked:
|
|
1855
|
+
checked: Boolean(flags & OpenEditors),
|
|
1856
|
+
name: SearchOnlyOpenEditors
|
|
1773
1857
|
}];
|
|
1774
1858
|
const excludeButtons = [{
|
|
1775
1859
|
icon: MaskIconExclude,
|
|
1776
1860
|
title: useExcludeSettings(),
|
|
1777
1861
|
command: 'toggleUseExcludeSettings',
|
|
1778
|
-
checked:
|
|
1862
|
+
checked: Boolean(flags & UseIgnoreFiles),
|
|
1863
|
+
name: UseExcludeSettings
|
|
1779
1864
|
}];
|
|
1780
1865
|
return [{
|
|
1781
1866
|
type: Div,
|
|
@@ -1789,16 +1874,16 @@ const getSearchHeaderDetailsExpandedVirtualDom = message => {
|
|
|
1789
1874
|
type: H4,
|
|
1790
1875
|
className: SearchHeaderDetailsHeading,
|
|
1791
1876
|
childCount: 1
|
|
1792
|
-
}, text(filesToInclude()), ...getSearchFieldVirtualDom(
|
|
1877
|
+
}, text(filesToInclude()), ...getSearchFieldVirtualDom(FilesToInclude, 'Include', 'handleIncludeInput', includeButtons, []), {
|
|
1793
1878
|
type: H4,
|
|
1794
1879
|
className: SearchHeaderDetailsHeading,
|
|
1795
1880
|
childCount: 1
|
|
1796
|
-
}, text(filesToExclude()), ...getSearchFieldVirtualDom(
|
|
1881
|
+
}, text(filesToExclude()), ...getSearchFieldVirtualDom(FilesToExclude, 'Exclude', 'handleExcludeInput', excludeButtons, []), ...getSearchMessageVirtualDom(message)];
|
|
1797
1882
|
};
|
|
1798
1883
|
|
|
1799
1884
|
const getSearchHeaderDetailsVirtualDom = (flags, message) => {
|
|
1800
1885
|
if (flags & DetailsExpanded) {
|
|
1801
|
-
return getSearchHeaderDetailsExpandedVirtualDom(message);
|
|
1886
|
+
return getSearchHeaderDetailsExpandedVirtualDom(flags, message);
|
|
1802
1887
|
}
|
|
1803
1888
|
return getSearchHeaderDetailsCollapsedVirtualDom(message);
|
|
1804
1889
|
};
|
|
@@ -1830,28 +1915,33 @@ const getSearchHeaderTopVirtualDom = flags => {
|
|
|
1830
1915
|
className: SearchHeaderTopRight,
|
|
1831
1916
|
role: None,
|
|
1832
1917
|
childCount: hasReplaceExpanded(flags) ? 2 : 1
|
|
1833
|
-
}, ...getSearchFieldVirtualDom(
|
|
1918
|
+
}, ...getSearchFieldVirtualDom(SearchValue, 'Search', 'handleInput', [{
|
|
1834
1919
|
icon: MaskIconCaseSensitive,
|
|
1835
1920
|
checked: hasMatchCase(flags),
|
|
1836
|
-
title: matchCase()
|
|
1921
|
+
title: matchCase(),
|
|
1922
|
+
name: MatchCase
|
|
1837
1923
|
}, {
|
|
1838
1924
|
icon: MaskIconWholeWord,
|
|
1839
1925
|
checked: hasMatchWholeWord(flags),
|
|
1840
|
-
title: matchWholeWord()
|
|
1926
|
+
title: matchWholeWord(),
|
|
1927
|
+
name: MatchWholeWord
|
|
1841
1928
|
}, {
|
|
1842
1929
|
icon: MaskIconRegex,
|
|
1843
1930
|
checked: hasUseRegularExpression(flags),
|
|
1844
|
-
title: useRegularExpression()
|
|
1931
|
+
title: useRegularExpression(),
|
|
1932
|
+
name: UseRegularExpression
|
|
1845
1933
|
}], [])];
|
|
1846
1934
|
if (hasReplaceExpanded(flags)) {
|
|
1847
|
-
dom.push(...getSearchFieldVirtualDom(
|
|
1935
|
+
dom.push(...getSearchFieldVirtualDom(ReplaceValue, 'Replace', 'handleReplaceInput', [{
|
|
1848
1936
|
icon: MaskIconPreserveCase,
|
|
1849
1937
|
checked: hasPreserveCase(flags),
|
|
1850
|
-
title: preserveCase()
|
|
1938
|
+
title: preserveCase(),
|
|
1939
|
+
name: PreserveCase
|
|
1851
1940
|
}], [{
|
|
1852
1941
|
icon: MaskIconReplaceAll,
|
|
1853
1942
|
checked: false,
|
|
1854
|
-
title: replaceAll$1()
|
|
1943
|
+
title: replaceAll$1(),
|
|
1944
|
+
name: ReplaceAll
|
|
1855
1945
|
}]));
|
|
1856
1946
|
}
|
|
1857
1947
|
return dom;
|
|
@@ -2365,7 +2455,7 @@ function promisifyRequest(request) {
|
|
|
2365
2455
|
request.removeEventListener('error', error);
|
|
2366
2456
|
};
|
|
2367
2457
|
const success = () => {
|
|
2368
|
-
resolve(wrap(request.result));
|
|
2458
|
+
resolve(wrap$2(request.result));
|
|
2369
2459
|
unlisten();
|
|
2370
2460
|
};
|
|
2371
2461
|
const error = () => {
|
|
@@ -2415,7 +2505,7 @@ let idbProxyTraps = {
|
|
|
2415
2505
|
}
|
|
2416
2506
|
}
|
|
2417
2507
|
// Else transform whatever we get back.
|
|
2418
|
-
return wrap(target[prop]);
|
|
2508
|
+
return wrap$2(target[prop]);
|
|
2419
2509
|
},
|
|
2420
2510
|
set(target, prop, value) {
|
|
2421
2511
|
target[prop] = value;
|
|
@@ -2444,13 +2534,13 @@ function wrapFunction(func) {
|
|
|
2444
2534
|
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
2445
2535
|
// the original object.
|
|
2446
2536
|
func.apply(unwrap(this), args);
|
|
2447
|
-
return wrap(this.request);
|
|
2537
|
+
return wrap$2(this.request);
|
|
2448
2538
|
};
|
|
2449
2539
|
}
|
|
2450
2540
|
return function (...args) {
|
|
2451
2541
|
// Calling the original function with the proxy as 'this' causes ILLEGAL INVOCATION, so we use
|
|
2452
2542
|
// the original object.
|
|
2453
|
-
return wrap(func.apply(unwrap(this), args));
|
|
2543
|
+
return wrap$2(func.apply(unwrap(this), args));
|
|
2454
2544
|
};
|
|
2455
2545
|
}
|
|
2456
2546
|
function transformCachableValue(value) {
|
|
@@ -2462,7 +2552,7 @@ function transformCachableValue(value) {
|
|
|
2462
2552
|
// Return the same value back if we're not going to transform it.
|
|
2463
2553
|
return value;
|
|
2464
2554
|
}
|
|
2465
|
-
function wrap(value) {
|
|
2555
|
+
function wrap$2(value) {
|
|
2466
2556
|
// We sometimes generate multiple promises from a single IDBRequest (eg when cursoring), because
|
|
2467
2557
|
// IDB is weird and a single IDBRequest can yield many responses, so these can't be cached.
|
|
2468
2558
|
if (value instanceof IDBRequest) return promisifyRequest(value);
|
|
@@ -2494,10 +2584,10 @@ function openDB(name, version, {
|
|
|
2494
2584
|
terminated
|
|
2495
2585
|
} = {}) {
|
|
2496
2586
|
const request = indexedDB.open(name, version);
|
|
2497
|
-
const openPromise = wrap(request);
|
|
2587
|
+
const openPromise = wrap$2(request);
|
|
2498
2588
|
if (upgrade) {
|
|
2499
2589
|
request.addEventListener('upgradeneeded', event => {
|
|
2500
|
-
upgrade(wrap(request.result), event.oldVersion, event.newVersion, wrap(request.transaction), event);
|
|
2590
|
+
upgrade(wrap$2(request.result), event.oldVersion, event.newVersion, wrap$2(request.transaction), event);
|
|
2501
2591
|
});
|
|
2502
2592
|
}
|
|
2503
2593
|
if (blocked) {
|
|
@@ -2807,6 +2897,7 @@ const handleUpdate = async (state, update) => {
|
|
|
2807
2897
|
maxLineY: 0,
|
|
2808
2898
|
deltaY: 0,
|
|
2809
2899
|
items: [],
|
|
2900
|
+
listItems: [],
|
|
2810
2901
|
matchCount: 0,
|
|
2811
2902
|
message: '',
|
|
2812
2903
|
loaded: true
|
|
@@ -2841,6 +2932,7 @@ const handleUpdate = async (state, update) => {
|
|
|
2841
2932
|
deltaY: 0,
|
|
2842
2933
|
value,
|
|
2843
2934
|
items: results,
|
|
2935
|
+
listItems: results,
|
|
2844
2936
|
message,
|
|
2845
2937
|
maxLineY: maxLineY,
|
|
2846
2938
|
scrollBarHeight,
|
|
@@ -2857,6 +2949,7 @@ const handleUpdate = async (state, update) => {
|
|
|
2857
2949
|
...partialNewState,
|
|
2858
2950
|
message: `${error}`,
|
|
2859
2951
|
items: [],
|
|
2952
|
+
listItems: [],
|
|
2860
2953
|
matchCount: 0,
|
|
2861
2954
|
fileCount: 0,
|
|
2862
2955
|
minLineY: 0,
|
|
@@ -2901,6 +2994,10 @@ const handleInput = (state, value, inputSource = Script) => {
|
|
|
2901
2994
|
});
|
|
2902
2995
|
};
|
|
2903
2996
|
|
|
2997
|
+
const handleListBlur = state => {
|
|
2998
|
+
return state;
|
|
2999
|
+
};
|
|
3000
|
+
|
|
2904
3001
|
const handleReplaceInput = (state, value, inputSource = Script) => {
|
|
2905
3002
|
return handleUpdate(state, {
|
|
2906
3003
|
replacement: value,
|
|
@@ -2926,6 +3023,296 @@ const handleSharedInput = (state, name, value, inputSource = Script) => {
|
|
|
2926
3023
|
return fn(state, value, inputSource);
|
|
2927
3024
|
};
|
|
2928
3025
|
|
|
3026
|
+
const NodeAlternate = 8;
|
|
3027
|
+
|
|
3028
|
+
const getData = event => {
|
|
3029
|
+
const {
|
|
3030
|
+
data
|
|
3031
|
+
} = event;
|
|
3032
|
+
return data;
|
|
3033
|
+
};
|
|
3034
|
+
|
|
3035
|
+
const getPortTuple = () => {
|
|
3036
|
+
const {
|
|
3037
|
+
port1,
|
|
3038
|
+
port2
|
|
3039
|
+
} = new MessageChannel();
|
|
3040
|
+
return {
|
|
3041
|
+
port1,
|
|
3042
|
+
port2
|
|
3043
|
+
};
|
|
3044
|
+
};
|
|
3045
|
+
|
|
3046
|
+
const Open = 1;
|
|
3047
|
+
const Close = 2;
|
|
3048
|
+
|
|
3049
|
+
const Https = 'https:';
|
|
3050
|
+
const Ws = 'ws:';
|
|
3051
|
+
const Wss = 'wss:';
|
|
3052
|
+
|
|
3053
|
+
const getWebSocketProtocol = () => {
|
|
3054
|
+
return location.protocol === Https ? Wss : Ws;
|
|
3055
|
+
};
|
|
3056
|
+
|
|
3057
|
+
const getWebSocketUrl = (type, host) => {
|
|
3058
|
+
const wsProtocol = getWebSocketProtocol();
|
|
3059
|
+
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
3060
|
+
};
|
|
3061
|
+
|
|
3062
|
+
class IpcError extends Error {
|
|
3063
|
+
constructor(message) {
|
|
3064
|
+
super(message);
|
|
3065
|
+
this.name = 'IpcError';
|
|
3066
|
+
}
|
|
3067
|
+
}
|
|
3068
|
+
|
|
3069
|
+
const stringifyCompact = value => {
|
|
3070
|
+
return JSON.stringify(value);
|
|
3071
|
+
};
|
|
3072
|
+
const parse = content => {
|
|
3073
|
+
if (content === 'undefined') {
|
|
3074
|
+
return null;
|
|
3075
|
+
}
|
|
3076
|
+
// TODO use better json parse to throw more helpful error messages if json is invalid
|
|
3077
|
+
try {
|
|
3078
|
+
return JSON.parse(content);
|
|
3079
|
+
} catch (error) {
|
|
3080
|
+
throw new VError(error, 'failed to parse json');
|
|
3081
|
+
}
|
|
3082
|
+
};
|
|
3083
|
+
|
|
3084
|
+
const create$3 = (url, args) => {
|
|
3085
|
+
const webSocket = new WebSocket(url, args);
|
|
3086
|
+
const reconnect = () => {
|
|
3087
|
+
const originalOnMessage = context.webSocket.onmessage;
|
|
3088
|
+
context.webSocket = new WebSocket(url, args);
|
|
3089
|
+
context.webSocket.onmessage = originalOnMessage;
|
|
3090
|
+
context.webSocket.onclose = handleClose;
|
|
3091
|
+
};
|
|
3092
|
+
const handleClose = () => {
|
|
3093
|
+
setTimeout(reconnect, 2000);
|
|
3094
|
+
};
|
|
3095
|
+
const context = {
|
|
3096
|
+
webSocket,
|
|
3097
|
+
get onmessage() {
|
|
3098
|
+
return this.webSocket.onmessage;
|
|
3099
|
+
},
|
|
3100
|
+
set onmessage(value) {
|
|
3101
|
+
this.webSocket.onmessage = value;
|
|
3102
|
+
},
|
|
3103
|
+
send(message) {
|
|
3104
|
+
this.webSocket.send(message);
|
|
3105
|
+
},
|
|
3106
|
+
addEventListener(type, listener) {
|
|
3107
|
+
this.webSocket.addEventListener(type, listener);
|
|
3108
|
+
},
|
|
3109
|
+
removeEventListener(type, listener) {
|
|
3110
|
+
this.webSocket.removeEventListener(type, listener);
|
|
3111
|
+
}
|
|
3112
|
+
};
|
|
3113
|
+
webSocket.onclose = handleClose;
|
|
3114
|
+
return context;
|
|
3115
|
+
};
|
|
3116
|
+
|
|
3117
|
+
const getFirstEvent = (eventTarget, eventMap) => {
|
|
3118
|
+
const {
|
|
3119
|
+
resolve,
|
|
3120
|
+
promise
|
|
3121
|
+
} = Promise.withResolvers();
|
|
3122
|
+
const listenerMap = Object.create(null);
|
|
3123
|
+
const cleanup = value => {
|
|
3124
|
+
for (const event of Object.keys(eventMap)) {
|
|
3125
|
+
eventTarget.removeEventListener(event, listenerMap[event]);
|
|
3126
|
+
}
|
|
3127
|
+
resolve(value);
|
|
3128
|
+
};
|
|
3129
|
+
for (const [event, type] of Object.entries(eventMap)) {
|
|
3130
|
+
const listener = event => {
|
|
3131
|
+
cleanup({
|
|
3132
|
+
type,
|
|
3133
|
+
event
|
|
3134
|
+
});
|
|
3135
|
+
};
|
|
3136
|
+
eventTarget.addEventListener(event, listener);
|
|
3137
|
+
listenerMap[event] = listener;
|
|
3138
|
+
}
|
|
3139
|
+
return promise;
|
|
3140
|
+
};
|
|
3141
|
+
|
|
3142
|
+
const waitForWebSocketToBeOpen = webSocket => {
|
|
3143
|
+
return getFirstEvent(webSocket, {
|
|
3144
|
+
open: Open,
|
|
3145
|
+
close: Close
|
|
3146
|
+
});
|
|
3147
|
+
};
|
|
3148
|
+
|
|
3149
|
+
const getHost = () => {
|
|
3150
|
+
return location.host;
|
|
3151
|
+
};
|
|
3152
|
+
|
|
3153
|
+
const create$2 = async ({
|
|
3154
|
+
type
|
|
3155
|
+
}) => {
|
|
3156
|
+
string(type);
|
|
3157
|
+
const host = getHost();
|
|
3158
|
+
const wsUrl = getWebSocketUrl(type, host);
|
|
3159
|
+
const webSocket = create$3(wsUrl);
|
|
3160
|
+
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
3161
|
+
if (firstWebSocketEvent.type === Close) {
|
|
3162
|
+
throw new IpcError('Websocket connection was immediately closed');
|
|
3163
|
+
}
|
|
3164
|
+
return webSocket;
|
|
3165
|
+
};
|
|
3166
|
+
const getMessage = event => {
|
|
3167
|
+
return parse(event.data);
|
|
3168
|
+
};
|
|
3169
|
+
const wrap$1 = webSocket => {
|
|
3170
|
+
return {
|
|
3171
|
+
webSocket,
|
|
3172
|
+
/**
|
|
3173
|
+
* @type {any}
|
|
3174
|
+
*/
|
|
3175
|
+
listener: undefined,
|
|
3176
|
+
get onmessage() {
|
|
3177
|
+
return this.listener;
|
|
3178
|
+
},
|
|
3179
|
+
set onmessage(listener) {
|
|
3180
|
+
this.listener = listener;
|
|
3181
|
+
const wrappedListener = event => {
|
|
3182
|
+
const message = getMessage(event);
|
|
3183
|
+
const syntheticEvent = {
|
|
3184
|
+
data: message,
|
|
3185
|
+
target: this
|
|
3186
|
+
};
|
|
3187
|
+
listener(syntheticEvent);
|
|
3188
|
+
};
|
|
3189
|
+
this.webSocket.onmessage = wrappedListener;
|
|
3190
|
+
},
|
|
3191
|
+
send(message) {
|
|
3192
|
+
const stringifiedMessage = stringifyCompact(message);
|
|
3193
|
+
this.webSocket.send(stringifiedMessage);
|
|
3194
|
+
}
|
|
3195
|
+
};
|
|
3196
|
+
};
|
|
3197
|
+
|
|
3198
|
+
const IpcParentWithWebSocket = {
|
|
3199
|
+
__proto__: null,
|
|
3200
|
+
create: create$2,
|
|
3201
|
+
wrap: wrap$1
|
|
3202
|
+
};
|
|
3203
|
+
|
|
3204
|
+
const Web = 1;
|
|
3205
|
+
const Electron = 2;
|
|
3206
|
+
const Remote = 3;
|
|
3207
|
+
|
|
3208
|
+
const sendMessagePortToElectron = async (port, initialCommand, ipcId) => {
|
|
3209
|
+
object(port);
|
|
3210
|
+
string(initialCommand);
|
|
3211
|
+
await invokeAndTransfer(initialCommand, port, ipcId);
|
|
3212
|
+
};
|
|
3213
|
+
|
|
3214
|
+
const create$1 = async options => {
|
|
3215
|
+
switch (options.platform) {
|
|
3216
|
+
case Web:
|
|
3217
|
+
case Remote:
|
|
3218
|
+
const module = IpcParentWithWebSocket;
|
|
3219
|
+
const rawIpc = await module.create(options);
|
|
3220
|
+
if (options.raw) {
|
|
3221
|
+
return rawIpc;
|
|
3222
|
+
}
|
|
3223
|
+
return {
|
|
3224
|
+
rawIpc,
|
|
3225
|
+
module
|
|
3226
|
+
};
|
|
3227
|
+
case Electron:
|
|
3228
|
+
const {
|
|
3229
|
+
port1,
|
|
3230
|
+
port2
|
|
3231
|
+
} = getPortTuple();
|
|
3232
|
+
await sendMessagePortToElectron(port2, options.initialCommand, options.ipcId);
|
|
3233
|
+
return port1;
|
|
3234
|
+
default:
|
|
3235
|
+
throw new Error('unsupported platform');
|
|
3236
|
+
}
|
|
3237
|
+
};
|
|
3238
|
+
const wrap = port => {
|
|
3239
|
+
if (!(port instanceof MessagePort)) {
|
|
3240
|
+
return port.module.wrap(port.rawIpc);
|
|
3241
|
+
}
|
|
3242
|
+
return {
|
|
3243
|
+
port,
|
|
3244
|
+
/**
|
|
3245
|
+
* @type {any}
|
|
3246
|
+
*/
|
|
3247
|
+
listener: undefined,
|
|
3248
|
+
get onmessage() {
|
|
3249
|
+
return this.listener;
|
|
3250
|
+
},
|
|
3251
|
+
set onmessage(listener) {
|
|
3252
|
+
this.listener = listener;
|
|
3253
|
+
const wrappedListener = event => {
|
|
3254
|
+
const data = getData(event);
|
|
3255
|
+
const syntheticEvent = {
|
|
3256
|
+
data,
|
|
3257
|
+
target: this
|
|
3258
|
+
};
|
|
3259
|
+
listener(syntheticEvent);
|
|
3260
|
+
};
|
|
3261
|
+
this.port.onmessage = wrappedListener;
|
|
3262
|
+
},
|
|
3263
|
+
send(message) {
|
|
3264
|
+
this.port.postMessage(message);
|
|
3265
|
+
},
|
|
3266
|
+
sendAndTransfer(message, transfer) {
|
|
3267
|
+
this.port.postMessage(message, transfer);
|
|
3268
|
+
}
|
|
3269
|
+
};
|
|
3270
|
+
};
|
|
3271
|
+
|
|
3272
|
+
const IpcParentWithNodeAlternate = {
|
|
3273
|
+
__proto__: null,
|
|
3274
|
+
create: create$1,
|
|
3275
|
+
wrap
|
|
3276
|
+
};
|
|
3277
|
+
|
|
3278
|
+
const getModule = method => {
|
|
3279
|
+
switch (method) {
|
|
3280
|
+
case NodeAlternate:
|
|
3281
|
+
return IpcParentWithNodeAlternate;
|
|
3282
|
+
default:
|
|
3283
|
+
throw new Error('unexpected ipc type');
|
|
3284
|
+
}
|
|
3285
|
+
};
|
|
3286
|
+
|
|
3287
|
+
const create = async ({
|
|
3288
|
+
method,
|
|
3289
|
+
...options
|
|
3290
|
+
}) => {
|
|
3291
|
+
const module = getModule(method);
|
|
3292
|
+
// @ts-ignore
|
|
3293
|
+
const rawIpc = await module.create(options);
|
|
3294
|
+
if (options.noReturn) {
|
|
3295
|
+
return undefined;
|
|
3296
|
+
}
|
|
3297
|
+
if (options.raw) {
|
|
3298
|
+
return rawIpc;
|
|
3299
|
+
}
|
|
3300
|
+
const ipc = module.wrap(rawIpc);
|
|
3301
|
+
return ipc;
|
|
3302
|
+
};
|
|
3303
|
+
|
|
3304
|
+
const launchSearchProcess = async () => {
|
|
3305
|
+
const ipc = await create({
|
|
3306
|
+
method: NodeAlternate,
|
|
3307
|
+
type: 'search-process',
|
|
3308
|
+
name: 'Search Process',
|
|
3309
|
+
initialCommand: 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess'
|
|
3310
|
+
});
|
|
3311
|
+
// TODO
|
|
3312
|
+
// HandleIpc.handleIpc(ipc)
|
|
3313
|
+
return ipc;
|
|
3314
|
+
};
|
|
3315
|
+
|
|
2929
3316
|
const first = () => {
|
|
2930
3317
|
return 0;
|
|
2931
3318
|
};
|
|
@@ -3063,23 +3450,65 @@ const focusPreviousPage = state => {
|
|
|
3063
3450
|
return focusIndex(state, indexPreviousPage);
|
|
3064
3451
|
};
|
|
3065
3452
|
|
|
3066
|
-
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight) => {
|
|
3067
|
-
const relativeY = eventY - y + deltaY;
|
|
3453
|
+
const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight) => {
|
|
3454
|
+
const relativeY = eventY - y - topHeight + deltaY;
|
|
3068
3455
|
const index = Math.floor(relativeY / itemHeight);
|
|
3069
3456
|
return index;
|
|
3070
3457
|
};
|
|
3071
3458
|
|
|
3459
|
+
const getTopHeight = flags => {
|
|
3460
|
+
if (flags & ReplaceExpanded && flags & DetailsExpanded) {
|
|
3461
|
+
return 190;
|
|
3462
|
+
}
|
|
3463
|
+
if (flags & DetailsExpanded) {
|
|
3464
|
+
return 158;
|
|
3465
|
+
}
|
|
3466
|
+
if (flags & ReplaceExpanded) {
|
|
3467
|
+
return 93;
|
|
3468
|
+
}
|
|
3469
|
+
return 61;
|
|
3470
|
+
};
|
|
3471
|
+
|
|
3472
|
+
const getFilteredResults = (results, collapsedPaths) => {
|
|
3473
|
+
if (collapsedPaths.length === 0) {
|
|
3474
|
+
return results;
|
|
3475
|
+
}
|
|
3476
|
+
const filteredResults = [];
|
|
3477
|
+
let isExcluded = false;
|
|
3478
|
+
for (const result of results) {
|
|
3479
|
+
if (result.type === File$1) {
|
|
3480
|
+
if (collapsedPaths.includes(result.text)) {
|
|
3481
|
+
isExcluded = true;
|
|
3482
|
+
} else {
|
|
3483
|
+
isExcluded = false;
|
|
3484
|
+
}
|
|
3485
|
+
}
|
|
3486
|
+
if (!isExcluded) {
|
|
3487
|
+
filteredResults.push(result);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
return filteredResults;
|
|
3491
|
+
};
|
|
3492
|
+
|
|
3072
3493
|
const selectIndexFile = (state, searchResult, index) => {
|
|
3073
3494
|
const {
|
|
3074
|
-
collapsedPaths
|
|
3495
|
+
collapsedPaths,
|
|
3496
|
+
items,
|
|
3497
|
+
maxLineY
|
|
3075
3498
|
} = state;
|
|
3076
3499
|
const path = getAbsolutePath(searchResult.text);
|
|
3077
3500
|
string(path);
|
|
3501
|
+
const pathWithDot = `.${path}`;
|
|
3502
|
+
const newCollapsedPaths = [...collapsedPaths, path, pathWithDot];
|
|
3503
|
+
const filteredResults = getFilteredResults(items, collapsedPaths);
|
|
3504
|
+
const newMaxLineY = Math.min(maxLineY, filteredResults.length);
|
|
3078
3505
|
return {
|
|
3079
3506
|
...state,
|
|
3080
|
-
collapsedPaths:
|
|
3507
|
+
collapsedPaths: newCollapsedPaths,
|
|
3081
3508
|
listFocusedIndex: index,
|
|
3082
|
-
listFocused: true
|
|
3509
|
+
listFocused: true,
|
|
3510
|
+
listItems: filteredResults,
|
|
3511
|
+
maxLineY: newMaxLineY
|
|
3083
3512
|
};
|
|
3084
3513
|
};
|
|
3085
3514
|
|
|
@@ -3143,14 +3572,16 @@ const selectIndex = async (state, index) => {
|
|
|
3143
3572
|
}
|
|
3144
3573
|
};
|
|
3145
3574
|
|
|
3146
|
-
const handleClickAt =
|
|
3575
|
+
const handleClickAt = (state, eventX, eventY) => {
|
|
3147
3576
|
const {
|
|
3148
3577
|
x,
|
|
3149
3578
|
y,
|
|
3150
3579
|
itemHeight,
|
|
3151
|
-
deltaY
|
|
3580
|
+
deltaY,
|
|
3581
|
+
flags
|
|
3152
3582
|
} = state;
|
|
3153
|
-
const
|
|
3583
|
+
const topHeight = getTopHeight(flags);
|
|
3584
|
+
const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight);
|
|
3154
3585
|
return selectIndex(state, index);
|
|
3155
3586
|
};
|
|
3156
3587
|
|
|
@@ -3329,23 +3760,34 @@ const refresh = state => {
|
|
|
3329
3760
|
return handleUpdate(state, {});
|
|
3330
3761
|
};
|
|
3331
3762
|
|
|
3332
|
-
// TODO just return name
|
|
3333
3763
|
const getFocusSelector = focusKey => {
|
|
3334
3764
|
switch (focusKey) {
|
|
3335
3765
|
case FocusSearchInput:
|
|
3336
|
-
return
|
|
3766
|
+
return SearchValue;
|
|
3337
3767
|
case FocusSearchReplaceInput:
|
|
3338
|
-
return
|
|
3768
|
+
return ReplaceValue;
|
|
3769
|
+
case FocusToggleDetails:
|
|
3770
|
+
return ToggleSearchDetails;
|
|
3339
3771
|
case FocusSearchMatchCase:
|
|
3340
|
-
return
|
|
3772
|
+
return MatchCase;
|
|
3341
3773
|
case FocusSearchPreserveCase:
|
|
3342
|
-
return
|
|
3774
|
+
return PreserveCase;
|
|
3343
3775
|
case FocusSearchRegex:
|
|
3344
|
-
return
|
|
3776
|
+
return UseRegularExpression;
|
|
3345
3777
|
case FocusSearchIncludeInput:
|
|
3346
|
-
return
|
|
3778
|
+
return FilesToInclude;
|
|
3347
3779
|
case FocusSearchExcludeInput:
|
|
3348
|
-
return
|
|
3780
|
+
return FilesToExclude;
|
|
3781
|
+
case FocusSearchWholeWord:
|
|
3782
|
+
return MatchWholeWord;
|
|
3783
|
+
case FocusSearchReplaceAll:
|
|
3784
|
+
return ReplaceAll;
|
|
3785
|
+
case FocusSearchOpenEditors:
|
|
3786
|
+
return SearchOnlyOpenEditors;
|
|
3787
|
+
case FocusIgnoreFiles:
|
|
3788
|
+
return UseExcludeSettings;
|
|
3789
|
+
case FocusToggleReplace:
|
|
3790
|
+
return ToggleReplace;
|
|
3349
3791
|
default:
|
|
3350
3792
|
return '';
|
|
3351
3793
|
}
|
|
@@ -3356,7 +3798,7 @@ const renderItems = {
|
|
|
3356
3798
|
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;
|
|
3357
3799
|
},
|
|
3358
3800
|
apply(oldState, newState) {
|
|
3359
|
-
const displayResults = getDisplayResults(newState.
|
|
3801
|
+
const displayResults = getDisplayResults(newState.listItems, newState.itemHeight, newState.fileCount, newState.value, newState.minLineY, newState.maxLineY, newState.replacement, newState.icons, newState.listFocusedIndex);
|
|
3360
3802
|
const focusOutline = newState.listFocused && newState.listFocusedIndex === -1;
|
|
3361
3803
|
const dom = getSearchVirtualDom(displayResults, newState.flags, newState.message, focusOutline);
|
|
3362
3804
|
return ['Viewlet.setDom2', newState.uid, dom];
|
|
@@ -3367,8 +3809,8 @@ const renderFocus = {
|
|
|
3367
3809
|
return oldState.focus === newState.focus || newState.focusSource === User;
|
|
3368
3810
|
},
|
|
3369
3811
|
apply(oldState, newState) {
|
|
3370
|
-
const
|
|
3371
|
-
return ['Viewlet.
|
|
3812
|
+
const name = newState.focusSource === User ? '' : getFocusSelector(newState.focus);
|
|
3813
|
+
return ['Viewlet.focusElementByName', name];
|
|
3372
3814
|
}
|
|
3373
3815
|
};
|
|
3374
3816
|
const renderValue = {
|
|
@@ -3541,20 +3983,30 @@ const setFocus = async focusKey => {
|
|
|
3541
3983
|
|
|
3542
3984
|
const getSearchFocusKey = key => {
|
|
3543
3985
|
switch (key) {
|
|
3544
|
-
case
|
|
3986
|
+
case SearchValue:
|
|
3545
3987
|
return FocusSearchInput;
|
|
3546
|
-
case
|
|
3988
|
+
case ReplaceValue:
|
|
3547
3989
|
return FocusSearchReplaceInput;
|
|
3548
|
-
case
|
|
3990
|
+
case MatchCase:
|
|
3549
3991
|
return FocusSearchMatchCase;
|
|
3550
|
-
case
|
|
3992
|
+
case MatchWholeWord:
|
|
3551
3993
|
return FocusSearchWholeWord;
|
|
3552
|
-
case
|
|
3994
|
+
case UseRegularExpression:
|
|
3553
3995
|
return FocusSearchRegex;
|
|
3554
|
-
case
|
|
3996
|
+
case ReplaceAll:
|
|
3555
3997
|
return FocusSearchReplaceAll;
|
|
3556
|
-
case
|
|
3998
|
+
case PreserveCase:
|
|
3557
3999
|
return FocusSearchPreserveCase;
|
|
4000
|
+
case ToggleSearchDetails:
|
|
4001
|
+
return FocusToggleDetails;
|
|
4002
|
+
case FilesToInclude:
|
|
4003
|
+
return FocusSearchIncludeInput;
|
|
4004
|
+
case FilesToExclude:
|
|
4005
|
+
return FocusSearchExcludeInput;
|
|
4006
|
+
case SearchOnlyOpenEditors:
|
|
4007
|
+
return FocusSearchOpenEditors;
|
|
4008
|
+
case UseExcludeSettings:
|
|
4009
|
+
return FocusIgnoreFiles;
|
|
3558
4010
|
default:
|
|
3559
4011
|
return Empty$1;
|
|
3560
4012
|
}
|
|
@@ -3578,6 +4030,9 @@ const focusReplaceValueNext = state => {
|
|
|
3578
4030
|
const focusRegexNext = state => {
|
|
3579
4031
|
return focusPreserveCase(state);
|
|
3580
4032
|
};
|
|
4033
|
+
const focusPreserveCasePrevious = state => {
|
|
4034
|
+
return focusRegex(state);
|
|
4035
|
+
};
|
|
3581
4036
|
const focusReplaceValue = state => {
|
|
3582
4037
|
return focusElement(state, FocusSearchReplaceInput);
|
|
3583
4038
|
};
|
|
@@ -3601,7 +4056,7 @@ const handleFocusIn = (state, key) => {
|
|
|
3601
4056
|
if (state.focus === focusKey) {
|
|
3602
4057
|
return state;
|
|
3603
4058
|
}
|
|
3604
|
-
void setFocus(
|
|
4059
|
+
void setFocus(FocusSearch);
|
|
3605
4060
|
return {
|
|
3606
4061
|
...state,
|
|
3607
4062
|
focus: focusKey,
|
|
@@ -3647,11 +4102,11 @@ const toggleDetailsExpanded = state => {
|
|
|
3647
4102
|
};
|
|
3648
4103
|
|
|
3649
4104
|
const toggleMatchCase = state => {
|
|
3650
|
-
return toggleSearchFlag(state, MatchCase);
|
|
4105
|
+
return toggleSearchFlag(state, MatchCase$1);
|
|
3651
4106
|
};
|
|
3652
4107
|
|
|
3653
4108
|
const toggleMatchWholeWord = state => {
|
|
3654
|
-
return toggleSearchFlag(state, MatchWholeWord);
|
|
4109
|
+
return toggleSearchFlag(state, MatchWholeWord$1);
|
|
3655
4110
|
};
|
|
3656
4111
|
|
|
3657
4112
|
const toggleOpenEditors = state => {
|
|
@@ -3659,7 +4114,7 @@ const toggleOpenEditors = state => {
|
|
|
3659
4114
|
};
|
|
3660
4115
|
|
|
3661
4116
|
const togglePreserveCase = state => {
|
|
3662
|
-
return toggleSearchFlag(state, PreserveCase);
|
|
4117
|
+
return toggleSearchFlag(state, PreserveCase$1);
|
|
3663
4118
|
};
|
|
3664
4119
|
|
|
3665
4120
|
const toggleReplace = state => {
|
|
@@ -3671,7 +4126,7 @@ const toggleUseIgnoreFiles = state => {
|
|
|
3671
4126
|
};
|
|
3672
4127
|
|
|
3673
4128
|
const toggleUseRegularExpression = state => {
|
|
3674
|
-
return toggleSearchFlag(state, UseRegularExpression);
|
|
4129
|
+
return toggleSearchFlag(state, UseRegularExpression$1);
|
|
3675
4130
|
};
|
|
3676
4131
|
|
|
3677
4132
|
const Keyboard = -1;
|
|
@@ -3730,16 +4185,19 @@ const commandMap = {
|
|
|
3730
4185
|
'TextSearch.focusMatchCasePrevious': wrapCommand(focusMatchCasePrevious),
|
|
3731
4186
|
'TextSearch.focusMatchWholeWord': wrapCommand(focusMatchWholeWord),
|
|
3732
4187
|
'TextSearch.focusNext': wrapCommand(focusNext),
|
|
4188
|
+
'TextSearch.focusNextInput': wrapCommand(focusNextInput),
|
|
3733
4189
|
'TextSearch.focusNextPage': wrapCommand(focusNextPage),
|
|
3734
4190
|
'TextSearch.focusPreserveCase': wrapCommand(focusPreserveCase),
|
|
4191
|
+
'TextSearch.focusPreserveCasePrevious': wrapCommand(focusPreserveCasePrevious),
|
|
3735
4192
|
'TextSearch.focusPrevious': wrapCommand(focusPrevious),
|
|
4193
|
+
'TextSearch.focusPreviousInput': wrapCommand(focusPreviousInput),
|
|
3736
4194
|
'TextSearch.focusPreviousPage': wrapCommand(focusPreviousPage),
|
|
3737
4195
|
'TextSearch.focusRegex': wrapCommand(focusRegex),
|
|
3738
4196
|
'TextSearch.focusRegexNext': wrapCommand(focusRegexNext),
|
|
3739
4197
|
'TextSearch.focusReplaceAll': wrapCommand(focusReplaceAll),
|
|
3740
4198
|
'TextSearch.focusReplaceValue': wrapCommand(focusReplaceValue$1),
|
|
3741
|
-
'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
|
|
3742
4199
|
'TextSearch.focusReplaceValueNext': wrapCommand(focusReplaceValueNext),
|
|
4200
|
+
'TextSearch.focusReplaceValuePrevious': wrapCommand(focusReplaceValuePrevious),
|
|
3743
4201
|
'TextSearch.focusSearchValue': wrapCommand(focusSearchValue$1),
|
|
3744
4202
|
'TextSearch.focusSearchValueNext': wrapCommand(focusSearchValueNext),
|
|
3745
4203
|
'TextSearch.getActions': wrapCommand(getActions),
|
|
@@ -3748,17 +4206,19 @@ const commandMap = {
|
|
|
3748
4206
|
'TextSearch.getVirtualDom': wrapCommand(getSearchVirtualDom),
|
|
3749
4207
|
'TextSearch.handleClickAt': wrapCommand(handleClickAt),
|
|
3750
4208
|
'TextSearch.handleContextMenu': wrapCommand(handleContextMenu),
|
|
4209
|
+
'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
|
|
3751
4210
|
'TextSearch.handleFocusIn': wrapCommand(handleFocusIn),
|
|
3752
4211
|
'TextSearch.handleIconThemeChange': wrapCommand(handleIconThemeChange),
|
|
4212
|
+
'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
|
|
3753
4213
|
'TextSearch.handleInput': wrapCommand(handleInput),
|
|
4214
|
+
'TextSearch.handleListBlur': wrapCommand(handleListBlur),
|
|
3754
4215
|
'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
|
|
3755
|
-
'TextSearch.handleIncludeInput': wrapCommand(handleIncludeInput),
|
|
3756
|
-
'TextSearch.handleExcludeInput': wrapCommand(handleExcludeInput),
|
|
3757
4216
|
'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
|
|
3758
4217
|
'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
3759
4218
|
'TextSearch.handleScrollBarMove': wrapCommand(handleScrollBarMove),
|
|
3760
4219
|
'TextSearch.handleSharedInput': wrapCommand(handleSharedInput),
|
|
3761
4220
|
'TextSearch.handleWheel': wrapCommand(handleWheel),
|
|
4221
|
+
'TextSearch.launchSearchProcess': wrapCommand(launchSearchProcess),
|
|
3762
4222
|
'TextSearch.loadContent': wrapCommand(loadContent),
|
|
3763
4223
|
'TextSearch.refresh': wrapCommand(refresh),
|
|
3764
4224
|
'TextSearch.replaceAll': wrapCommand(replaceAll),
|
|
@@ -3773,7 +4233,7 @@ const commandMap = {
|
|
|
3773
4233
|
'TextSearch.toggleUseIgnoreFiles': wrapCommand(toggleUseIgnoreFiles),
|
|
3774
4234
|
'TextSearch.toggleUseRegularExpression': wrapCommand(toggleUseRegularExpression),
|
|
3775
4235
|
// not wrapped
|
|
3776
|
-
'TextSearch.create': create,
|
|
4236
|
+
'TextSearch.create': create$4,
|
|
3777
4237
|
'TextSearch.render': doRender,
|
|
3778
4238
|
'TextSearch.saveState': saveState,
|
|
3779
4239
|
'TextSearch.getKeyBindings': getKeyBindings,
|