@lvce-editor/text-search-view 1.0.1 → 1.1.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/textSearchViewMain.js +68 -384
- package/package.json +1 -1
|
@@ -435,9 +435,6 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
|
|
|
435
435
|
listen: listen$6,
|
|
436
436
|
wrap: wrap$e
|
|
437
437
|
};
|
|
438
|
-
const Error$3 = 1;
|
|
439
|
-
const Open = 2;
|
|
440
|
-
const Close = 3;
|
|
441
438
|
const addListener = (emitter, type, callback) => {
|
|
442
439
|
if ('addEventListener' in emitter) {
|
|
443
440
|
emitter.addEventListener(type, callback);
|
|
@@ -532,66 +529,6 @@ const IpcParentWithMessagePort$1 = {
|
|
|
532
529
|
signal: signal$1,
|
|
533
530
|
wrap: wrap$5
|
|
534
531
|
};
|
|
535
|
-
const stringifyCompact = value => {
|
|
536
|
-
return JSON.stringify(value);
|
|
537
|
-
};
|
|
538
|
-
const parse = content => {
|
|
539
|
-
if (content === 'undefined') {
|
|
540
|
-
return null;
|
|
541
|
-
}
|
|
542
|
-
try {
|
|
543
|
-
return JSON.parse(content);
|
|
544
|
-
} catch (error) {
|
|
545
|
-
throw new VError(error, 'failed to parse json');
|
|
546
|
-
}
|
|
547
|
-
};
|
|
548
|
-
const waitForWebSocketToBeOpen = webSocket => {
|
|
549
|
-
return getFirstEvent(webSocket, {
|
|
550
|
-
close: Close,
|
|
551
|
-
error: Error$3,
|
|
552
|
-
open: Open
|
|
553
|
-
});
|
|
554
|
-
};
|
|
555
|
-
const create$f = async ({
|
|
556
|
-
webSocket
|
|
557
|
-
}) => {
|
|
558
|
-
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
559
|
-
if (firstWebSocketEvent.type === Error$3) {
|
|
560
|
-
throw new IpcError(`WebSocket connection error`);
|
|
561
|
-
}
|
|
562
|
-
if (firstWebSocketEvent.type === Close) {
|
|
563
|
-
throw new IpcError('Websocket connection was immediately closed');
|
|
564
|
-
}
|
|
565
|
-
return webSocket;
|
|
566
|
-
};
|
|
567
|
-
class IpcParentWithWebSocket extends Ipc {
|
|
568
|
-
getData(event) {
|
|
569
|
-
return parse(event.data);
|
|
570
|
-
}
|
|
571
|
-
send(message) {
|
|
572
|
-
this._rawIpc.send(stringifyCompact(message));
|
|
573
|
-
}
|
|
574
|
-
sendAndTransfer(message) {
|
|
575
|
-
throw new Error('sendAndTransfer not supported');
|
|
576
|
-
}
|
|
577
|
-
dispose() {
|
|
578
|
-
this._rawIpc.close();
|
|
579
|
-
}
|
|
580
|
-
onClose(callback) {
|
|
581
|
-
this._rawIpc.addEventListener('close', callback);
|
|
582
|
-
}
|
|
583
|
-
onMessage(callback) {
|
|
584
|
-
this._rawIpc.addEventListener('message', callback);
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
const wrap = webSocket => {
|
|
588
|
-
return new IpcParentWithWebSocket(webSocket);
|
|
589
|
-
};
|
|
590
|
-
const IpcParentWithWebSocket$1 = {
|
|
591
|
-
__proto__: null,
|
|
592
|
-
create: create$f,
|
|
593
|
-
wrap
|
|
594
|
-
};
|
|
595
532
|
|
|
596
533
|
class CommandNotFoundError extends Error {
|
|
597
534
|
constructor(command) {
|
|
@@ -616,7 +553,7 @@ const execute = (command, ...args) => {
|
|
|
616
553
|
|
|
617
554
|
const Two$1 = '2.0';
|
|
618
555
|
const callbacks = Object.create(null);
|
|
619
|
-
const get$
|
|
556
|
+
const get$2 = id => {
|
|
620
557
|
return callbacks[id];
|
|
621
558
|
};
|
|
622
559
|
const remove$3 = id => {
|
|
@@ -806,7 +743,7 @@ const warn = (...args) => {
|
|
|
806
743
|
console.warn(...args);
|
|
807
744
|
};
|
|
808
745
|
const resolve = (id, response) => {
|
|
809
|
-
const fn = get$
|
|
746
|
+
const fn = get$2(id);
|
|
810
747
|
if (!fn) {
|
|
811
748
|
console.log(response);
|
|
812
749
|
warn(`callback ${id} may already be disposed`);
|
|
@@ -869,7 +806,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
869
806
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
870
807
|
return create$1$1(id, errorProperty);
|
|
871
808
|
};
|
|
872
|
-
const create$
|
|
809
|
+
const create$b = (message, result) => {
|
|
873
810
|
return {
|
|
874
811
|
id: message.id,
|
|
875
812
|
jsonrpc: Two$1,
|
|
@@ -878,7 +815,7 @@ const create$e = (message, result) => {
|
|
|
878
815
|
};
|
|
879
816
|
const getSuccessResponse = (message, result) => {
|
|
880
817
|
const resultProperty = result ?? null;
|
|
881
|
-
return create$
|
|
818
|
+
return create$b(message, resultProperty);
|
|
882
819
|
};
|
|
883
820
|
const getErrorResponseSimple = (id, error) => {
|
|
884
821
|
return {
|
|
@@ -972,7 +909,7 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
972
909
|
|
|
973
910
|
const Two = '2.0';
|
|
974
911
|
|
|
975
|
-
const create$
|
|
912
|
+
const create$a = (method, params) => {
|
|
976
913
|
return {
|
|
977
914
|
jsonrpc: Two,
|
|
978
915
|
method,
|
|
@@ -980,7 +917,7 @@ const create$d = (method, params) => {
|
|
|
980
917
|
};
|
|
981
918
|
};
|
|
982
919
|
|
|
983
|
-
const create$
|
|
920
|
+
const create$9 = (id, method, params) => {
|
|
984
921
|
const message = {
|
|
985
922
|
id,
|
|
986
923
|
jsonrpc: Two,
|
|
@@ -991,12 +928,12 @@ const create$c = (id, method, params) => {
|
|
|
991
928
|
};
|
|
992
929
|
|
|
993
930
|
let id = 0;
|
|
994
|
-
const create$
|
|
931
|
+
const create$8 = () => {
|
|
995
932
|
return ++id;
|
|
996
933
|
};
|
|
997
934
|
|
|
998
935
|
const registerPromise = map => {
|
|
999
|
-
const id = create$
|
|
936
|
+
const id = create$8();
|
|
1000
937
|
const {
|
|
1001
938
|
promise,
|
|
1002
939
|
resolve
|
|
@@ -1013,7 +950,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
1013
950
|
id,
|
|
1014
951
|
promise
|
|
1015
952
|
} = registerPromise(callbacks);
|
|
1016
|
-
const message = create$
|
|
953
|
+
const message = create$9(id, method, params);
|
|
1017
954
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1018
955
|
ipc.sendAndTransfer(message);
|
|
1019
956
|
} else {
|
|
@@ -1049,7 +986,7 @@ const createRpc = ipc => {
|
|
|
1049
986
|
* @deprecated
|
|
1050
987
|
*/
|
|
1051
988
|
send(method, ...params) {
|
|
1052
|
-
const message = create$
|
|
989
|
+
const message = create$a(method, params);
|
|
1053
990
|
ipc.send(message);
|
|
1054
991
|
}
|
|
1055
992
|
};
|
|
@@ -1089,7 +1026,7 @@ const listen$1 = async (module, options) => {
|
|
|
1089
1026
|
return ipc;
|
|
1090
1027
|
};
|
|
1091
1028
|
|
|
1092
|
-
const create$
|
|
1029
|
+
const create$7 = async ({
|
|
1093
1030
|
commandMap,
|
|
1094
1031
|
isMessagePortOpen = true,
|
|
1095
1032
|
messagePort
|
|
@@ -1107,7 +1044,7 @@ const create$a = async ({
|
|
|
1107
1044
|
return rpc;
|
|
1108
1045
|
};
|
|
1109
1046
|
|
|
1110
|
-
const create$
|
|
1047
|
+
const create$6 = async ({
|
|
1111
1048
|
commandMap,
|
|
1112
1049
|
isMessagePortOpen,
|
|
1113
1050
|
send
|
|
@@ -1117,7 +1054,7 @@ const create$9 = async ({
|
|
|
1117
1054
|
port2
|
|
1118
1055
|
} = new MessageChannel();
|
|
1119
1056
|
await send(port1);
|
|
1120
|
-
return create$
|
|
1057
|
+
return create$7({
|
|
1121
1058
|
commandMap,
|
|
1122
1059
|
isMessagePortOpen,
|
|
1123
1060
|
messagePort: port2
|
|
@@ -1152,13 +1089,13 @@ const createSharedLazyRpc = factory => {
|
|
|
1152
1089
|
};
|
|
1153
1090
|
};
|
|
1154
1091
|
|
|
1155
|
-
const create$
|
|
1092
|
+
const create$5 = async ({
|
|
1156
1093
|
commandMap,
|
|
1157
1094
|
isMessagePortOpen,
|
|
1158
1095
|
send
|
|
1159
1096
|
}) => {
|
|
1160
1097
|
return createSharedLazyRpc(() => {
|
|
1161
|
-
return create$
|
|
1098
|
+
return create$6({
|
|
1162
1099
|
commandMap,
|
|
1163
1100
|
isMessagePortOpen,
|
|
1164
1101
|
send
|
|
@@ -1166,73 +1103,6 @@ const create$8 = async ({
|
|
|
1166
1103
|
});
|
|
1167
1104
|
};
|
|
1168
1105
|
|
|
1169
|
-
const Https = 'https:';
|
|
1170
|
-
const Ws = 'ws:';
|
|
1171
|
-
const Wss = 'wss:';
|
|
1172
|
-
|
|
1173
|
-
const getWebSocketProtocol = locationProtocol => {
|
|
1174
|
-
return locationProtocol === Https ? Wss : Ws;
|
|
1175
|
-
};
|
|
1176
|
-
|
|
1177
|
-
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1178
|
-
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1179
|
-
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1180
|
-
};
|
|
1181
|
-
|
|
1182
|
-
const getHost = () => {
|
|
1183
|
-
return location.host;
|
|
1184
|
-
};
|
|
1185
|
-
const getProtocol$1 = () => {
|
|
1186
|
-
return location.protocol;
|
|
1187
|
-
};
|
|
1188
|
-
|
|
1189
|
-
const create$7 = async ({
|
|
1190
|
-
commandMap,
|
|
1191
|
-
webSocket
|
|
1192
|
-
}) => {
|
|
1193
|
-
// TODO create a commandMap per rpc instance
|
|
1194
|
-
register(commandMap);
|
|
1195
|
-
let rawIpc;
|
|
1196
|
-
try {
|
|
1197
|
-
rawIpc = await IpcParentWithWebSocket$1.create({
|
|
1198
|
-
webSocket
|
|
1199
|
-
});
|
|
1200
|
-
} catch (error) {
|
|
1201
|
-
throw new VError(error, 'Failed to create rpc connection');
|
|
1202
|
-
}
|
|
1203
|
-
const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
|
|
1204
|
-
handleIpc(ipc);
|
|
1205
|
-
const rpc = createRpc(ipc);
|
|
1206
|
-
return rpc;
|
|
1207
|
-
};
|
|
1208
|
-
|
|
1209
|
-
const create$6 = async ({
|
|
1210
|
-
commandMap,
|
|
1211
|
-
type
|
|
1212
|
-
}) => {
|
|
1213
|
-
const host = getHost();
|
|
1214
|
-
const protocol = getProtocol$1();
|
|
1215
|
-
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1216
|
-
const webSocket = new WebSocket(wsUrl);
|
|
1217
|
-
const rpc = await create$7({
|
|
1218
|
-
commandMap,
|
|
1219
|
-
webSocket
|
|
1220
|
-
});
|
|
1221
|
-
return rpc;
|
|
1222
|
-
};
|
|
1223
|
-
|
|
1224
|
-
const create$5 = async ({
|
|
1225
|
-
commandMap,
|
|
1226
|
-
type
|
|
1227
|
-
}) => {
|
|
1228
|
-
return createSharedLazyRpc(() => {
|
|
1229
|
-
return create$6({
|
|
1230
|
-
commandMap,
|
|
1231
|
-
type
|
|
1232
|
-
});
|
|
1233
|
-
});
|
|
1234
|
-
};
|
|
1235
|
-
|
|
1236
1106
|
const create$4 = async ({
|
|
1237
1107
|
commandMap
|
|
1238
1108
|
}) => {
|
|
@@ -1268,7 +1138,7 @@ const rpcs = Object.create(null);
|
|
|
1268
1138
|
const set$4 = (id, rpc) => {
|
|
1269
1139
|
rpcs[id] = rpc;
|
|
1270
1140
|
};
|
|
1271
|
-
const get$
|
|
1141
|
+
const get$1 = id => {
|
|
1272
1142
|
return rpcs[id];
|
|
1273
1143
|
};
|
|
1274
1144
|
const remove$2 = id => {
|
|
@@ -1279,18 +1149,18 @@ const remove$2 = id => {
|
|
|
1279
1149
|
const create$3 = rpcId => {
|
|
1280
1150
|
return {
|
|
1281
1151
|
async dispose() {
|
|
1282
|
-
const rpc = get$
|
|
1152
|
+
const rpc = get$1(rpcId);
|
|
1283
1153
|
await rpc.dispose();
|
|
1284
1154
|
},
|
|
1285
1155
|
// @ts-ignore
|
|
1286
1156
|
invoke(method, ...params) {
|
|
1287
|
-
const rpc = get$
|
|
1157
|
+
const rpc = get$1(rpcId);
|
|
1288
1158
|
// @ts-ignore
|
|
1289
1159
|
return rpc.invoke(method, ...params);
|
|
1290
1160
|
},
|
|
1291
1161
|
// @ts-ignore
|
|
1292
1162
|
invokeAndTransfer(method, ...params) {
|
|
1293
|
-
const rpc = get$
|
|
1163
|
+
const rpc = get$1(rpcId);
|
|
1294
1164
|
// @ts-ignore
|
|
1295
1165
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1296
1166
|
},
|
|
@@ -1572,12 +1442,9 @@ const None$1 = 0;
|
|
|
1572
1442
|
|
|
1573
1443
|
const LeftClick = 0;
|
|
1574
1444
|
|
|
1575
|
-
const Electron = 2;
|
|
1576
|
-
const Remote = 3;
|
|
1577
|
-
|
|
1578
1445
|
const IconThemeWorker = 7009;
|
|
1579
1446
|
const RendererWorker = 1;
|
|
1580
|
-
const
|
|
1447
|
+
const TextSearchWorker = 7010;
|
|
1581
1448
|
|
|
1582
1449
|
const File$1 = 1;
|
|
1583
1450
|
const Match$1 = 2;
|
|
@@ -1626,6 +1493,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1626
1493
|
number(y);
|
|
1627
1494
|
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1628
1495
|
};
|
|
1496
|
+
const sendMessagePortToTextSearchWorker = async (port, rpcId) => {
|
|
1497
|
+
const command = 'HandleMessagePort.handleMessagePort';
|
|
1498
|
+
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextSearchWorker', port, command, rpcId);
|
|
1499
|
+
};
|
|
1629
1500
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1630
1501
|
const command = 'IconTheme.handleMessagePort';
|
|
1631
1502
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
@@ -1633,9 +1504,6 @@ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
|
1633
1504
|
const handleWorkspaceRefresh = async () => {
|
|
1634
1505
|
return invoke$1('Layout.handleWorkspaceRefresh');
|
|
1635
1506
|
};
|
|
1636
|
-
const sendMessagePortToSearchProcess = async port => {
|
|
1637
|
-
await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
|
|
1638
|
-
};
|
|
1639
1507
|
const writeClipBoardText = async text => {
|
|
1640
1508
|
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1641
1509
|
};
|
|
@@ -1649,7 +1517,16 @@ const openUri$1 = async (uri, focus, options) => {
|
|
|
1649
1517
|
const {
|
|
1650
1518
|
invoke,
|
|
1651
1519
|
set: set$1
|
|
1652
|
-
} = create$3(
|
|
1520
|
+
} = create$3(TextSearchWorker);
|
|
1521
|
+
const getIncrementalResults = async (searchId, minLineY, maxLineY) => {
|
|
1522
|
+
return invoke('TextSearch.getIncrementalResults', searchId, minLineY, maxLineY);
|
|
1523
|
+
};
|
|
1524
|
+
const search$1 = async (...args) => {
|
|
1525
|
+
return invoke('TextSearch.search', ...args);
|
|
1526
|
+
};
|
|
1527
|
+
const searchIncremental = async (...args) => {
|
|
1528
|
+
return invoke('TextSearch.searchIncremental', ...args);
|
|
1529
|
+
};
|
|
1653
1530
|
|
|
1654
1531
|
const toCommandId = key => {
|
|
1655
1532
|
const dotIndex = key.indexOf('.');
|
|
@@ -2545,7 +2422,7 @@ defaultExcludes.join(',');
|
|
|
2545
2422
|
const minimumSliderSize = 20;
|
|
2546
2423
|
|
|
2547
2424
|
const {
|
|
2548
|
-
get
|
|
2425
|
+
get,
|
|
2549
2426
|
getCommandIds,
|
|
2550
2427
|
registerCommands,
|
|
2551
2428
|
set,
|
|
@@ -2722,7 +2599,7 @@ const diff2 = uid => {
|
|
|
2722
2599
|
const {
|
|
2723
2600
|
newState,
|
|
2724
2601
|
oldState
|
|
2725
|
-
} = get
|
|
2602
|
+
} = get(uid);
|
|
2726
2603
|
const diffResult = diff(oldState, newState);
|
|
2727
2604
|
return diffResult;
|
|
2728
2605
|
};
|
|
@@ -3701,25 +3578,8 @@ const getTextSearchResultCounts = results => {
|
|
|
3701
3578
|
};
|
|
3702
3579
|
};
|
|
3703
3580
|
|
|
3704
|
-
const
|
|
3705
|
-
|
|
3706
|
-
Object.assign(providers, providerMap);
|
|
3707
|
-
};
|
|
3708
|
-
const get = protocol => {
|
|
3709
|
-
return providers[protocol] || providers['default'];
|
|
3710
|
-
};
|
|
3711
|
-
|
|
3712
|
-
const getTextSearchProvider = scheme => {
|
|
3713
|
-
return get(scheme);
|
|
3714
|
-
};
|
|
3715
|
-
|
|
3716
|
-
const textSearch$6 = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
3717
|
-
string(root);
|
|
3718
|
-
string(query);
|
|
3719
|
-
const scheme = getProtocol(root);
|
|
3720
|
-
const provider = getTextSearchProvider(scheme);
|
|
3721
|
-
const results = await provider(scheme, root, query, options, assetDir, platform, searchId, uid);
|
|
3722
|
-
return results;
|
|
3581
|
+
const textSearch = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
3582
|
+
return search$1(root, query, options, assetDir, platform, searchId, uid);
|
|
3723
3583
|
};
|
|
3724
3584
|
|
|
3725
3585
|
const handleUpdateFull = async (state, update) => {
|
|
@@ -3755,7 +3615,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3755
3615
|
const {
|
|
3756
3616
|
limitHit,
|
|
3757
3617
|
results
|
|
3758
|
-
} = await textSearch
|
|
3618
|
+
} = await textSearch(root, value, {
|
|
3759
3619
|
assetDir,
|
|
3760
3620
|
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3761
3621
|
exclude: excludeValue,
|
|
@@ -3820,44 +3680,6 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3820
3680
|
};
|
|
3821
3681
|
};
|
|
3822
3682
|
|
|
3823
|
-
const getRipGrepArgs = ({
|
|
3824
|
-
defaultExcludes,
|
|
3825
|
-
exclude,
|
|
3826
|
-
isCaseSensitive,
|
|
3827
|
-
searchString,
|
|
3828
|
-
threads,
|
|
3829
|
-
useRegularExpression
|
|
3830
|
-
}) => {
|
|
3831
|
-
const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json', '--threads', `${threads}`];
|
|
3832
|
-
const excludePatternsFromValue = exclude ? exclude.split(',').map(part => part.trim()).filter(Boolean) : [];
|
|
3833
|
-
const excludePatternsFromDefaults = defaultExcludes?.filter(Boolean) || [];
|
|
3834
|
-
const uniqueExcludePatterns = [...new Set([...excludePatternsFromDefaults, ...excludePatternsFromValue])];
|
|
3835
|
-
for (const excludePattern of uniqueExcludePatterns) {
|
|
3836
|
-
if (excludePattern.includes('*')) {
|
|
3837
|
-
ripGrepArgs.push('--glob', `!${excludePattern}`);
|
|
3838
|
-
if (!excludePattern.endsWith('/**')) {
|
|
3839
|
-
ripGrepArgs.push('--glob', `!${excludePattern}/**`);
|
|
3840
|
-
}
|
|
3841
|
-
} else {
|
|
3842
|
-
ripGrepArgs.push('--glob', `!**/${excludePattern}/**`);
|
|
3843
|
-
}
|
|
3844
|
-
}
|
|
3845
|
-
if (isCaseSensitive) {
|
|
3846
|
-
ripGrepArgs.push('--case-sensitive');
|
|
3847
|
-
} else {
|
|
3848
|
-
ripGrepArgs.push('--ignore-case');
|
|
3849
|
-
}
|
|
3850
|
-
if (useRegularExpression) {
|
|
3851
|
-
ripGrepArgs.push('--regexp', searchString);
|
|
3852
|
-
} else {
|
|
3853
|
-
ripGrepArgs.push('--fixed-strings');
|
|
3854
|
-
ripGrepArgs.push('--');
|
|
3855
|
-
ripGrepArgs.push(searchString);
|
|
3856
|
-
}
|
|
3857
|
-
ripGrepArgs.push('.');
|
|
3858
|
-
return ripGrepArgs;
|
|
3859
|
-
};
|
|
3860
|
-
|
|
3861
3683
|
const waitForNextFrame = async () => {
|
|
3862
3684
|
const {
|
|
3863
3685
|
promise,
|
|
@@ -3868,20 +3690,9 @@ const waitForNextFrame = async () => {
|
|
|
3868
3690
|
};
|
|
3869
3691
|
|
|
3870
3692
|
const textSearchIncremental = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
3871
|
-
|
|
3872
|
-
string(query);
|
|
3873
|
-
const ripGrepArgs = getRipGrepArgs({
|
|
3874
|
-
...options,
|
|
3875
|
-
searchString: query
|
|
3876
|
-
});
|
|
3877
|
-
const actualOptions = {
|
|
3878
|
-
id: searchId,
|
|
3879
|
-
ripGrepArgs,
|
|
3880
|
-
searchDir: root
|
|
3881
|
-
};
|
|
3882
|
-
const resultPromise = invoke('TextSearch.searchIncremental', actualOptions);
|
|
3693
|
+
const resultPromise = searchIncremental(root, query, options, assetDir, platform, searchId, uid);
|
|
3883
3694
|
for (let i = 0; i < 100; i++) {
|
|
3884
|
-
const latest = get
|
|
3695
|
+
const latest = get(uid);
|
|
3885
3696
|
const {
|
|
3886
3697
|
newState
|
|
3887
3698
|
} = latest;
|
|
@@ -3893,8 +3704,8 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
|
|
|
3893
3704
|
} = newState;
|
|
3894
3705
|
const listHeight = height - headerHeight;
|
|
3895
3706
|
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
3896
|
-
const visible = await
|
|
3897
|
-
const latest2 = get
|
|
3707
|
+
const visible = await getIncrementalResults(searchId, minLineY, minLineY + numberOfVisible);
|
|
3708
|
+
const latest2 = get(uid);
|
|
3898
3709
|
if (!latest2 || latest2.newState.searchId !== searchId) {
|
|
3899
3710
|
return;
|
|
3900
3711
|
}
|
|
@@ -3936,7 +3747,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3936
3747
|
const root = workspacePath;
|
|
3937
3748
|
const scheme = getProtocol(root);
|
|
3938
3749
|
const searchId = crypto.randomUUID(); // TODO try to avoid side effect
|
|
3939
|
-
const latest1 = get
|
|
3750
|
+
const latest1 = get(uid);
|
|
3940
3751
|
const updatedState1 = {
|
|
3941
3752
|
...latest1.newState,
|
|
3942
3753
|
...partialNewState,
|
|
@@ -4002,7 +3813,7 @@ const handleUpdatePullBased = async (state, update) => {
|
|
|
4002
3813
|
const shouldUsePullBasedSearch = usePullBasedSearch && isFileSearch;
|
|
4003
3814
|
const {
|
|
4004
3815
|
limitHit
|
|
4005
|
-
} = await textSearch
|
|
3816
|
+
} = await textSearch(root, value, {
|
|
4006
3817
|
assetDir,
|
|
4007
3818
|
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
4008
3819
|
exclude: excludeValue,
|
|
@@ -4018,7 +3829,7 @@ const handleUpdatePullBased = async (state, update) => {
|
|
|
4018
3829
|
usePullBasedSearch: shouldUsePullBasedSearch,
|
|
4019
3830
|
useRegularExpression: Boolean(flags & UseRegularExpression$2)
|
|
4020
3831
|
}, assetDir, platform, searchId, uid);
|
|
4021
|
-
const latest = get
|
|
3832
|
+
const latest = get(uid);
|
|
4022
3833
|
if (!latest) {
|
|
4023
3834
|
return state;
|
|
4024
3835
|
}
|
|
@@ -4818,7 +4629,7 @@ const handleListFocus = async state => {
|
|
|
4818
4629
|
};
|
|
4819
4630
|
};
|
|
4820
4631
|
|
|
4821
|
-
const handlePullResultsFound = async (state, resultSearchId) => {
|
|
4632
|
+
const handlePullResultsFound = async (state, resultSearchId, newResults) => {
|
|
4822
4633
|
const {
|
|
4823
4634
|
fileIconCache,
|
|
4824
4635
|
headerHeight,
|
|
@@ -4826,15 +4637,12 @@ const handlePullResultsFound = async (state, resultSearchId) => {
|
|
|
4826
4637
|
itemHeight,
|
|
4827
4638
|
listItems,
|
|
4828
4639
|
minimumSliderSize,
|
|
4829
|
-
platform,
|
|
4830
4640
|
searchId,
|
|
4831
4641
|
uid
|
|
4832
4642
|
} = state;
|
|
4833
4643
|
if (searchId !== resultSearchId) {
|
|
4834
4644
|
return state;
|
|
4835
4645
|
}
|
|
4836
|
-
const result = platform === Remote || platform === Electron ? await invoke('TextSearch.getPullResults', searchId) : await invoke$1('SearchProcess.invoke', 'TextSearch.getPullResults', searchId);
|
|
4837
|
-
const newResults = result;
|
|
4838
4646
|
const allResults = [...listItems, ...newResults];
|
|
4839
4647
|
const {
|
|
4840
4648
|
fileCount,
|
|
@@ -4853,7 +4661,7 @@ const handlePullResultsFound = async (state, resultSearchId) => {
|
|
|
4853
4661
|
icons,
|
|
4854
4662
|
newFileIconCache
|
|
4855
4663
|
} = await getFileIcons(visible, fileIconCache);
|
|
4856
|
-
const latest = get
|
|
4664
|
+
const latest = get(uid);
|
|
4857
4665
|
const updatedState = {
|
|
4858
4666
|
...latest.newState,
|
|
4859
4667
|
fileCount,
|
|
@@ -4940,14 +4748,14 @@ const handleWorkspaceChange = state => {
|
|
|
4940
4748
|
};
|
|
4941
4749
|
};
|
|
4942
4750
|
|
|
4943
|
-
const send = async port => {
|
|
4751
|
+
const send$1 = async port => {
|
|
4944
4752
|
await sendMessagePortToIconThemeWorker(port, 0);
|
|
4945
4753
|
};
|
|
4946
4754
|
const launchIconThemeWorker = async () => {
|
|
4947
4755
|
// TODO connect to icon theme worker
|
|
4948
|
-
const rpc = await create$
|
|
4756
|
+
const rpc = await create$5({
|
|
4949
4757
|
commandMap: {},
|
|
4950
|
-
send
|
|
4758
|
+
send: send$1
|
|
4951
4759
|
});
|
|
4952
4760
|
return rpc;
|
|
4953
4761
|
};
|
|
@@ -4957,35 +4765,27 @@ const initializeIconThemeWorker = async () => {
|
|
|
4957
4765
|
set$3(rpc);
|
|
4958
4766
|
};
|
|
4959
4767
|
|
|
4960
|
-
const
|
|
4961
|
-
|
|
4962
|
-
commandMap: {},
|
|
4963
|
-
send: sendMessagePortToSearchProcess
|
|
4964
|
-
});
|
|
4965
|
-
return rpc;
|
|
4768
|
+
const commandMap$1 = {
|
|
4769
|
+
'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound)
|
|
4966
4770
|
};
|
|
4967
4771
|
|
|
4968
|
-
const
|
|
4969
|
-
|
|
4970
|
-
|
|
4971
|
-
|
|
4972
|
-
|
|
4772
|
+
const send = async port => {
|
|
4773
|
+
await sendMessagePortToTextSearchWorker(port, 0);
|
|
4774
|
+
};
|
|
4775
|
+
const launchTextSearchWorker = async () => {
|
|
4776
|
+
return create$5({
|
|
4777
|
+
commandMap: commandMap$1,
|
|
4778
|
+
send
|
|
4973
4779
|
});
|
|
4974
|
-
return rpc;
|
|
4975
4780
|
};
|
|
4976
4781
|
|
|
4977
|
-
const
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
set$1(rpc);
|
|
4981
|
-
} else if (platform === Remote) {
|
|
4982
|
-
const rpc = await launchSearchProcessNode();
|
|
4983
|
-
set$1(rpc);
|
|
4984
|
-
}
|
|
4782
|
+
const initializeTextSearchWorker = async () => {
|
|
4783
|
+
const rpc = await launchTextSearchWorker();
|
|
4784
|
+
set$1(rpc);
|
|
4985
4785
|
};
|
|
4986
4786
|
|
|
4987
|
-
const initialize = async
|
|
4988
|
-
await Promise.all([
|
|
4787
|
+
const initialize = async () => {
|
|
4788
|
+
await Promise.all([initializeTextSearchWorker(), initializeIconThemeWorker()]);
|
|
4989
4789
|
};
|
|
4990
4790
|
|
|
4991
4791
|
// TODO optimize this function to return the minimum number
|
|
@@ -6597,7 +6397,7 @@ const render2 = (uid, diffResult) => {
|
|
|
6597
6397
|
const {
|
|
6598
6398
|
newState,
|
|
6599
6399
|
oldState
|
|
6600
|
-
} = get
|
|
6400
|
+
} = get(uid);
|
|
6601
6401
|
set(uid, newState, newState);
|
|
6602
6402
|
const commands = applyRender(oldState, newState, diffResult);
|
|
6603
6403
|
return commands;
|
|
@@ -6981,7 +6781,7 @@ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
|
|
|
6981
6781
|
const {
|
|
6982
6782
|
newState,
|
|
6983
6783
|
oldState
|
|
6984
|
-
} = get
|
|
6784
|
+
} = get(uid);
|
|
6985
6785
|
set(uid, oldState, {
|
|
6986
6786
|
...newState,
|
|
6987
6787
|
focusedIndex: index,
|
|
@@ -7108,7 +6908,7 @@ const commandMap = {
|
|
|
7108
6908
|
'TextSearch.setLimit': wrapCommand(setLimit),
|
|
7109
6909
|
'TextSearch.submit': wrapCommand(submit),
|
|
7110
6910
|
'TextSearch.terminate': terminate,
|
|
7111
|
-
'TextSearch.textSearch': textSearch
|
|
6911
|
+
'TextSearch.textSearch': textSearch,
|
|
7112
6912
|
'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
|
|
7113
6913
|
'TextSearch.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord),
|
|
7114
6914
|
'TextSearch.toggleOpenEditors': wrapCommand(toggleOpenEditors),
|
|
@@ -7120,124 +6920,8 @@ const commandMap = {
|
|
|
7120
6920
|
'TextSearch.viewAsTree': wrapCommand(viewAsTree)
|
|
7121
6921
|
};
|
|
7122
6922
|
|
|
7123
|
-
const textSearch$5 = async (scheme, root, query) => {
|
|
7124
|
-
string(scheme);
|
|
7125
|
-
string(query);
|
|
7126
|
-
const results = await invoke$1('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
|
|
7127
|
-
return {
|
|
7128
|
-
limitHit: false,
|
|
7129
|
-
results
|
|
7130
|
-
};
|
|
7131
|
-
};
|
|
7132
|
-
|
|
7133
|
-
const textSearch$4 = async (scheme, root, query, options, assetDir) => {
|
|
7134
|
-
const results = await invoke$1('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
|
|
7135
|
-
return {
|
|
7136
|
-
limitHit: false,
|
|
7137
|
-
results
|
|
7138
|
-
};
|
|
7139
|
-
};
|
|
7140
|
-
|
|
7141
|
-
const textSearch$3 = async (scheme, root, query) => {
|
|
7142
|
-
const results = await invoke$1('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
|
|
7143
|
-
return {
|
|
7144
|
-
limitHit: false,
|
|
7145
|
-
results
|
|
7146
|
-
};
|
|
7147
|
-
};
|
|
7148
|
-
|
|
7149
|
-
const textSearch$2 = async (scheme, root, query, options, assetDir) => {
|
|
7150
|
-
try {
|
|
7151
|
-
// @ts-ignore
|
|
7152
|
-
const result = await invoke$1('ExtensionHostTextSearch.textSearchMemory2', scheme, root, query, options, assetDir);
|
|
7153
|
-
if (!result || !result.results) {
|
|
7154
|
-
throw new Error(`new api not supported`);
|
|
7155
|
-
}
|
|
7156
|
-
return result;
|
|
7157
|
-
} catch {
|
|
7158
|
-
const results = await invoke$1('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
|
|
7159
|
-
return {
|
|
7160
|
-
limitHit: false,
|
|
7161
|
-
results
|
|
7162
|
-
};
|
|
7163
|
-
}
|
|
7164
|
-
};
|
|
7165
|
-
|
|
7166
|
-
const textSearch$1 = async (scheme, root, query, options, assetDir, platform, searchId, uid) => {
|
|
7167
|
-
const ripGrepArgs = getRipGrepArgs({
|
|
7168
|
-
...options,
|
|
7169
|
-
searchString: query
|
|
7170
|
-
});
|
|
7171
|
-
if (options.usePullBasedSearch && searchId && (scheme === '' || scheme === 'file')) {
|
|
7172
|
-
const pullSearchOptions = {
|
|
7173
|
-
ripGrepArgs,
|
|
7174
|
-
searchDir: root,
|
|
7175
|
-
searchId,
|
|
7176
|
-
uid
|
|
7177
|
-
};
|
|
7178
|
-
if (platform === Remote || platform === Electron) {
|
|
7179
|
-
await invoke('TextSearch.searchPull', pullSearchOptions);
|
|
7180
|
-
} else {
|
|
7181
|
-
await invoke$1('SearchProcess.invoke', 'TextSearch.searchPull', pullSearchOptions);
|
|
7182
|
-
}
|
|
7183
|
-
return {
|
|
7184
|
-
limitHit: false,
|
|
7185
|
-
results: []
|
|
7186
|
-
};
|
|
7187
|
-
}
|
|
7188
|
-
const actualOptions = {
|
|
7189
|
-
ripGrepArgs,
|
|
7190
|
-
searchDir: root
|
|
7191
|
-
};
|
|
7192
|
-
if (platform === Remote || platform === Electron) {
|
|
7193
|
-
const result = await invoke('TextSearch.search', actualOptions);
|
|
7194
|
-
return {
|
|
7195
|
-
limitHit: result.limitHit,
|
|
7196
|
-
results: result.results
|
|
7197
|
-
};
|
|
7198
|
-
}
|
|
7199
|
-
// TODO always create search process messageport rpc to have one api, in web can send the messageport to renderer worker
|
|
7200
|
-
const result = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
|
|
7201
|
-
// TODO api is weird
|
|
7202
|
-
return {
|
|
7203
|
-
limitHit: result.limitHit,
|
|
7204
|
-
results: result.results
|
|
7205
|
-
};
|
|
7206
|
-
};
|
|
7207
|
-
|
|
7208
|
-
const textSearch = async (scheme, root, query) => {
|
|
7209
|
-
// TODO ask renderer worker for files
|
|
7210
|
-
const entries = Object.entries({});
|
|
7211
|
-
const results = [];
|
|
7212
|
-
for (const [key, value] of entries) {
|
|
7213
|
-
// @ts-ignore
|
|
7214
|
-
if (value.includes(query)) {
|
|
7215
|
-
results.push([key, [{
|
|
7216
|
-
absoluteOffset: 0,
|
|
7217
|
-
preview: value
|
|
7218
|
-
}]]);
|
|
7219
|
-
}
|
|
7220
|
-
}
|
|
7221
|
-
return {
|
|
7222
|
-
limitHit: false,
|
|
7223
|
-
results
|
|
7224
|
-
};
|
|
7225
|
-
};
|
|
7226
|
-
|
|
7227
|
-
const textSearchProviderMap = {
|
|
7228
|
-
'': textSearch$1,
|
|
7229
|
-
// TODO deprecate/remove workspaces without scheme
|
|
7230
|
-
default: textSearch$5,
|
|
7231
|
-
fetch: textSearch$4,
|
|
7232
|
-
file: textSearch$1,
|
|
7233
|
-
html: textSearch$3,
|
|
7234
|
-
memfs: textSearch$2,
|
|
7235
|
-
web: textSearch
|
|
7236
|
-
};
|
|
7237
|
-
|
|
7238
6923
|
const listen = async () => {
|
|
7239
6924
|
registerCommands(commandMap);
|
|
7240
|
-
add(textSearchProviderMap);
|
|
7241
6925
|
const rpc = await create$4({
|
|
7242
6926
|
commandMap: commandMap
|
|
7243
6927
|
});
|