@lvce-editor/text-search-worker 6.0.0 → 6.2.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 +357 -146
- package/package.json +1 -1
|
@@ -546,7 +546,7 @@ const waitForWebSocketToBeOpen = webSocket => {
|
|
|
546
546
|
open: Open
|
|
547
547
|
});
|
|
548
548
|
};
|
|
549
|
-
const create$
|
|
549
|
+
const create$f = async ({
|
|
550
550
|
webSocket
|
|
551
551
|
}) => {
|
|
552
552
|
const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
|
|
@@ -583,10 +583,31 @@ const wrap = webSocket => {
|
|
|
583
583
|
};
|
|
584
584
|
const IpcParentWithWebSocket$1 = {
|
|
585
585
|
__proto__: null,
|
|
586
|
-
create: create$
|
|
586
|
+
create: create$f,
|
|
587
587
|
wrap
|
|
588
588
|
};
|
|
589
589
|
|
|
590
|
+
class CommandNotFoundError extends Error {
|
|
591
|
+
constructor(command) {
|
|
592
|
+
super(`Command not found ${command}`);
|
|
593
|
+
this.name = 'CommandNotFoundError';
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
const commands = Object.create(null);
|
|
597
|
+
const register = commandMap => {
|
|
598
|
+
Object.assign(commands, commandMap);
|
|
599
|
+
};
|
|
600
|
+
const getCommand = key => {
|
|
601
|
+
return commands[key];
|
|
602
|
+
};
|
|
603
|
+
const execute = (command, ...args) => {
|
|
604
|
+
const fn = getCommand(command);
|
|
605
|
+
if (!fn) {
|
|
606
|
+
throw new CommandNotFoundError(command);
|
|
607
|
+
}
|
|
608
|
+
return fn(...args);
|
|
609
|
+
};
|
|
610
|
+
|
|
590
611
|
const Two$1 = '2.0';
|
|
591
612
|
const callbacks = Object.create(null);
|
|
592
613
|
const get$3 = id => {
|
|
@@ -788,7 +809,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
788
809
|
}
|
|
789
810
|
};
|
|
790
811
|
};
|
|
791
|
-
const create$1$
|
|
812
|
+
const create$1$1 = (id, error) => {
|
|
792
813
|
return {
|
|
793
814
|
jsonrpc: Two$1,
|
|
794
815
|
id,
|
|
@@ -799,9 +820,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
799
820
|
const prettyError = preparePrettyError(error);
|
|
800
821
|
logError(error, prettyError);
|
|
801
822
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
802
|
-
return create$1$
|
|
823
|
+
return create$1$1(id, errorProperty);
|
|
803
824
|
};
|
|
804
|
-
const create$
|
|
825
|
+
const create$e = (message, result) => {
|
|
805
826
|
return {
|
|
806
827
|
jsonrpc: Two$1,
|
|
807
828
|
id: message.id,
|
|
@@ -810,7 +831,7 @@ const create$5 = (message, result) => {
|
|
|
810
831
|
};
|
|
811
832
|
const getSuccessResponse = (message, result) => {
|
|
812
833
|
const resultProperty = result ?? null;
|
|
813
|
-
return create$
|
|
834
|
+
return create$e(message, resultProperty);
|
|
814
835
|
};
|
|
815
836
|
const getErrorResponseSimple = (id, error) => {
|
|
816
837
|
return {
|
|
@@ -902,36 +923,17 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
902
923
|
throw new JsonRpcError('unexpected message');
|
|
903
924
|
};
|
|
904
925
|
|
|
905
|
-
class CommandNotFoundError extends Error {
|
|
906
|
-
constructor(command) {
|
|
907
|
-
super(`Command not found ${command}`);
|
|
908
|
-
this.name = 'CommandNotFoundError';
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
const commands = Object.create(null);
|
|
912
|
-
const register = commandMap => {
|
|
913
|
-
Object.assign(commands, commandMap);
|
|
914
|
-
};
|
|
915
|
-
const getCommand = key => {
|
|
916
|
-
return commands[key];
|
|
917
|
-
};
|
|
918
|
-
const execute = (command, ...args) => {
|
|
919
|
-
const fn = getCommand(command);
|
|
920
|
-
if (!fn) {
|
|
921
|
-
throw new CommandNotFoundError(command);
|
|
922
|
-
}
|
|
923
|
-
return fn(...args);
|
|
924
|
-
};
|
|
925
|
-
|
|
926
926
|
const Two = '2.0';
|
|
927
|
-
|
|
927
|
+
|
|
928
|
+
const create$d = (method, params) => {
|
|
928
929
|
return {
|
|
929
930
|
jsonrpc: Two,
|
|
930
931
|
method,
|
|
931
932
|
params
|
|
932
933
|
};
|
|
933
934
|
};
|
|
934
|
-
|
|
935
|
+
|
|
936
|
+
const create$c = (id, method, params) => {
|
|
935
937
|
const message = {
|
|
936
938
|
id,
|
|
937
939
|
jsonrpc: Two,
|
|
@@ -940,15 +942,14 @@ const create$r = (id, method, params) => {
|
|
|
940
942
|
};
|
|
941
943
|
return message;
|
|
942
944
|
};
|
|
945
|
+
|
|
943
946
|
let id = 0;
|
|
944
|
-
const create$
|
|
947
|
+
const create$b = () => {
|
|
945
948
|
return ++id;
|
|
946
949
|
};
|
|
947
950
|
|
|
948
|
-
/* eslint-disable n/no-unsupported-features/es-syntax */
|
|
949
|
-
|
|
950
951
|
const registerPromise = map => {
|
|
951
|
-
const id = create$
|
|
952
|
+
const id = create$b();
|
|
952
953
|
const {
|
|
953
954
|
promise,
|
|
954
955
|
resolve
|
|
@@ -966,7 +967,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
|
|
|
966
967
|
id,
|
|
967
968
|
promise
|
|
968
969
|
} = registerPromise(callbacks);
|
|
969
|
-
const message = create$
|
|
970
|
+
const message = create$c(id, method, params);
|
|
970
971
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
971
972
|
ipc.sendAndTransfer(message);
|
|
972
973
|
} else {
|
|
@@ -1002,12 +1003,13 @@ const createRpc = ipc => {
|
|
|
1002
1003
|
* @deprecated
|
|
1003
1004
|
*/
|
|
1004
1005
|
send(method, ...params) {
|
|
1005
|
-
const message = create$
|
|
1006
|
+
const message = create$d(method, params);
|
|
1006
1007
|
ipc.send(message);
|
|
1007
1008
|
}
|
|
1008
1009
|
};
|
|
1009
1010
|
return rpc;
|
|
1010
1011
|
};
|
|
1012
|
+
|
|
1011
1013
|
const requiresSocket = () => {
|
|
1012
1014
|
return false;
|
|
1013
1015
|
};
|
|
@@ -1022,6 +1024,7 @@ const handleMessage = event => {
|
|
|
1022
1024
|
const actualExecute = event?.target?.execute || execute;
|
|
1023
1025
|
return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
|
|
1024
1026
|
};
|
|
1027
|
+
|
|
1025
1028
|
const handleIpc = ipc => {
|
|
1026
1029
|
if ('addEventListener' in ipc) {
|
|
1027
1030
|
ipc.addEventListener('message', handleMessage);
|
|
@@ -1030,6 +1033,7 @@ const handleIpc = ipc => {
|
|
|
1030
1033
|
ipc.on('message', handleMessage);
|
|
1031
1034
|
}
|
|
1032
1035
|
};
|
|
1036
|
+
|
|
1033
1037
|
const listen$1 = async (module, options) => {
|
|
1034
1038
|
const rawIpc = await module.listen(options);
|
|
1035
1039
|
if (module.signal) {
|
|
@@ -1039,8 +1043,6 @@ const listen$1 = async (module, options) => {
|
|
|
1039
1043
|
return ipc;
|
|
1040
1044
|
};
|
|
1041
1045
|
|
|
1042
|
-
/* eslint-disable @typescript-eslint/no-misused-promises */
|
|
1043
|
-
|
|
1044
1046
|
const createSharedLazyRpc = factory => {
|
|
1045
1047
|
let rpcPromise;
|
|
1046
1048
|
const getOrCreate = () => {
|
|
@@ -1068,40 +1070,42 @@ const createSharedLazyRpc = factory => {
|
|
|
1068
1070
|
}
|
|
1069
1071
|
};
|
|
1070
1072
|
};
|
|
1071
|
-
|
|
1073
|
+
|
|
1074
|
+
const create$a = async ({
|
|
1072
1075
|
commandMap,
|
|
1073
1076
|
isMessagePortOpen,
|
|
1074
1077
|
send
|
|
1075
1078
|
}) => {
|
|
1076
1079
|
return createSharedLazyRpc(() => {
|
|
1077
|
-
return create$
|
|
1080
|
+
return create$5({
|
|
1078
1081
|
commandMap,
|
|
1079
1082
|
isMessagePortOpen,
|
|
1080
1083
|
send
|
|
1081
1084
|
});
|
|
1082
1085
|
});
|
|
1083
1086
|
};
|
|
1084
|
-
|
|
1085
|
-
__proto__: null,
|
|
1086
|
-
create: create$i
|
|
1087
|
-
};
|
|
1087
|
+
|
|
1088
1088
|
const Https = 'https:';
|
|
1089
1089
|
const Ws = 'ws:';
|
|
1090
1090
|
const Wss = 'wss:';
|
|
1091
|
+
|
|
1091
1092
|
const getWebSocketProtocol = locationProtocol => {
|
|
1092
1093
|
return locationProtocol === Https ? Wss : Ws;
|
|
1093
1094
|
};
|
|
1095
|
+
|
|
1094
1096
|
const getWebSocketUrl = (type, host, locationProtocol) => {
|
|
1095
1097
|
const wsProtocol = getWebSocketProtocol(locationProtocol);
|
|
1096
1098
|
return `${wsProtocol}//${host}/websocket/${type}`;
|
|
1097
1099
|
};
|
|
1100
|
+
|
|
1098
1101
|
const getHost = () => {
|
|
1099
1102
|
return location.host;
|
|
1100
1103
|
};
|
|
1101
1104
|
const getProtocol$1 = () => {
|
|
1102
1105
|
return location.protocol;
|
|
1103
1106
|
};
|
|
1104
|
-
|
|
1107
|
+
|
|
1108
|
+
const create$9 = async ({
|
|
1105
1109
|
commandMap,
|
|
1106
1110
|
webSocket
|
|
1107
1111
|
}) => {
|
|
@@ -1115,7 +1119,8 @@ const create$h = async ({
|
|
|
1115
1119
|
const rpc = createRpc(ipc);
|
|
1116
1120
|
return rpc;
|
|
1117
1121
|
};
|
|
1118
|
-
|
|
1122
|
+
|
|
1123
|
+
const create$8 = async ({
|
|
1119
1124
|
commandMap,
|
|
1120
1125
|
type
|
|
1121
1126
|
}) => {
|
|
@@ -1123,28 +1128,26 @@ const create$g = async ({
|
|
|
1123
1128
|
const protocol = getProtocol$1();
|
|
1124
1129
|
const wsUrl = getWebSocketUrl(type, host, protocol);
|
|
1125
1130
|
const webSocket = new WebSocket(wsUrl);
|
|
1126
|
-
const rpc = await create$
|
|
1131
|
+
const rpc = await create$9({
|
|
1127
1132
|
commandMap,
|
|
1128
1133
|
webSocket
|
|
1129
1134
|
});
|
|
1130
1135
|
return rpc;
|
|
1131
1136
|
};
|
|
1132
|
-
|
|
1137
|
+
|
|
1138
|
+
const create$7 = async ({
|
|
1133
1139
|
commandMap,
|
|
1134
1140
|
type
|
|
1135
1141
|
}) => {
|
|
1136
1142
|
return createSharedLazyRpc(() => {
|
|
1137
|
-
return create$
|
|
1143
|
+
return create$8({
|
|
1138
1144
|
commandMap,
|
|
1139
1145
|
type
|
|
1140
1146
|
});
|
|
1141
1147
|
});
|
|
1142
1148
|
};
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
create: create$f
|
|
1146
|
-
};
|
|
1147
|
-
const create$4 = async ({
|
|
1149
|
+
|
|
1150
|
+
const create$6 = async ({
|
|
1148
1151
|
commandMap,
|
|
1149
1152
|
isMessagePortOpen = true,
|
|
1150
1153
|
messagePort
|
|
@@ -1161,7 +1164,8 @@ const create$4 = async ({
|
|
|
1161
1164
|
messagePort.start();
|
|
1162
1165
|
return rpc;
|
|
1163
1166
|
};
|
|
1164
|
-
|
|
1167
|
+
|
|
1168
|
+
const create$5 = async ({
|
|
1165
1169
|
commandMap,
|
|
1166
1170
|
isMessagePortOpen,
|
|
1167
1171
|
send
|
|
@@ -1171,17 +1175,14 @@ const create$2$1 = async ({
|
|
|
1171
1175
|
port2
|
|
1172
1176
|
} = new MessageChannel();
|
|
1173
1177
|
await send(port1);
|
|
1174
|
-
return create$
|
|
1178
|
+
return create$6({
|
|
1175
1179
|
commandMap,
|
|
1176
1180
|
isMessagePortOpen,
|
|
1177
1181
|
messagePort: port2
|
|
1178
1182
|
});
|
|
1179
1183
|
};
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
create: create$2$1
|
|
1183
|
-
};
|
|
1184
|
-
const create$1$1 = async ({
|
|
1184
|
+
|
|
1185
|
+
const create$4 = async ({
|
|
1185
1186
|
commandMap
|
|
1186
1187
|
}) => {
|
|
1187
1188
|
// TODO create a commandMap per rpc instance
|
|
@@ -1191,29 +1192,6 @@ const create$1$1 = async ({
|
|
|
1191
1192
|
const rpc = createRpc(ipc);
|
|
1192
1193
|
return rpc;
|
|
1193
1194
|
};
|
|
1194
|
-
const WebWorkerRpcClient = {
|
|
1195
|
-
__proto__: null,
|
|
1196
|
-
create: create$1$1
|
|
1197
|
-
};
|
|
1198
|
-
const createMockRpc = ({
|
|
1199
|
-
commandMap
|
|
1200
|
-
}) => {
|
|
1201
|
-
const invocations = [];
|
|
1202
|
-
const invoke = (method, ...params) => {
|
|
1203
|
-
invocations.push([method, ...params]);
|
|
1204
|
-
const command = commandMap[method];
|
|
1205
|
-
if (!command) {
|
|
1206
|
-
throw new Error(`command ${method} not found`);
|
|
1207
|
-
}
|
|
1208
|
-
return command(...params);
|
|
1209
|
-
};
|
|
1210
|
-
const mockRpc = {
|
|
1211
|
-
invocations,
|
|
1212
|
-
invoke,
|
|
1213
|
-
invokeAndTransfer: invoke
|
|
1214
|
-
};
|
|
1215
|
-
return mockRpc;
|
|
1216
|
-
};
|
|
1217
1195
|
|
|
1218
1196
|
const Alert = 'alert';
|
|
1219
1197
|
const Button$3 = 'button';
|
|
@@ -1295,6 +1273,7 @@ const Ins = 20;
|
|
|
1295
1273
|
const Del = 21;
|
|
1296
1274
|
const H4 = 24;
|
|
1297
1275
|
const TextArea = 62;
|
|
1276
|
+
const Reference = 100;
|
|
1298
1277
|
|
|
1299
1278
|
const Button$1 = 'event.button';
|
|
1300
1279
|
const ClientX = 'event.clientX';
|
|
@@ -1348,6 +1327,26 @@ const FocusSearchWholeWord = 34;
|
|
|
1348
1327
|
const FocusToggleDetails = 1010;
|
|
1349
1328
|
const FocusToggleReplace = 1020;
|
|
1350
1329
|
|
|
1330
|
+
const createMockRpc = ({
|
|
1331
|
+
commandMap
|
|
1332
|
+
}) => {
|
|
1333
|
+
const invocations = [];
|
|
1334
|
+
const invoke = (method, ...params) => {
|
|
1335
|
+
invocations.push([method, ...params]);
|
|
1336
|
+
const command = commandMap[method];
|
|
1337
|
+
if (!command) {
|
|
1338
|
+
throw new Error(`command ${method} not found`);
|
|
1339
|
+
}
|
|
1340
|
+
return command(...params);
|
|
1341
|
+
};
|
|
1342
|
+
const mockRpc = {
|
|
1343
|
+
invocations,
|
|
1344
|
+
invoke,
|
|
1345
|
+
invokeAndTransfer: invoke
|
|
1346
|
+
};
|
|
1347
|
+
return mockRpc;
|
|
1348
|
+
};
|
|
1349
|
+
|
|
1351
1350
|
const rpcs = Object.create(null);
|
|
1352
1351
|
const set$4 = (id, rpc) => {
|
|
1353
1352
|
rpcs[id] = rpc;
|
|
@@ -1415,12 +1414,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1415
1414
|
number(menuId);
|
|
1416
1415
|
number(x);
|
|
1417
1416
|
number(y);
|
|
1418
|
-
// @ts-ignore
|
|
1419
1417
|
await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
|
|
1420
1418
|
};
|
|
1421
1419
|
const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
1422
1420
|
const command = 'IconTheme.handleMessagePort';
|
|
1423
|
-
// @ts-ignore
|
|
1424
1421
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
|
|
1425
1422
|
};
|
|
1426
1423
|
const handleWorkspaceRefresh = async () => {
|
|
@@ -1432,6 +1429,9 @@ const sendMessagePortToSearchProcess = async port => {
|
|
|
1432
1429
|
const writeClipBoardText = async text => {
|
|
1433
1430
|
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1434
1431
|
};
|
|
1432
|
+
const getPreference = async key => {
|
|
1433
|
+
return await invoke$1('Preferences.get', key);
|
|
1434
|
+
};
|
|
1435
1435
|
const openUri$1 = async (uri, focus, options) => {
|
|
1436
1436
|
await invoke$1('Main.openUri', uri, focus, options);
|
|
1437
1437
|
};
|
|
@@ -1449,42 +1449,68 @@ const create$2 = () => {
|
|
|
1449
1449
|
const states = Object.create(null);
|
|
1450
1450
|
const commandMapRef = {};
|
|
1451
1451
|
return {
|
|
1452
|
-
|
|
1453
|
-
|
|
1452
|
+
clear() {
|
|
1453
|
+
for (const key of Object.keys(states)) {
|
|
1454
|
+
delete states[key];
|
|
1455
|
+
}
|
|
1454
1456
|
},
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
};
|
|
1457
|
+
diff(uid, modules, numbers) {
|
|
1458
|
+
const {
|
|
1459
|
+
newState,
|
|
1460
|
+
oldState
|
|
1461
|
+
} = states[uid];
|
|
1462
|
+
const diffResult = [];
|
|
1463
|
+
for (let i = 0; i < modules.length; i++) {
|
|
1464
|
+
const fn = modules[i];
|
|
1465
|
+
if (!fn(oldState, newState)) {
|
|
1466
|
+
diffResult.push(numbers[i]);
|
|
1467
|
+
}
|
|
1468
|
+
}
|
|
1469
|
+
return diffResult;
|
|
1460
1470
|
},
|
|
1461
1471
|
dispose(uid) {
|
|
1462
1472
|
delete states[uid];
|
|
1463
1473
|
},
|
|
1474
|
+
get(uid) {
|
|
1475
|
+
return states[uid];
|
|
1476
|
+
},
|
|
1477
|
+
getCommandIds() {
|
|
1478
|
+
const keys = Object.keys(commandMapRef);
|
|
1479
|
+
const ids = keys.map(toCommandId);
|
|
1480
|
+
return ids;
|
|
1481
|
+
},
|
|
1464
1482
|
getKeys() {
|
|
1465
1483
|
return Object.keys(states).map(key => {
|
|
1466
1484
|
return Number.parseInt(key);
|
|
1467
1485
|
});
|
|
1468
1486
|
},
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1487
|
+
registerCommands(commandMap) {
|
|
1488
|
+
Object.assign(commandMapRef, commandMap);
|
|
1489
|
+
},
|
|
1490
|
+
set(uid, oldState, newState) {
|
|
1491
|
+
states[uid] = {
|
|
1492
|
+
newState,
|
|
1493
|
+
oldState
|
|
1494
|
+
};
|
|
1473
1495
|
},
|
|
1474
1496
|
wrapCommand(fn) {
|
|
1475
1497
|
const wrapped = async (uid, ...args) => {
|
|
1476
1498
|
const {
|
|
1477
|
-
|
|
1478
|
-
|
|
1499
|
+
newState,
|
|
1500
|
+
oldState
|
|
1479
1501
|
} = states[uid];
|
|
1480
1502
|
const newerState = await fn(newState, ...args);
|
|
1481
1503
|
if (oldState === newerState || newState === newerState) {
|
|
1482
1504
|
return;
|
|
1483
1505
|
}
|
|
1484
|
-
const
|
|
1506
|
+
const latestOld = states[uid];
|
|
1507
|
+
const latestNew = {
|
|
1508
|
+
...latestOld.newState,
|
|
1509
|
+
...newerState
|
|
1510
|
+
};
|
|
1485
1511
|
states[uid] = {
|
|
1486
|
-
|
|
1487
|
-
|
|
1512
|
+
newState: latestNew,
|
|
1513
|
+
oldState: latestOld.oldState
|
|
1488
1514
|
};
|
|
1489
1515
|
};
|
|
1490
1516
|
return wrapped;
|
|
@@ -1497,28 +1523,6 @@ const create$2 = () => {
|
|
|
1497
1523
|
return fn(newState, ...args);
|
|
1498
1524
|
};
|
|
1499
1525
|
return wrapped;
|
|
1500
|
-
},
|
|
1501
|
-
diff(uid, modules, numbers) {
|
|
1502
|
-
const {
|
|
1503
|
-
oldState,
|
|
1504
|
-
newState
|
|
1505
|
-
} = states[uid];
|
|
1506
|
-
const diffResult = [];
|
|
1507
|
-
for (let i = 0; i < modules.length; i++) {
|
|
1508
|
-
const fn = modules[i];
|
|
1509
|
-
if (!fn(oldState, newState)) {
|
|
1510
|
-
diffResult.push(numbers[i]);
|
|
1511
|
-
}
|
|
1512
|
-
}
|
|
1513
|
-
return diffResult;
|
|
1514
|
-
},
|
|
1515
|
-
getCommandIds() {
|
|
1516
|
-
const keys = Object.keys(commandMapRef);
|
|
1517
|
-
const ids = keys.map(toCommandId);
|
|
1518
|
-
return ids;
|
|
1519
|
-
},
|
|
1520
|
-
registerCommands(commandMap) {
|
|
1521
|
-
Object.assign(commandMapRef, commandMap);
|
|
1522
1526
|
}
|
|
1523
1527
|
};
|
|
1524
1528
|
};
|
|
@@ -1547,6 +1551,7 @@ const NavigateChild = 7;
|
|
|
1547
1551
|
const NavigateParent = 8;
|
|
1548
1552
|
const RemoveChild = 9;
|
|
1549
1553
|
const NavigateSibling = 10;
|
|
1554
|
+
const SetReferenceNodeUid = 11;
|
|
1550
1555
|
|
|
1551
1556
|
const isKey = key => {
|
|
1552
1557
|
return key !== 'type' && key !== 'childCount';
|
|
@@ -1614,6 +1619,16 @@ const compareNodes = (oldNode, newNode) => {
|
|
|
1614
1619
|
if (oldNode.type !== newNode.type) {
|
|
1615
1620
|
return null;
|
|
1616
1621
|
}
|
|
1622
|
+
// Handle reference nodes - special handling for uid changes
|
|
1623
|
+
if (oldNode.type === Reference) {
|
|
1624
|
+
if (oldNode.uid !== newNode.uid) {
|
|
1625
|
+
patches.push({
|
|
1626
|
+
type: SetReferenceNodeUid,
|
|
1627
|
+
uid: newNode.uid
|
|
1628
|
+
});
|
|
1629
|
+
}
|
|
1630
|
+
return patches;
|
|
1631
|
+
}
|
|
1617
1632
|
// Handle text nodes
|
|
1618
1633
|
if (oldNode.type === Text && newNode.type === Text) {
|
|
1619
1634
|
if (oldNode.text !== newNode.text) {
|
|
@@ -2006,6 +2021,9 @@ const hasReplaceExpanded = flags => {
|
|
|
2006
2021
|
const hasDetailsExpanded = flags => {
|
|
2007
2022
|
return (flags & DetailsExpanded) === DetailsExpanded;
|
|
2008
2023
|
};
|
|
2024
|
+
const hasUseIgnoreFiles = flags => {
|
|
2025
|
+
return (flags & UseIgnoreFiles) === UseIgnoreFiles;
|
|
2026
|
+
};
|
|
2009
2027
|
|
|
2010
2028
|
const collapseDetails = state => {
|
|
2011
2029
|
const {
|
|
@@ -2047,6 +2065,9 @@ const copyPath$1 = async state => {
|
|
|
2047
2065
|
return state;
|
|
2048
2066
|
};
|
|
2049
2067
|
|
|
2068
|
+
const defaultExcludes = ['.git', 'node_modules'];
|
|
2069
|
+
defaultExcludes.join(',');
|
|
2070
|
+
|
|
2050
2071
|
const minimumSliderSize = 20;
|
|
2051
2072
|
|
|
2052
2073
|
const {
|
|
@@ -2105,11 +2126,12 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2105
2126
|
}),
|
|
2106
2127
|
assetDir,
|
|
2107
2128
|
collapsedPaths: [],
|
|
2129
|
+
defaultExcludes: defaultExcludes,
|
|
2108
2130
|
deltaY: 0,
|
|
2109
2131
|
excludeValue: '',
|
|
2110
2132
|
fileIconCache: {},
|
|
2111
2133
|
finalDeltaY: 0,
|
|
2112
|
-
flags:
|
|
2134
|
+
flags: UseIgnoreFiles,
|
|
2113
2135
|
focus: Empty,
|
|
2114
2136
|
focused: false,
|
|
2115
2137
|
focusedIndex: -1,
|
|
@@ -2156,6 +2178,8 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2156
2178
|
threads: 0,
|
|
2157
2179
|
useChevrons: true,
|
|
2158
2180
|
useFileIcons: true,
|
|
2181
|
+
usePullBasedSearch: false,
|
|
2182
|
+
// TODO enable
|
|
2159
2183
|
viewMode: List,
|
|
2160
2184
|
workspacePath: workspacePath
|
|
2161
2185
|
};
|
|
@@ -3083,12 +3107,12 @@ const getTextSearchProvider = scheme => {
|
|
|
3083
3107
|
return get(scheme);
|
|
3084
3108
|
};
|
|
3085
3109
|
|
|
3086
|
-
const textSearch$6 = async (root, query, options, assetDir, platform) => {
|
|
3110
|
+
const textSearch$6 = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
3087
3111
|
string(root);
|
|
3088
3112
|
string(query);
|
|
3089
3113
|
const scheme = getProtocol(root);
|
|
3090
3114
|
const provider = getTextSearchProvider(scheme);
|
|
3091
|
-
const results = await provider(scheme, root, query, options, assetDir, platform);
|
|
3115
|
+
const results = await provider(scheme, root, query, options, assetDir, platform, searchId, uid);
|
|
3092
3116
|
return results;
|
|
3093
3117
|
};
|
|
3094
3118
|
|
|
@@ -3110,15 +3134,21 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3110
3134
|
minimumSliderSize,
|
|
3111
3135
|
platform,
|
|
3112
3136
|
threads,
|
|
3137
|
+
uid,
|
|
3138
|
+
usePullBasedSearch,
|
|
3113
3139
|
value
|
|
3114
3140
|
} = partialNewState;
|
|
3115
3141
|
const root = state.workspacePath;
|
|
3116
3142
|
const scheme = getProtocol(root);
|
|
3143
|
+
const isFileSearch = scheme === '' || scheme === 'file';
|
|
3144
|
+
const shouldUsePullBasedSearch = Boolean(usePullBasedSearch) && isFileSearch;
|
|
3145
|
+
const searchId = shouldUsePullBasedSearch ? crypto.randomUUID() : '';
|
|
3117
3146
|
const {
|
|
3118
3147
|
limitHit,
|
|
3119
3148
|
results
|
|
3120
3149
|
} = await textSearch$6(root, value, {
|
|
3121
3150
|
assetDir,
|
|
3151
|
+
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3122
3152
|
exclude: excludeValue,
|
|
3123
3153
|
flags,
|
|
3124
3154
|
include: includeValue,
|
|
@@ -3129,8 +3159,9 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3129
3159
|
root,
|
|
3130
3160
|
scheme,
|
|
3131
3161
|
threads,
|
|
3162
|
+
usePullBasedSearch: shouldUsePullBasedSearch,
|
|
3132
3163
|
useRegularExpression: Boolean(flags & UseRegularExpression$2)
|
|
3133
|
-
}, assetDir, platform);
|
|
3164
|
+
}, assetDir, platform, searchId, uid);
|
|
3134
3165
|
if (!Array.isArray(results)) {
|
|
3135
3166
|
throw new TypeError('results must be of type array');
|
|
3136
3167
|
}
|
|
@@ -3170,6 +3201,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3170
3201
|
message,
|
|
3171
3202
|
minLineY: 0,
|
|
3172
3203
|
scrollBarHeight,
|
|
3204
|
+
searchId,
|
|
3173
3205
|
searchInputErrorMessage: '',
|
|
3174
3206
|
threads,
|
|
3175
3207
|
value
|
|
@@ -3177,12 +3209,20 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3177
3209
|
};
|
|
3178
3210
|
|
|
3179
3211
|
const getRipGrepArgs = ({
|
|
3212
|
+
defaultExcludes,
|
|
3213
|
+
exclude,
|
|
3180
3214
|
isCaseSensitive,
|
|
3181
3215
|
searchString,
|
|
3182
3216
|
threads,
|
|
3183
3217
|
useRegularExpression
|
|
3184
3218
|
}) => {
|
|
3185
3219
|
const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json', '--threads', `${threads}`];
|
|
3220
|
+
const excludePatternsFromValue = exclude ? exclude.split(',').map(part => part.trim()).filter(Boolean) : [];
|
|
3221
|
+
const excludePatternsFromDefaults = defaultExcludes?.filter(Boolean) || [];
|
|
3222
|
+
const uniqueExcludePatterns = [...new Set([...excludePatternsFromDefaults, ...excludePatternsFromValue])];
|
|
3223
|
+
for (const excludePattern of uniqueExcludePatterns) {
|
|
3224
|
+
ripGrepArgs.push('--glob', `!**/${excludePattern}/**`);
|
|
3225
|
+
}
|
|
3186
3226
|
if (isCaseSensitive) {
|
|
3187
3227
|
ripGrepArgs.push('--case-sensitive');
|
|
3188
3228
|
} else {
|
|
@@ -3268,6 +3308,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3268
3308
|
platform,
|
|
3269
3309
|
threads,
|
|
3270
3310
|
uid,
|
|
3311
|
+
usePullBasedSearch,
|
|
3271
3312
|
value
|
|
3272
3313
|
} = partialNewState;
|
|
3273
3314
|
const root = state.workspacePath;
|
|
@@ -3284,6 +3325,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3284
3325
|
// TODO await promise?
|
|
3285
3326
|
void textSearchIncremental(root, value, {
|
|
3286
3327
|
assetDir: assetDir,
|
|
3328
|
+
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3287
3329
|
exclude: excludeValue,
|
|
3288
3330
|
flags,
|
|
3289
3331
|
include: includeValue,
|
|
@@ -3294,11 +3336,76 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3294
3336
|
root,
|
|
3295
3337
|
scheme,
|
|
3296
3338
|
threads,
|
|
3339
|
+
usePullBasedSearch: usePullBasedSearch || false,
|
|
3297
3340
|
useRegularExpression: Boolean(flags & UseRegularExpression$2)
|
|
3298
3341
|
}, assetDir, platform, searchId, uid);
|
|
3299
3342
|
return state;
|
|
3300
3343
|
};
|
|
3301
3344
|
|
|
3345
|
+
const handleUpdatePullBased = async (state, update) => {
|
|
3346
|
+
const searchId = crypto.randomUUID();
|
|
3347
|
+
const partialNewState = {
|
|
3348
|
+
...state,
|
|
3349
|
+
...update,
|
|
3350
|
+
items: [],
|
|
3351
|
+
listItems: [],
|
|
3352
|
+
message: '',
|
|
3353
|
+
searchId,
|
|
3354
|
+
searchResults: []
|
|
3355
|
+
};
|
|
3356
|
+
set(state.uid, state, partialNewState);
|
|
3357
|
+
const {
|
|
3358
|
+
assetDir,
|
|
3359
|
+
excludeValue,
|
|
3360
|
+
flags,
|
|
3361
|
+
includeValue,
|
|
3362
|
+
limit,
|
|
3363
|
+
platform,
|
|
3364
|
+
threads,
|
|
3365
|
+
uid,
|
|
3366
|
+
usePullBasedSearch,
|
|
3367
|
+
value
|
|
3368
|
+
} = partialNewState;
|
|
3369
|
+
const root = state.workspacePath;
|
|
3370
|
+
const scheme = getProtocol(root);
|
|
3371
|
+
const isFileSearch = scheme === '' || scheme === 'file';
|
|
3372
|
+
const shouldUsePullBasedSearch = Boolean(usePullBasedSearch) && isFileSearch;
|
|
3373
|
+
const {
|
|
3374
|
+
limitHit
|
|
3375
|
+
} = await textSearch$6(root, value, {
|
|
3376
|
+
assetDir,
|
|
3377
|
+
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3378
|
+
exclude: excludeValue,
|
|
3379
|
+
flags,
|
|
3380
|
+
include: includeValue,
|
|
3381
|
+
isCaseSensitive: Boolean(flags & MatchCase$2),
|
|
3382
|
+
limit,
|
|
3383
|
+
matchWholeWord: Boolean(flags & MatchWholeWord$2),
|
|
3384
|
+
query: value,
|
|
3385
|
+
root,
|
|
3386
|
+
scheme,
|
|
3387
|
+
threads,
|
|
3388
|
+
usePullBasedSearch: shouldUsePullBasedSearch,
|
|
3389
|
+
useRegularExpression: Boolean(flags & UseRegularExpression$2)
|
|
3390
|
+
}, assetDir, platform, searchId, uid);
|
|
3391
|
+
const latest = get$1(uid);
|
|
3392
|
+
if (!latest) {
|
|
3393
|
+
return state;
|
|
3394
|
+
}
|
|
3395
|
+
const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
|
|
3396
|
+
const {
|
|
3397
|
+
fileCount,
|
|
3398
|
+
resultCount
|
|
3399
|
+
} = getTextSearchResultCounts(latest.newState.items);
|
|
3400
|
+
const message = getStatusMessage(resultCount, fileCount);
|
|
3401
|
+
return {
|
|
3402
|
+
...latest.newState,
|
|
3403
|
+
limitHit,
|
|
3404
|
+
limitHitWarning,
|
|
3405
|
+
message
|
|
3406
|
+
};
|
|
3407
|
+
};
|
|
3408
|
+
|
|
3302
3409
|
const handleUpdateValidationError = (state, update, searchInputErrorMessage) => {
|
|
3303
3410
|
const partialNewState = {
|
|
3304
3411
|
...state,
|
|
@@ -3338,7 +3445,8 @@ const validateSearchInput = (value, flags) => {
|
|
|
3338
3445
|
|
|
3339
3446
|
const handleUpdate = async (state, update) => {
|
|
3340
3447
|
const {
|
|
3341
|
-
incrementalSearch
|
|
3448
|
+
incrementalSearch,
|
|
3449
|
+
usePullBasedSearch
|
|
3342
3450
|
} = state;
|
|
3343
3451
|
const partialNewState = {
|
|
3344
3452
|
...state,
|
|
@@ -3359,6 +3467,9 @@ const handleUpdate = async (state, update) => {
|
|
|
3359
3467
|
if (incrementalSearch) {
|
|
3360
3468
|
return await handleUpdateIncremental(state, update);
|
|
3361
3469
|
}
|
|
3470
|
+
if (usePullBasedSearch) {
|
|
3471
|
+
return await handleUpdatePullBased(state, update);
|
|
3472
|
+
}
|
|
3362
3473
|
return await handleUpdateFull(state, update);
|
|
3363
3474
|
} catch (error) {
|
|
3364
3475
|
handleError(error);
|
|
@@ -3542,6 +3653,7 @@ const toggleUseRegularExpression = state => {
|
|
|
3542
3653
|
};
|
|
3543
3654
|
|
|
3544
3655
|
const getClickHandler = name => {
|
|
3656
|
+
// TODO maybe add a click handler to each button instead
|
|
3545
3657
|
switch (name) {
|
|
3546
3658
|
case MatchCase:
|
|
3547
3659
|
return toggleMatchCase;
|
|
@@ -3926,6 +4038,63 @@ const handleListFocus = async state => {
|
|
|
3926
4038
|
};
|
|
3927
4039
|
};
|
|
3928
4040
|
|
|
4041
|
+
const handlePullResultsFound = async (state, resultSearchId) => {
|
|
4042
|
+
const {
|
|
4043
|
+
fileIconCache,
|
|
4044
|
+
headerHeight,
|
|
4045
|
+
height,
|
|
4046
|
+
itemHeight,
|
|
4047
|
+
listItems,
|
|
4048
|
+
minimumSliderSize,
|
|
4049
|
+
platform,
|
|
4050
|
+
searchId,
|
|
4051
|
+
uid
|
|
4052
|
+
} = state;
|
|
4053
|
+
if (searchId !== resultSearchId) {
|
|
4054
|
+
return state;
|
|
4055
|
+
}
|
|
4056
|
+
const result = platform === Remote || platform === Electron ? await invoke('TextSearch.getPullResults', searchId) : await invoke$1('SearchProcess.invoke', 'TextSearch.getPullResults', searchId);
|
|
4057
|
+
const newResults = result;
|
|
4058
|
+
const allResults = [...listItems, ...newResults];
|
|
4059
|
+
const {
|
|
4060
|
+
fileCount,
|
|
4061
|
+
resultCount
|
|
4062
|
+
} = getTextSearchResultCounts(allResults);
|
|
4063
|
+
const message = getStatusMessage(resultCount, fileCount);
|
|
4064
|
+
const total = allResults.length;
|
|
4065
|
+
const contentHeight = total * itemHeight;
|
|
4066
|
+
const listHeight = height - headerHeight;
|
|
4067
|
+
const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
|
|
4068
|
+
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
4069
|
+
const maxLineY = Math.min(numberOfVisible, total);
|
|
4070
|
+
const finalDeltaY = Math.max(contentHeight - listHeight, 0);
|
|
4071
|
+
const visible = allResults.slice(0, maxLineY);
|
|
4072
|
+
const {
|
|
4073
|
+
icons,
|
|
4074
|
+
newFileIconCache
|
|
4075
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
4076
|
+
const latest = get$1(uid);
|
|
4077
|
+
const updatedState = {
|
|
4078
|
+
...latest.newState,
|
|
4079
|
+
fileCount,
|
|
4080
|
+
fileIconCache: newFileIconCache,
|
|
4081
|
+
finalDeltaY,
|
|
4082
|
+
icons,
|
|
4083
|
+
items: allResults,
|
|
4084
|
+
listItems: allResults,
|
|
4085
|
+
loaded: true,
|
|
4086
|
+
matchCount: resultCount,
|
|
4087
|
+
maxLineY,
|
|
4088
|
+
message,
|
|
4089
|
+
minLineY: 0,
|
|
4090
|
+
scrollBarHeight
|
|
4091
|
+
};
|
|
4092
|
+
const oldState = latest ? latest.oldState : state;
|
|
4093
|
+
set(uid, oldState, updatedState);
|
|
4094
|
+
await invoke$1('Search.rerender');
|
|
4095
|
+
return state;
|
|
4096
|
+
};
|
|
4097
|
+
|
|
3929
4098
|
const handleSharedInput = (state, name, value, inputSource = Script) => {
|
|
3930
4099
|
const fn = getInputHandler(name);
|
|
3931
4100
|
return fn(state, value, inputSource);
|
|
@@ -3936,7 +4105,7 @@ const send = async port => {
|
|
|
3936
4105
|
};
|
|
3937
4106
|
const launchIconThemeWorker = async () => {
|
|
3938
4107
|
// TODO connect to icon theme worker
|
|
3939
|
-
const rpc = await
|
|
4108
|
+
const rpc = await create$5({
|
|
3940
4109
|
commandMap: {},
|
|
3941
4110
|
send
|
|
3942
4111
|
});
|
|
@@ -3949,7 +4118,7 @@ const initializeIconThemeWorker = async () => {
|
|
|
3949
4118
|
};
|
|
3950
4119
|
|
|
3951
4120
|
const launchSearchProcessElectron = async () => {
|
|
3952
|
-
const rpc = await
|
|
4121
|
+
const rpc = await create$a({
|
|
3953
4122
|
commandMap: {},
|
|
3954
4123
|
send: sendMessagePortToSearchProcess
|
|
3955
4124
|
});
|
|
@@ -3957,7 +4126,7 @@ const launchSearchProcessElectron = async () => {
|
|
|
3957
4126
|
};
|
|
3958
4127
|
|
|
3959
4128
|
const launchSearchProcessNode = async () => {
|
|
3960
|
-
const rpc = await
|
|
4129
|
+
const rpc = await create$7({
|
|
3961
4130
|
commandMap: {},
|
|
3962
4131
|
// @ts-ignore
|
|
3963
4132
|
type: 'search-process'
|
|
@@ -4471,14 +4640,29 @@ const handleListPointerDown = async (state, button, name) => {
|
|
|
4471
4640
|
};
|
|
4472
4641
|
};
|
|
4473
4642
|
|
|
4643
|
+
const getUsePullBasedSearch = async () => {
|
|
4644
|
+
try {
|
|
4645
|
+
return Boolean(await getPreference('Search.usePullBasedSearch'));
|
|
4646
|
+
} catch {
|
|
4647
|
+
return false;
|
|
4648
|
+
}
|
|
4649
|
+
};
|
|
4650
|
+
|
|
4651
|
+
const hasProperty = (object, key) => {
|
|
4652
|
+
if (!object || typeof object !== 'object' || !(key in object)) {
|
|
4653
|
+
return false;
|
|
4654
|
+
}
|
|
4655
|
+
return true;
|
|
4656
|
+
};
|
|
4657
|
+
|
|
4474
4658
|
const getSavedFocus = savedState => {
|
|
4475
|
-
if (savedState
|
|
4659
|
+
if (hasProperty(savedState, 'focus') && typeof savedState.focus === 'number') {
|
|
4476
4660
|
return savedState.focus;
|
|
4477
4661
|
}
|
|
4478
4662
|
return 0;
|
|
4479
4663
|
};
|
|
4480
4664
|
const getSavedListFocus = savedState => {
|
|
4481
|
-
if (savedState
|
|
4665
|
+
if (hasProperty(savedState, 'listFocused') && typeof savedState.listFocused === 'boolean') {
|
|
4482
4666
|
return savedState.listFocused;
|
|
4483
4667
|
}
|
|
4484
4668
|
return false;
|
|
@@ -4488,44 +4672,44 @@ const isString = value => {
|
|
|
4488
4672
|
return typeof value === 'string';
|
|
4489
4673
|
};
|
|
4490
4674
|
const getSavedHistory = savedState => {
|
|
4491
|
-
if (savedState
|
|
4675
|
+
if (hasProperty(savedState, 'history') && Array.isArray(savedState.history) && savedState.history.every(isString)) {
|
|
4492
4676
|
return savedState.history;
|
|
4493
4677
|
}
|
|
4494
4678
|
return [];
|
|
4495
4679
|
};
|
|
4496
4680
|
|
|
4497
4681
|
const getSavedValue = savedState => {
|
|
4498
|
-
if (savedState
|
|
4682
|
+
if (hasProperty(savedState, 'value') && typeof savedState.value === 'string') {
|
|
4499
4683
|
return savedState.value;
|
|
4500
4684
|
}
|
|
4501
4685
|
return '';
|
|
4502
4686
|
};
|
|
4503
4687
|
const getSavedReplacement = savedState => {
|
|
4504
|
-
if (savedState
|
|
4688
|
+
if (hasProperty(savedState, 'replacement') && typeof savedState.replacement === 'string') {
|
|
4505
4689
|
return savedState.replacement;
|
|
4506
4690
|
}
|
|
4507
4691
|
return '';
|
|
4508
4692
|
};
|
|
4509
4693
|
const getSavedFlags = savedState => {
|
|
4510
|
-
if (savedState
|
|
4694
|
+
if (hasProperty(savedState, 'flags') && typeof savedState.flags === 'number') {
|
|
4511
4695
|
return savedState.flags;
|
|
4512
4696
|
}
|
|
4513
|
-
return
|
|
4697
|
+
return UseIgnoreFiles;
|
|
4514
4698
|
};
|
|
4515
4699
|
const getSavedIncludeValue = savedState => {
|
|
4516
|
-
if (savedState
|
|
4700
|
+
if (hasProperty(savedState, 'includeValue') && typeof savedState.includeValue === 'string') {
|
|
4517
4701
|
return savedState.includeValue;
|
|
4518
4702
|
}
|
|
4519
4703
|
return '';
|
|
4520
4704
|
};
|
|
4521
4705
|
const getSavedExcludeValue = savedState => {
|
|
4522
|
-
if (savedState
|
|
4706
|
+
if (hasProperty(savedState, 'excludeValue') && typeof savedState.excludeValue === 'string') {
|
|
4523
4707
|
return savedState.excludeValue;
|
|
4524
4708
|
}
|
|
4525
4709
|
return '';
|
|
4526
4710
|
};
|
|
4527
4711
|
const getSavedCollapsedPaths = savedState => {
|
|
4528
|
-
if (savedState
|
|
4712
|
+
if (hasProperty(savedState, 'collapsedPaths') && Array.isArray(savedState.collapsedPaths) && savedState.collapsedPaths.every(item => typeof item === 'string')) {
|
|
4529
4713
|
return savedState.collapsedPaths;
|
|
4530
4714
|
}
|
|
4531
4715
|
return [];
|
|
@@ -4556,6 +4740,7 @@ const loadContent = async (state, savedState) => {
|
|
|
4556
4740
|
savedValue,
|
|
4557
4741
|
threads
|
|
4558
4742
|
} = restoreState(savedState);
|
|
4743
|
+
const usePullBasedSearch = await getUsePullBasedSearch();
|
|
4559
4744
|
const update = {
|
|
4560
4745
|
collapsedPaths: savedCollapsedPaths,
|
|
4561
4746
|
excludeValue,
|
|
@@ -4566,10 +4751,14 @@ const loadContent = async (state, savedState) => {
|
|
|
4566
4751
|
inputSource: Script,
|
|
4567
4752
|
replacement,
|
|
4568
4753
|
threads,
|
|
4754
|
+
usePullBasedSearch,
|
|
4569
4755
|
value: savedValue
|
|
4570
4756
|
};
|
|
4571
4757
|
if (savedValue) {
|
|
4572
|
-
const result = await handleUpdate(
|
|
4758
|
+
const result = await handleUpdate({
|
|
4759
|
+
...state,
|
|
4760
|
+
usePullBasedSearch
|
|
4761
|
+
}, update);
|
|
4573
4762
|
return {
|
|
4574
4763
|
...result,
|
|
4575
4764
|
initial: false,
|
|
@@ -4582,7 +4771,8 @@ const loadContent = async (state, savedState) => {
|
|
|
4582
4771
|
flags,
|
|
4583
4772
|
initial: false,
|
|
4584
4773
|
loaded: true,
|
|
4585
|
-
threads
|
|
4774
|
+
threads,
|
|
4775
|
+
usePullBasedSearch
|
|
4586
4776
|
};
|
|
4587
4777
|
};
|
|
4588
4778
|
|
|
@@ -5803,8 +5993,11 @@ const focusElement = (state, focusKey) => {
|
|
|
5803
5993
|
};
|
|
5804
5994
|
|
|
5805
5995
|
const handleFocusIn = async (state, key) => {
|
|
5996
|
+
const {
|
|
5997
|
+
focus
|
|
5998
|
+
} = state;
|
|
5806
5999
|
const focusKey = getSearchFocusKey(key);
|
|
5807
|
-
if (
|
|
6000
|
+
if (focus === focusKey) {
|
|
5808
6001
|
return state;
|
|
5809
6002
|
}
|
|
5810
6003
|
return {
|
|
@@ -5994,6 +6187,7 @@ const commandMap = {
|
|
|
5994
6187
|
'TextSearch.handleListBlur': wrapCommand(handleListBlur),
|
|
5995
6188
|
'TextSearch.handleListFocus': wrapCommand(handleListFocus),
|
|
5996
6189
|
'TextSearch.handleListPointerDown': wrapCommand(handleListPointerDown),
|
|
6190
|
+
'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound),
|
|
5997
6191
|
'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
|
|
5998
6192
|
'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
|
|
5999
6193
|
'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
@@ -6079,11 +6273,28 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
|
|
|
6079
6273
|
}
|
|
6080
6274
|
};
|
|
6081
6275
|
|
|
6082
|
-
const textSearch$1 = async (scheme, root, query, options, assetDir, platform) => {
|
|
6276
|
+
const textSearch$1 = async (scheme, root, query, options, assetDir, platform, searchId, uid) => {
|
|
6083
6277
|
const ripGrepArgs = getRipGrepArgs({
|
|
6084
6278
|
...options,
|
|
6085
6279
|
searchString: query
|
|
6086
6280
|
});
|
|
6281
|
+
if (options.usePullBasedSearch && searchId && (scheme === '' || scheme === 'file')) {
|
|
6282
|
+
const pullSearchOptions = {
|
|
6283
|
+
ripGrepArgs,
|
|
6284
|
+
searchDir: root,
|
|
6285
|
+
searchId,
|
|
6286
|
+
uid
|
|
6287
|
+
};
|
|
6288
|
+
if (platform === Remote || platform === Electron) {
|
|
6289
|
+
await invoke('TextSearch.searchPull', pullSearchOptions);
|
|
6290
|
+
} else {
|
|
6291
|
+
await invoke$1('SearchProcess.invoke', 'TextSearch.searchPull', pullSearchOptions);
|
|
6292
|
+
}
|
|
6293
|
+
return {
|
|
6294
|
+
limitHit: false,
|
|
6295
|
+
results: []
|
|
6296
|
+
};
|
|
6297
|
+
}
|
|
6087
6298
|
const actualOptions = {
|
|
6088
6299
|
ripGrepArgs,
|
|
6089
6300
|
searchDir: root
|
|
@@ -6137,7 +6348,7 @@ const textSearchProviderMap = {
|
|
|
6137
6348
|
const listen = async () => {
|
|
6138
6349
|
registerCommands(commandMap);
|
|
6139
6350
|
add(textSearchProviderMap);
|
|
6140
|
-
const rpc = await
|
|
6351
|
+
const rpc = await create$4({
|
|
6141
6352
|
commandMap: commandMap
|
|
6142
6353
|
});
|
|
6143
6354
|
set$2(rpc);
|