@lvce-editor/text-search-worker 6.1.0 → 6.3.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 +410 -164
- 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 => {
|
|
@@ -801,7 +822,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
|
|
|
801
822
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
802
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$4 = (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$s = (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$j
|
|
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$i = 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$h = 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$g
|
|
1146
|
-
};
|
|
1147
|
-
const create$5 = async ({
|
|
1149
|
+
|
|
1150
|
+
const create$6 = async ({
|
|
1148
1151
|
commandMap,
|
|
1149
1152
|
isMessagePortOpen = true,
|
|
1150
1153
|
messagePort
|
|
@@ -1161,7 +1164,8 @@ const create$5 = 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$3$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$3$1
|
|
1183
|
-
};
|
|
1184
|
-
const create$2$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$2$1 = async ({
|
|
|
1191
1192
|
const rpc = createRpc(ipc);
|
|
1192
1193
|
return rpc;
|
|
1193
1194
|
};
|
|
1194
|
-
const WebWorkerRpcClient = {
|
|
1195
|
-
__proto__: null,
|
|
1196
|
-
create: create$2$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';
|
|
@@ -1328,6 +1306,7 @@ const File$1 = 1;
|
|
|
1328
1306
|
const Match$1 = 2;
|
|
1329
1307
|
|
|
1330
1308
|
const FocusElementByName = 'Viewlet.focusElementByName';
|
|
1309
|
+
const SetCss = 'Viewlet.setCss';
|
|
1331
1310
|
const SetDom2 = 'Viewlet.setDom2';
|
|
1332
1311
|
const SetFocusContext = 'Viewlet.setFocusContext';
|
|
1333
1312
|
const SetValueByName = 'Viewlet.setValueByName';
|
|
@@ -1349,6 +1328,26 @@ const FocusSearchWholeWord = 34;
|
|
|
1349
1328
|
const FocusToggleDetails = 1010;
|
|
1350
1329
|
const FocusToggleReplace = 1020;
|
|
1351
1330
|
|
|
1331
|
+
const createMockRpc = ({
|
|
1332
|
+
commandMap
|
|
1333
|
+
}) => {
|
|
1334
|
+
const invocations = [];
|
|
1335
|
+
const invoke = (method, ...params) => {
|
|
1336
|
+
invocations.push([method, ...params]);
|
|
1337
|
+
const command = commandMap[method];
|
|
1338
|
+
if (!command) {
|
|
1339
|
+
throw new Error(`command ${method} not found`);
|
|
1340
|
+
}
|
|
1341
|
+
return command(...params);
|
|
1342
|
+
};
|
|
1343
|
+
const mockRpc = {
|
|
1344
|
+
invocations,
|
|
1345
|
+
invoke,
|
|
1346
|
+
invokeAndTransfer: invoke
|
|
1347
|
+
};
|
|
1348
|
+
return mockRpc;
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1352
1351
|
const rpcs = Object.create(null);
|
|
1353
1352
|
const set$4 = (id, rpc) => {
|
|
1354
1353
|
rpcs[id] = rpc;
|
|
@@ -1431,6 +1430,9 @@ const sendMessagePortToSearchProcess = async port => {
|
|
|
1431
1430
|
const writeClipBoardText = async text => {
|
|
1432
1431
|
await invoke$1('ClipBoard.writeText', /* text */text);
|
|
1433
1432
|
};
|
|
1433
|
+
const getPreference = async key => {
|
|
1434
|
+
return await invoke$1('Preferences.get', key);
|
|
1435
|
+
};
|
|
1434
1436
|
const openUri$1 = async (uri, focus, options) => {
|
|
1435
1437
|
await invoke$1('Main.openUri', uri, focus, options);
|
|
1436
1438
|
};
|
|
@@ -2177,6 +2179,8 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2177
2179
|
threads: 0,
|
|
2178
2180
|
useChevrons: true,
|
|
2179
2181
|
useFileIcons: true,
|
|
2182
|
+
usePullBasedSearch: false,
|
|
2183
|
+
// TODO enable
|
|
2180
2184
|
viewMode: List,
|
|
2181
2185
|
workspacePath: workspacePath
|
|
2182
2186
|
};
|
|
@@ -2184,6 +2188,10 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
|
|
|
2184
2188
|
return state;
|
|
2185
2189
|
};
|
|
2186
2190
|
|
|
2191
|
+
const isEqual$7 = (oldState, newState) => {
|
|
2192
|
+
return oldState.deltaY === newState.deltaY && oldState.finalDeltaY === newState.finalDeltaY && oldState.height === newState.height && oldState.headerHeight === newState.headerHeight && oldState.itemHeight === newState.itemHeight && oldState.items === newState.items;
|
|
2193
|
+
};
|
|
2194
|
+
|
|
2187
2195
|
const RenderItems = 1;
|
|
2188
2196
|
const RenderFocus = 2;
|
|
2189
2197
|
const RenderValue = 3;
|
|
@@ -2193,6 +2201,7 @@ const RenderExcludeValue = 6;
|
|
|
2193
2201
|
const RenderFocusContext = 7;
|
|
2194
2202
|
const RenderSelections = 8;
|
|
2195
2203
|
const RenderIncremental = 9;
|
|
2204
|
+
const RenderCss = 10;
|
|
2196
2205
|
|
|
2197
2206
|
const isEqual$6 = (oldState, newState) => {
|
|
2198
2207
|
return oldState.excludeValue === newState.excludeValue || newState.inputSource === User;
|
|
@@ -2222,8 +2231,8 @@ const isEqual = (oldState, newState) => {
|
|
|
2222
2231
|
return oldState.value === newState.value || newState.inputSource === User;
|
|
2223
2232
|
};
|
|
2224
2233
|
|
|
2225
|
-
const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4];
|
|
2226
|
-
const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext];
|
|
2234
|
+
const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4, isEqual$7];
|
|
2235
|
+
const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext, RenderCss];
|
|
2227
2236
|
|
|
2228
2237
|
const diff = (oldState, newState) => {
|
|
2229
2238
|
const diffResult = [];
|
|
@@ -3104,12 +3113,12 @@ const getTextSearchProvider = scheme => {
|
|
|
3104
3113
|
return get(scheme);
|
|
3105
3114
|
};
|
|
3106
3115
|
|
|
3107
|
-
const textSearch$6 = async (root, query, options, assetDir, platform) => {
|
|
3116
|
+
const textSearch$6 = async (root, query, options, assetDir, platform, searchId, uid) => {
|
|
3108
3117
|
string(root);
|
|
3109
3118
|
string(query);
|
|
3110
3119
|
const scheme = getProtocol(root);
|
|
3111
3120
|
const provider = getTextSearchProvider(scheme);
|
|
3112
|
-
const results = await provider(scheme, root, query, options, assetDir, platform);
|
|
3121
|
+
const results = await provider(scheme, root, query, options, assetDir, platform, searchId, uid);
|
|
3113
3122
|
return results;
|
|
3114
3123
|
};
|
|
3115
3124
|
|
|
@@ -3131,10 +3140,15 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3131
3140
|
minimumSliderSize,
|
|
3132
3141
|
platform,
|
|
3133
3142
|
threads,
|
|
3143
|
+
uid,
|
|
3144
|
+
usePullBasedSearch,
|
|
3134
3145
|
value
|
|
3135
3146
|
} = partialNewState;
|
|
3136
3147
|
const root = state.workspacePath;
|
|
3137
3148
|
const scheme = getProtocol(root);
|
|
3149
|
+
const isFileSearch = scheme === '' || scheme === 'file';
|
|
3150
|
+
const shouldUsePullBasedSearch = Boolean(usePullBasedSearch) && isFileSearch;
|
|
3151
|
+
const searchId = shouldUsePullBasedSearch ? crypto.randomUUID() : '';
|
|
3138
3152
|
const {
|
|
3139
3153
|
limitHit,
|
|
3140
3154
|
results
|
|
@@ -3151,8 +3165,9 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3151
3165
|
root,
|
|
3152
3166
|
scheme,
|
|
3153
3167
|
threads,
|
|
3168
|
+
usePullBasedSearch: shouldUsePullBasedSearch,
|
|
3154
3169
|
useRegularExpression: Boolean(flags & UseRegularExpression$2)
|
|
3155
|
-
}, assetDir, platform);
|
|
3170
|
+
}, assetDir, platform, searchId, uid);
|
|
3156
3171
|
if (!Array.isArray(results)) {
|
|
3157
3172
|
throw new TypeError('results must be of type array');
|
|
3158
3173
|
}
|
|
@@ -3192,6 +3207,7 @@ const handleUpdateFull = async (state, update) => {
|
|
|
3192
3207
|
message,
|
|
3193
3208
|
minLineY: 0,
|
|
3194
3209
|
scrollBarHeight,
|
|
3210
|
+
searchId,
|
|
3195
3211
|
searchInputErrorMessage: '',
|
|
3196
3212
|
threads,
|
|
3197
3213
|
value
|
|
@@ -3298,6 +3314,7 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3298
3314
|
platform,
|
|
3299
3315
|
threads,
|
|
3300
3316
|
uid,
|
|
3317
|
+
usePullBasedSearch,
|
|
3301
3318
|
value
|
|
3302
3319
|
} = partialNewState;
|
|
3303
3320
|
const root = state.workspacePath;
|
|
@@ -3325,11 +3342,76 @@ const handleUpdateIncremental = async (state, update) => {
|
|
|
3325
3342
|
root,
|
|
3326
3343
|
scheme,
|
|
3327
3344
|
threads,
|
|
3345
|
+
usePullBasedSearch: usePullBasedSearch || false,
|
|
3328
3346
|
useRegularExpression: Boolean(flags & UseRegularExpression$2)
|
|
3329
3347
|
}, assetDir, platform, searchId, uid);
|
|
3330
3348
|
return state;
|
|
3331
3349
|
};
|
|
3332
3350
|
|
|
3351
|
+
const handleUpdatePullBased = async (state, update) => {
|
|
3352
|
+
const searchId = crypto.randomUUID();
|
|
3353
|
+
const partialNewState = {
|
|
3354
|
+
...state,
|
|
3355
|
+
...update,
|
|
3356
|
+
items: [],
|
|
3357
|
+
listItems: [],
|
|
3358
|
+
message: '',
|
|
3359
|
+
searchId,
|
|
3360
|
+
searchResults: []
|
|
3361
|
+
};
|
|
3362
|
+
set(state.uid, state, partialNewState);
|
|
3363
|
+
const {
|
|
3364
|
+
assetDir,
|
|
3365
|
+
excludeValue,
|
|
3366
|
+
flags,
|
|
3367
|
+
includeValue,
|
|
3368
|
+
limit,
|
|
3369
|
+
platform,
|
|
3370
|
+
threads,
|
|
3371
|
+
uid,
|
|
3372
|
+
usePullBasedSearch,
|
|
3373
|
+
value
|
|
3374
|
+
} = partialNewState;
|
|
3375
|
+
const root = state.workspacePath;
|
|
3376
|
+
const scheme = getProtocol(root);
|
|
3377
|
+
const isFileSearch = scheme === '' || scheme === 'file';
|
|
3378
|
+
const shouldUsePullBasedSearch = Boolean(usePullBasedSearch) && isFileSearch;
|
|
3379
|
+
const {
|
|
3380
|
+
limitHit
|
|
3381
|
+
} = await textSearch$6(root, value, {
|
|
3382
|
+
assetDir,
|
|
3383
|
+
defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
|
|
3384
|
+
exclude: excludeValue,
|
|
3385
|
+
flags,
|
|
3386
|
+
include: includeValue,
|
|
3387
|
+
isCaseSensitive: Boolean(flags & MatchCase$2),
|
|
3388
|
+
limit,
|
|
3389
|
+
matchWholeWord: Boolean(flags & MatchWholeWord$2),
|
|
3390
|
+
query: value,
|
|
3391
|
+
root,
|
|
3392
|
+
scheme,
|
|
3393
|
+
threads,
|
|
3394
|
+
usePullBasedSearch: shouldUsePullBasedSearch,
|
|
3395
|
+
useRegularExpression: Boolean(flags & UseRegularExpression$2)
|
|
3396
|
+
}, assetDir, platform, searchId, uid);
|
|
3397
|
+
const latest = get$1(uid);
|
|
3398
|
+
if (!latest) {
|
|
3399
|
+
return state;
|
|
3400
|
+
}
|
|
3401
|
+
const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
|
|
3402
|
+
const {
|
|
3403
|
+
fileCount,
|
|
3404
|
+
resultCount
|
|
3405
|
+
} = getTextSearchResultCounts(latest.newState.items);
|
|
3406
|
+
const message = getStatusMessage(resultCount, fileCount);
|
|
3407
|
+
return {
|
|
3408
|
+
...latest.newState,
|
|
3409
|
+
limitHit,
|
|
3410
|
+
limitHitWarning,
|
|
3411
|
+
message
|
|
3412
|
+
};
|
|
3413
|
+
};
|
|
3414
|
+
|
|
3333
3415
|
const handleUpdateValidationError = (state, update, searchInputErrorMessage) => {
|
|
3334
3416
|
const partialNewState = {
|
|
3335
3417
|
...state,
|
|
@@ -3369,7 +3451,8 @@ const validateSearchInput = (value, flags) => {
|
|
|
3369
3451
|
|
|
3370
3452
|
const handleUpdate = async (state, update) => {
|
|
3371
3453
|
const {
|
|
3372
|
-
incrementalSearch
|
|
3454
|
+
incrementalSearch,
|
|
3455
|
+
usePullBasedSearch
|
|
3373
3456
|
} = state;
|
|
3374
3457
|
const partialNewState = {
|
|
3375
3458
|
...state,
|
|
@@ -3390,6 +3473,9 @@ const handleUpdate = async (state, update) => {
|
|
|
3390
3473
|
if (incrementalSearch) {
|
|
3391
3474
|
return await handleUpdateIncremental(state, update);
|
|
3392
3475
|
}
|
|
3476
|
+
if (usePullBasedSearch) {
|
|
3477
|
+
return await handleUpdatePullBased(state, update);
|
|
3478
|
+
}
|
|
3393
3479
|
return await handleUpdateFull(state, update);
|
|
3394
3480
|
} catch (error) {
|
|
3395
3481
|
handleError(error);
|
|
@@ -3958,6 +4044,63 @@ const handleListFocus = async state => {
|
|
|
3958
4044
|
};
|
|
3959
4045
|
};
|
|
3960
4046
|
|
|
4047
|
+
const handlePullResultsFound = async (state, resultSearchId) => {
|
|
4048
|
+
const {
|
|
4049
|
+
fileIconCache,
|
|
4050
|
+
headerHeight,
|
|
4051
|
+
height,
|
|
4052
|
+
itemHeight,
|
|
4053
|
+
listItems,
|
|
4054
|
+
minimumSliderSize,
|
|
4055
|
+
platform,
|
|
4056
|
+
searchId,
|
|
4057
|
+
uid
|
|
4058
|
+
} = state;
|
|
4059
|
+
if (searchId !== resultSearchId) {
|
|
4060
|
+
return state;
|
|
4061
|
+
}
|
|
4062
|
+
const result = platform === Remote || platform === Electron ? await invoke('TextSearch.getPullResults', searchId) : await invoke$1('SearchProcess.invoke', 'TextSearch.getPullResults', searchId);
|
|
4063
|
+
const newResults = result;
|
|
4064
|
+
const allResults = [...listItems, ...newResults];
|
|
4065
|
+
const {
|
|
4066
|
+
fileCount,
|
|
4067
|
+
resultCount
|
|
4068
|
+
} = getTextSearchResultCounts(allResults);
|
|
4069
|
+
const message = getStatusMessage(resultCount, fileCount);
|
|
4070
|
+
const total = allResults.length;
|
|
4071
|
+
const contentHeight = total * itemHeight;
|
|
4072
|
+
const listHeight = height - headerHeight;
|
|
4073
|
+
const scrollBarHeight = getScrollBarSize$1(height, contentHeight, minimumSliderSize);
|
|
4074
|
+
const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
|
|
4075
|
+
const maxLineY = Math.min(numberOfVisible, total);
|
|
4076
|
+
const finalDeltaY = Math.max(contentHeight - listHeight, 0);
|
|
4077
|
+
const visible = allResults.slice(0, maxLineY);
|
|
4078
|
+
const {
|
|
4079
|
+
icons,
|
|
4080
|
+
newFileIconCache
|
|
4081
|
+
} = await getFileIcons(visible, fileIconCache);
|
|
4082
|
+
const latest = get$1(uid);
|
|
4083
|
+
const updatedState = {
|
|
4084
|
+
...latest.newState,
|
|
4085
|
+
fileCount,
|
|
4086
|
+
fileIconCache: newFileIconCache,
|
|
4087
|
+
finalDeltaY,
|
|
4088
|
+
icons,
|
|
4089
|
+
items: allResults,
|
|
4090
|
+
listItems: allResults,
|
|
4091
|
+
loaded: true,
|
|
4092
|
+
matchCount: resultCount,
|
|
4093
|
+
maxLineY,
|
|
4094
|
+
message,
|
|
4095
|
+
minLineY: 0,
|
|
4096
|
+
scrollBarHeight
|
|
4097
|
+
};
|
|
4098
|
+
const oldState = latest ? latest.oldState : state;
|
|
4099
|
+
set(uid, oldState, updatedState);
|
|
4100
|
+
await invoke$1('Search.rerender');
|
|
4101
|
+
return state;
|
|
4102
|
+
};
|
|
4103
|
+
|
|
3961
4104
|
const handleSharedInput = (state, name, value, inputSource = Script) => {
|
|
3962
4105
|
const fn = getInputHandler(name);
|
|
3963
4106
|
return fn(state, value, inputSource);
|
|
@@ -3968,7 +4111,7 @@ const send = async port => {
|
|
|
3968
4111
|
};
|
|
3969
4112
|
const launchIconThemeWorker = async () => {
|
|
3970
4113
|
// TODO connect to icon theme worker
|
|
3971
|
-
const rpc = await
|
|
4114
|
+
const rpc = await create$5({
|
|
3972
4115
|
commandMap: {},
|
|
3973
4116
|
send
|
|
3974
4117
|
});
|
|
@@ -3981,7 +4124,7 @@ const initializeIconThemeWorker = async () => {
|
|
|
3981
4124
|
};
|
|
3982
4125
|
|
|
3983
4126
|
const launchSearchProcessElectron = async () => {
|
|
3984
|
-
const rpc = await
|
|
4127
|
+
const rpc = await create$a({
|
|
3985
4128
|
commandMap: {},
|
|
3986
4129
|
send: sendMessagePortToSearchProcess
|
|
3987
4130
|
});
|
|
@@ -3989,7 +4132,7 @@ const launchSearchProcessElectron = async () => {
|
|
|
3989
4132
|
};
|
|
3990
4133
|
|
|
3991
4134
|
const launchSearchProcessNode = async () => {
|
|
3992
|
-
const rpc = await
|
|
4135
|
+
const rpc = await create$7({
|
|
3993
4136
|
commandMap: {},
|
|
3994
4137
|
// @ts-ignore
|
|
3995
4138
|
type: 'search-process'
|
|
@@ -4503,14 +4646,29 @@ const handleListPointerDown = async (state, button, name) => {
|
|
|
4503
4646
|
};
|
|
4504
4647
|
};
|
|
4505
4648
|
|
|
4649
|
+
const getUsePullBasedSearch = async () => {
|
|
4650
|
+
try {
|
|
4651
|
+
return Boolean(await getPreference('Search.usePullBasedSearch'));
|
|
4652
|
+
} catch {
|
|
4653
|
+
return false;
|
|
4654
|
+
}
|
|
4655
|
+
};
|
|
4656
|
+
|
|
4657
|
+
const hasProperty = (object, key) => {
|
|
4658
|
+
if (!object || typeof object !== 'object' || !(key in object)) {
|
|
4659
|
+
return false;
|
|
4660
|
+
}
|
|
4661
|
+
return true;
|
|
4662
|
+
};
|
|
4663
|
+
|
|
4506
4664
|
const getSavedFocus = savedState => {
|
|
4507
|
-
if (savedState
|
|
4665
|
+
if (hasProperty(savedState, 'focus') && typeof savedState.focus === 'number') {
|
|
4508
4666
|
return savedState.focus;
|
|
4509
4667
|
}
|
|
4510
4668
|
return 0;
|
|
4511
4669
|
};
|
|
4512
4670
|
const getSavedListFocus = savedState => {
|
|
4513
|
-
if (savedState
|
|
4671
|
+
if (hasProperty(savedState, 'listFocused') && typeof savedState.listFocused === 'boolean') {
|
|
4514
4672
|
return savedState.listFocused;
|
|
4515
4673
|
}
|
|
4516
4674
|
return false;
|
|
@@ -4520,44 +4678,44 @@ const isString = value => {
|
|
|
4520
4678
|
return typeof value === 'string';
|
|
4521
4679
|
};
|
|
4522
4680
|
const getSavedHistory = savedState => {
|
|
4523
|
-
if (savedState
|
|
4681
|
+
if (hasProperty(savedState, 'history') && Array.isArray(savedState.history) && savedState.history.every(isString)) {
|
|
4524
4682
|
return savedState.history;
|
|
4525
4683
|
}
|
|
4526
4684
|
return [];
|
|
4527
4685
|
};
|
|
4528
4686
|
|
|
4529
4687
|
const getSavedValue = savedState => {
|
|
4530
|
-
if (savedState
|
|
4688
|
+
if (hasProperty(savedState, 'value') && typeof savedState.value === 'string') {
|
|
4531
4689
|
return savedState.value;
|
|
4532
4690
|
}
|
|
4533
4691
|
return '';
|
|
4534
4692
|
};
|
|
4535
4693
|
const getSavedReplacement = savedState => {
|
|
4536
|
-
if (savedState
|
|
4694
|
+
if (hasProperty(savedState, 'replacement') && typeof savedState.replacement === 'string') {
|
|
4537
4695
|
return savedState.replacement;
|
|
4538
4696
|
}
|
|
4539
4697
|
return '';
|
|
4540
4698
|
};
|
|
4541
4699
|
const getSavedFlags = savedState => {
|
|
4542
|
-
if (savedState
|
|
4700
|
+
if (hasProperty(savedState, 'flags') && typeof savedState.flags === 'number') {
|
|
4543
4701
|
return savedState.flags;
|
|
4544
4702
|
}
|
|
4545
4703
|
return UseIgnoreFiles;
|
|
4546
4704
|
};
|
|
4547
4705
|
const getSavedIncludeValue = savedState => {
|
|
4548
|
-
if (savedState
|
|
4706
|
+
if (hasProperty(savedState, 'includeValue') && typeof savedState.includeValue === 'string') {
|
|
4549
4707
|
return savedState.includeValue;
|
|
4550
4708
|
}
|
|
4551
4709
|
return '';
|
|
4552
4710
|
};
|
|
4553
4711
|
const getSavedExcludeValue = savedState => {
|
|
4554
|
-
if (savedState
|
|
4712
|
+
if (hasProperty(savedState, 'excludeValue') && typeof savedState.excludeValue === 'string') {
|
|
4555
4713
|
return savedState.excludeValue;
|
|
4556
4714
|
}
|
|
4557
4715
|
return '';
|
|
4558
4716
|
};
|
|
4559
4717
|
const getSavedCollapsedPaths = savedState => {
|
|
4560
|
-
if (savedState
|
|
4718
|
+
if (hasProperty(savedState, 'collapsedPaths') && Array.isArray(savedState.collapsedPaths) && savedState.collapsedPaths.every(item => typeof item === 'string')) {
|
|
4561
4719
|
return savedState.collapsedPaths;
|
|
4562
4720
|
}
|
|
4563
4721
|
return [];
|
|
@@ -4588,6 +4746,7 @@ const loadContent = async (state, savedState) => {
|
|
|
4588
4746
|
savedValue,
|
|
4589
4747
|
threads
|
|
4590
4748
|
} = restoreState(savedState);
|
|
4749
|
+
const usePullBasedSearch = await getUsePullBasedSearch();
|
|
4591
4750
|
const update = {
|
|
4592
4751
|
collapsedPaths: savedCollapsedPaths,
|
|
4593
4752
|
excludeValue,
|
|
@@ -4598,10 +4757,14 @@ const loadContent = async (state, savedState) => {
|
|
|
4598
4757
|
inputSource: Script,
|
|
4599
4758
|
replacement,
|
|
4600
4759
|
threads,
|
|
4760
|
+
usePullBasedSearch,
|
|
4601
4761
|
value: savedValue
|
|
4602
4762
|
};
|
|
4603
4763
|
if (savedValue) {
|
|
4604
|
-
const result = await handleUpdate(
|
|
4764
|
+
const result = await handleUpdate({
|
|
4765
|
+
...state,
|
|
4766
|
+
usePullBasedSearch
|
|
4767
|
+
}, update);
|
|
4605
4768
|
return {
|
|
4606
4769
|
...result,
|
|
4607
4770
|
initial: false,
|
|
@@ -4614,7 +4777,8 @@ const loadContent = async (state, savedState) => {
|
|
|
4614
4777
|
flags,
|
|
4615
4778
|
initial: false,
|
|
4616
4779
|
loaded: true,
|
|
4617
|
-
threads
|
|
4780
|
+
threads,
|
|
4781
|
+
usePullBasedSearch
|
|
4618
4782
|
};
|
|
4619
4783
|
};
|
|
4620
4784
|
|
|
@@ -4670,50 +4834,6 @@ const removeCurrent = async state => {
|
|
|
4670
4834
|
return removeIndex(state, actualIndex);
|
|
4671
4835
|
};
|
|
4672
4836
|
|
|
4673
|
-
const getFocusSelector = focusKey => {
|
|
4674
|
-
switch (focusKey) {
|
|
4675
|
-
case FocusIgnoreFiles:
|
|
4676
|
-
return UseExcludeSettings;
|
|
4677
|
-
case FocusSearchExcludeInput:
|
|
4678
|
-
return FilesToExclude;
|
|
4679
|
-
case FocusSearchIncludeInput:
|
|
4680
|
-
return FilesToInclude;
|
|
4681
|
-
case FocusSearchInput:
|
|
4682
|
-
return SearchValue;
|
|
4683
|
-
case FocusSearchMatchCase:
|
|
4684
|
-
return MatchCase;
|
|
4685
|
-
case FocusSearchOpenEditors:
|
|
4686
|
-
return SearchOnlyOpenEditors;
|
|
4687
|
-
case FocusSearchPreserveCase:
|
|
4688
|
-
return PreserveCase;
|
|
4689
|
-
case FocusSearchRegex:
|
|
4690
|
-
return UseRegularExpression;
|
|
4691
|
-
case FocusSearchReplaceAll:
|
|
4692
|
-
return ReplaceAll;
|
|
4693
|
-
case FocusSearchReplaceInput:
|
|
4694
|
-
return ReplaceValue;
|
|
4695
|
-
case FocusSearchResults:
|
|
4696
|
-
return '.Tree';
|
|
4697
|
-
case FocusSearchWholeWord:
|
|
4698
|
-
return MatchWholeWord;
|
|
4699
|
-
case FocusToggleDetails:
|
|
4700
|
-
return ToggleSearchDetails;
|
|
4701
|
-
case FocusToggleReplace:
|
|
4702
|
-
return ToggleReplace;
|
|
4703
|
-
default:
|
|
4704
|
-
return '';
|
|
4705
|
-
}
|
|
4706
|
-
};
|
|
4707
|
-
|
|
4708
|
-
const renderFocus = (oldState, newState) => {
|
|
4709
|
-
const selector = getFocusSelector(newState.focus);
|
|
4710
|
-
return [FocusElementByName, newState.uid, selector];
|
|
4711
|
-
};
|
|
4712
|
-
|
|
4713
|
-
const renderFocusContext = (oldState, newState) => {
|
|
4714
|
-
return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
|
|
4715
|
-
};
|
|
4716
|
-
|
|
4717
4837
|
const None = 0;
|
|
4718
4838
|
const Collapsed = 1;
|
|
4719
4839
|
const Expanded = 2;
|
|
@@ -4728,6 +4848,12 @@ const getMatchCount = (results, startIndex) => {
|
|
|
4728
4848
|
return results.length - startIndex - 1;
|
|
4729
4849
|
};
|
|
4730
4850
|
|
|
4851
|
+
const defaultIndent = 12;
|
|
4852
|
+
const baseIndent = 16;
|
|
4853
|
+
const getTreeItemIndent = depth => {
|
|
4854
|
+
return baseIndent + depth * defaultIndent;
|
|
4855
|
+
};
|
|
4856
|
+
|
|
4731
4857
|
const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPaths, text, posInSet, relativeIndex, focused, originalResults) => {
|
|
4732
4858
|
const path = text;
|
|
4733
4859
|
const absolutePath = getRelativePath(path);
|
|
@@ -4736,12 +4862,15 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
4736
4862
|
const matchCount = getMatchCount(originalResults, index);
|
|
4737
4863
|
const expanded = collapsedPaths.includes(path) ? Collapsed : Expanded;
|
|
4738
4864
|
const badgeText = `${matchCount}`;
|
|
4865
|
+
const depth = 0;
|
|
4866
|
+
const indent = getTreeItemIndent(depth);
|
|
4739
4867
|
return {
|
|
4740
4868
|
badgeText,
|
|
4741
|
-
depth
|
|
4869
|
+
depth,
|
|
4742
4870
|
expanded,
|
|
4743
4871
|
focused,
|
|
4744
4872
|
icon: fileIcons[relativeIndex],
|
|
4873
|
+
indent,
|
|
4745
4874
|
matchLength: 0,
|
|
4746
4875
|
matchStart: 0,
|
|
4747
4876
|
posInSet,
|
|
@@ -4753,12 +4882,15 @@ const getSearchDisplayResultFile = (results, fileIcons, i, setSize, collapsedPat
|
|
|
4753
4882
|
};
|
|
4754
4883
|
|
|
4755
4884
|
const getDisplayResultMatch = (setSize, searchTermLength, replacement, text, posInSet, start, focused) => {
|
|
4885
|
+
const depth = 1;
|
|
4886
|
+
const indent = getTreeItemIndent(depth);
|
|
4756
4887
|
return {
|
|
4757
4888
|
badgeText: '',
|
|
4758
|
-
depth
|
|
4889
|
+
depth,
|
|
4759
4890
|
expanded: None,
|
|
4760
4891
|
focused,
|
|
4761
4892
|
icon: '',
|
|
4893
|
+
indent,
|
|
4762
4894
|
matchLength: searchTermLength,
|
|
4763
4895
|
matchStart: start,
|
|
4764
4896
|
posInSet,
|
|
@@ -4849,6 +4981,106 @@ const createViewModel = state => {
|
|
|
4849
4981
|
};
|
|
4850
4982
|
};
|
|
4851
4983
|
|
|
4984
|
+
const getIndentRule = indent => {
|
|
4985
|
+
return `.Indent-${indent} {
|
|
4986
|
+
padding-left: ${indent}px;
|
|
4987
|
+
}`;
|
|
4988
|
+
};
|
|
4989
|
+
const getIndentRightRule = indentRight => {
|
|
4990
|
+
return `.IndentRight-${indentRight} {
|
|
4991
|
+
padding-right: ${indentRight}px;
|
|
4992
|
+
}`;
|
|
4993
|
+
};
|
|
4994
|
+
const getTreeItemsTopRule = treeItemsTop => {
|
|
4995
|
+
const roundedTreeItemsTop = Math.round(treeItemsTop);
|
|
4996
|
+
return `.TreeItemsTop-${roundedTreeItemsTop} {
|
|
4997
|
+
top: ${roundedTreeItemsTop}px;
|
|
4998
|
+
}`;
|
|
4999
|
+
};
|
|
5000
|
+
const getCss = (top, uniqueIndents, uniqueIndentRights, scrollBarHeight, scrollBarY, treeItemsTop) => {
|
|
5001
|
+
const rules = [`.Search {
|
|
5002
|
+
--ScrollBarHeight: ${scrollBarHeight}px;
|
|
5003
|
+
--ScrollBarTop: ${scrollBarY}px;
|
|
5004
|
+
--TreeItemsTop: ${top}px;
|
|
5005
|
+
}
|
|
5006
|
+
`, ...uniqueIndents.map(getIndentRule), ...uniqueIndentRights.map(getIndentRightRule), getTreeItemsTopRule(treeItemsTop)];
|
|
5007
|
+
return rules.join('\n');
|
|
5008
|
+
};
|
|
5009
|
+
|
|
5010
|
+
const getUnique = items => {
|
|
5011
|
+
const seens = [];
|
|
5012
|
+
for (const item of items) {
|
|
5013
|
+
if (!seens.includes(item)) {
|
|
5014
|
+
seens.push(item);
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
return seens;
|
|
5018
|
+
};
|
|
5019
|
+
|
|
5020
|
+
const getUniqueIndents = indents => {
|
|
5021
|
+
const uniqueIndents = getUnique(indents);
|
|
5022
|
+
return uniqueIndents;
|
|
5023
|
+
};
|
|
5024
|
+
|
|
5025
|
+
const PaddingRight = 12;
|
|
5026
|
+
|
|
5027
|
+
const renderCss = (oldState, newState) => {
|
|
5028
|
+
const {
|
|
5029
|
+
uid
|
|
5030
|
+
} = newState;
|
|
5031
|
+
const viewModel = createViewModel(newState);
|
|
5032
|
+
const indents = viewModel.displayResults.map(item => item.indent);
|
|
5033
|
+
const uniqueIndents = getUniqueIndents(indents);
|
|
5034
|
+
const uniqueIndentRights = [PaddingRight];
|
|
5035
|
+
const treeItemsTop = viewModel.itemHeight === 0 ? 0 : Math.round(-(viewModel.deltaY % viewModel.itemHeight));
|
|
5036
|
+
const css = getCss(0, uniqueIndents, uniqueIndentRights, viewModel.scrollBarHeight, viewModel.scrollBarY, treeItemsTop);
|
|
5037
|
+
return [SetCss, uid, css];
|
|
5038
|
+
};
|
|
5039
|
+
|
|
5040
|
+
const getFocusSelector = focusKey => {
|
|
5041
|
+
switch (focusKey) {
|
|
5042
|
+
case FocusIgnoreFiles:
|
|
5043
|
+
return UseExcludeSettings;
|
|
5044
|
+
case FocusSearchExcludeInput:
|
|
5045
|
+
return FilesToExclude;
|
|
5046
|
+
case FocusSearchIncludeInput:
|
|
5047
|
+
return FilesToInclude;
|
|
5048
|
+
case FocusSearchInput:
|
|
5049
|
+
return SearchValue;
|
|
5050
|
+
case FocusSearchMatchCase:
|
|
5051
|
+
return MatchCase;
|
|
5052
|
+
case FocusSearchOpenEditors:
|
|
5053
|
+
return SearchOnlyOpenEditors;
|
|
5054
|
+
case FocusSearchPreserveCase:
|
|
5055
|
+
return PreserveCase;
|
|
5056
|
+
case FocusSearchRegex:
|
|
5057
|
+
return UseRegularExpression;
|
|
5058
|
+
case FocusSearchReplaceAll:
|
|
5059
|
+
return ReplaceAll;
|
|
5060
|
+
case FocusSearchReplaceInput:
|
|
5061
|
+
return ReplaceValue;
|
|
5062
|
+
case FocusSearchResults:
|
|
5063
|
+
return '.Tree';
|
|
5064
|
+
case FocusSearchWholeWord:
|
|
5065
|
+
return MatchWholeWord;
|
|
5066
|
+
case FocusToggleDetails:
|
|
5067
|
+
return ToggleSearchDetails;
|
|
5068
|
+
case FocusToggleReplace:
|
|
5069
|
+
return ToggleReplace;
|
|
5070
|
+
default:
|
|
5071
|
+
return '';
|
|
5072
|
+
}
|
|
5073
|
+
};
|
|
5074
|
+
|
|
5075
|
+
const renderFocus = (oldState, newState) => {
|
|
5076
|
+
const selector = getFocusSelector(newState.focus);
|
|
5077
|
+
return [FocusElementByName, newState.uid, selector];
|
|
5078
|
+
};
|
|
5079
|
+
|
|
5080
|
+
const renderFocusContext = (oldState, newState) => {
|
|
5081
|
+
return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
|
|
5082
|
+
};
|
|
5083
|
+
|
|
4852
5084
|
const HandleClick = 1;
|
|
4853
5085
|
const HandleListContextMenu = 2;
|
|
4854
5086
|
const HandleHeaderContextMenu = 3;
|
|
@@ -4875,7 +5107,7 @@ const getSearchDetailsToggleVirtualDom = () => {
|
|
|
4875
5107
|
return [{
|
|
4876
5108
|
ariaLabel: toggleSearchDetails(),
|
|
4877
5109
|
childCount: 1,
|
|
4878
|
-
className: ToggleDetails,
|
|
5110
|
+
className: mergeClassNames(ToggleDetails, IconButton),
|
|
4879
5111
|
name: ToggleSearchDetails,
|
|
4880
5112
|
onClick: HandleButtonClick,
|
|
4881
5113
|
role: Button$3,
|
|
@@ -5354,17 +5586,14 @@ const getLabelVirtualDom = (displayText, matchLength, matchStart, replacement) =
|
|
|
5354
5586
|
const highlight = displayText.slice(matchStart, matchStart + matchLength);
|
|
5355
5587
|
const after = displayText.slice(matchStart + matchLength);
|
|
5356
5588
|
if (replacement) {
|
|
5357
|
-
|
|
5589
|
+
const replacementPreview = replacement.split(/\r\n|\r|\n/, 1)[0];
|
|
5590
|
+
return [label4, text(before), deleted, text(highlight), inserted, text(replacementPreview), text(after)];
|
|
5358
5591
|
}
|
|
5359
5592
|
return [label3, text(before), highlighted, text(highlight), text(after)];
|
|
5360
5593
|
}
|
|
5361
5594
|
return [label1, text(displayText)];
|
|
5362
5595
|
};
|
|
5363
5596
|
|
|
5364
|
-
const getPaddingLeft = depth => {
|
|
5365
|
-
return `${Number(depth) + 1}rem`; // TODO use classname and dynamic css
|
|
5366
|
-
};
|
|
5367
|
-
|
|
5368
5597
|
const getChildCount = (icon, expanded, badgeText) => {
|
|
5369
5598
|
let childCount = 0;
|
|
5370
5599
|
if (expanded) {
|
|
@@ -5405,8 +5634,6 @@ const getSearchResultClassName = focused => {
|
|
|
5405
5634
|
return TreeItem;
|
|
5406
5635
|
};
|
|
5407
5636
|
|
|
5408
|
-
const PaddingRight = '12px';
|
|
5409
|
-
|
|
5410
5637
|
const getSearchResultVirtualDom = rowInfo => {
|
|
5411
5638
|
const {
|
|
5412
5639
|
badgeText,
|
|
@@ -5414,6 +5641,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5414
5641
|
expanded,
|
|
5415
5642
|
focused,
|
|
5416
5643
|
icon,
|
|
5644
|
+
indent,
|
|
5417
5645
|
matchLength,
|
|
5418
5646
|
matchStart,
|
|
5419
5647
|
posInSet,
|
|
@@ -5422,6 +5650,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5422
5650
|
text: displayText,
|
|
5423
5651
|
title
|
|
5424
5652
|
} = rowInfo;
|
|
5653
|
+
const className = `${getSearchResultClassName(focused)} Indent-${indent} IndentRight-${PaddingRight}`;
|
|
5425
5654
|
const childCount = getChildCount(icon, expanded, badgeText);
|
|
5426
5655
|
const dom = [{
|
|
5427
5656
|
ariaDescription: '',
|
|
@@ -5431,9 +5660,7 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5431
5660
|
ariaPosInSet: posInSet,
|
|
5432
5661
|
ariaSetSize: setSize,
|
|
5433
5662
|
childCount,
|
|
5434
|
-
className
|
|
5435
|
-
paddingLeft: getPaddingLeft(depth),
|
|
5436
|
-
paddingRight: PaddingRight,
|
|
5663
|
+
className,
|
|
5437
5664
|
role: TreeItem$1,
|
|
5438
5665
|
title,
|
|
5439
5666
|
type: Div
|
|
@@ -5442,17 +5669,16 @@ const getSearchResultVirtualDom = rowInfo => {
|
|
|
5442
5669
|
};
|
|
5443
5670
|
|
|
5444
5671
|
const getTreeItemsVirtualDom = (visibleItems, deltaY, itemHeight) => {
|
|
5445
|
-
const pixelOffset = deltaY % itemHeight;
|
|
5672
|
+
const pixelOffset = itemHeight === 0 ? 0 : deltaY % itemHeight;
|
|
5673
|
+
const treeItemsTop = Math.round(-pixelOffset);
|
|
5446
5674
|
return [{
|
|
5447
5675
|
childCount: visibleItems.length,
|
|
5448
|
-
className: TreeItems$1
|
|
5676
|
+
className: `${TreeItems$1} TreeItemsTop-${treeItemsTop}`,
|
|
5449
5677
|
id: TreeItems,
|
|
5450
5678
|
onBlur: HandleListBlur,
|
|
5451
5679
|
onClick: HandleClick,
|
|
5452
5680
|
onContextMenu: HandleListContextMenu,
|
|
5453
5681
|
onWheel: HandleWheel,
|
|
5454
|
-
top: `${-pixelOffset}px`,
|
|
5455
|
-
// TODO use dynamic css instead
|
|
5456
5682
|
type: Div
|
|
5457
5683
|
}, ...visibleItems.flatMap(getSearchResultVirtualDom)];
|
|
5458
5684
|
};
|
|
@@ -5522,6 +5748,8 @@ const renderExcludeValue = (oldState, newState) => {
|
|
|
5522
5748
|
|
|
5523
5749
|
const getRenderer = diffType => {
|
|
5524
5750
|
switch (diffType) {
|
|
5751
|
+
case RenderCss:
|
|
5752
|
+
return renderCss;
|
|
5525
5753
|
case RenderExcludeValue:
|
|
5526
5754
|
return renderExcludeValue;
|
|
5527
5755
|
case RenderFocus:
|
|
@@ -6029,6 +6257,7 @@ const commandMap = {
|
|
|
6029
6257
|
'TextSearch.handleListBlur': wrapCommand(handleListBlur),
|
|
6030
6258
|
'TextSearch.handleListFocus': wrapCommand(handleListFocus),
|
|
6031
6259
|
'TextSearch.handleListPointerDown': wrapCommand(handleListPointerDown),
|
|
6260
|
+
'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound),
|
|
6032
6261
|
'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
|
|
6033
6262
|
'TextSearch.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
|
|
6034
6263
|
'TextSearch.handleScrollBarClick': wrapCommand(handleScrollBarClick),
|
|
@@ -6114,11 +6343,28 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
|
|
|
6114
6343
|
}
|
|
6115
6344
|
};
|
|
6116
6345
|
|
|
6117
|
-
const textSearch$1 = async (scheme, root, query, options, assetDir, platform) => {
|
|
6346
|
+
const textSearch$1 = async (scheme, root, query, options, assetDir, platform, searchId, uid) => {
|
|
6118
6347
|
const ripGrepArgs = getRipGrepArgs({
|
|
6119
6348
|
...options,
|
|
6120
6349
|
searchString: query
|
|
6121
6350
|
});
|
|
6351
|
+
if (options.usePullBasedSearch && searchId && (scheme === '' || scheme === 'file')) {
|
|
6352
|
+
const pullSearchOptions = {
|
|
6353
|
+
ripGrepArgs,
|
|
6354
|
+
searchDir: root,
|
|
6355
|
+
searchId,
|
|
6356
|
+
uid
|
|
6357
|
+
};
|
|
6358
|
+
if (platform === Remote || platform === Electron) {
|
|
6359
|
+
await invoke('TextSearch.searchPull', pullSearchOptions);
|
|
6360
|
+
} else {
|
|
6361
|
+
await invoke$1('SearchProcess.invoke', 'TextSearch.searchPull', pullSearchOptions);
|
|
6362
|
+
}
|
|
6363
|
+
return {
|
|
6364
|
+
limitHit: false,
|
|
6365
|
+
results: []
|
|
6366
|
+
};
|
|
6367
|
+
}
|
|
6122
6368
|
const actualOptions = {
|
|
6123
6369
|
ripGrepArgs,
|
|
6124
6370
|
searchDir: root
|
|
@@ -6172,7 +6418,7 @@ const textSearchProviderMap = {
|
|
|
6172
6418
|
const listen = async () => {
|
|
6173
6419
|
registerCommands(commandMap);
|
|
6174
6420
|
add(textSearchProviderMap);
|
|
6175
|
-
const rpc = await
|
|
6421
|
+
const rpc = await create$4({
|
|
6176
6422
|
commandMap: commandMap
|
|
6177
6423
|
});
|
|
6178
6424
|
set$2(rpc);
|