@lvce-editor/text-search-worker 6.4.0 → 6.6.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.
@@ -632,12 +632,12 @@ const getErrorConstructor = (message, type) => {
632
632
  switch (type) {
633
633
  case DomException:
634
634
  return DOMException;
635
- case TypeError$1:
636
- return TypeError;
637
- case SyntaxError$1:
638
- return SyntaxError;
639
635
  case ReferenceError$1:
640
636
  return ReferenceError;
637
+ case SyntaxError$1:
638
+ return SyntaxError;
639
+ case TypeError$1:
640
+ return TypeError;
641
641
  default:
642
642
  return Error;
643
643
  }
@@ -793,27 +793,27 @@ const getErrorProperty = (error, prettyError) => {
793
793
  if (error && error.code === E_COMMAND_NOT_FOUND) {
794
794
  return {
795
795
  code: MethodNotFound,
796
- message: error.message,
797
- data: error.stack
796
+ data: error.stack,
797
+ message: error.message
798
798
  };
799
799
  }
800
800
  return {
801
801
  code: Custom,
802
- message: prettyError.message,
803
802
  data: {
804
- stack: getStack(prettyError),
805
- codeFrame: prettyError.codeFrame,
806
- type: getErrorType(prettyError),
807
803
  code: prettyError.code,
808
- name: prettyError.name
809
- }
804
+ codeFrame: prettyError.codeFrame,
805
+ name: prettyError.name,
806
+ stack: getStack(prettyError),
807
+ type: getErrorType(prettyError)
808
+ },
809
+ message: prettyError.message
810
810
  };
811
811
  };
812
812
  const create$1$1 = (id, error) => {
813
813
  return {
814
- jsonrpc: Two$1,
814
+ error,
815
815
  id,
816
- error
816
+ jsonrpc: Two$1
817
817
  };
818
818
  };
819
819
  const getErrorResponse = (id, error, preparePrettyError, logError) => {
@@ -824,8 +824,8 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
824
824
  };
825
825
  const create$e = (message, result) => {
826
826
  return {
827
- jsonrpc: Two$1,
828
827
  id: message.id,
828
+ jsonrpc: Two$1,
829
829
  result: result ?? null
830
830
  };
831
831
  };
@@ -835,14 +835,14 @@ const getSuccessResponse = (message, result) => {
835
835
  };
836
836
  const getErrorResponseSimple = (id, error) => {
837
837
  return {
838
- jsonrpc: Two$1,
839
- id,
840
838
  error: {
841
839
  code: Custom,
840
+ data: error,
842
841
  // @ts-ignore
843
- message: error.message,
844
- data: error
845
- }
842
+ message: error.message
843
+ },
844
+ id,
845
+ jsonrpc: Two$1
846
846
  };
847
847
  };
848
848
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
@@ -872,35 +872,35 @@ const normalizeParams = args => {
872
872
  if (args.length === 1) {
873
873
  const options = args[0];
874
874
  return {
875
+ execute: options.execute,
875
876
  ipc: options.ipc,
877
+ logError: options.logError || defaultLogError,
876
878
  message: options.message,
877
- execute: options.execute,
878
- resolve: options.resolve || defaultResolve,
879
879
  preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
880
- logError: options.logError || defaultLogError,
881
- requiresSocket: options.requiresSocket || defaultRequiresSocket
880
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
881
+ resolve: options.resolve || defaultResolve
882
882
  };
883
883
  }
884
884
  return {
885
+ execute: args[2],
885
886
  ipc: args[0],
887
+ logError: args[5],
886
888
  message: args[1],
887
- execute: args[2],
888
- resolve: args[3],
889
889
  preparePrettyError: args[4],
890
- logError: args[5],
891
- requiresSocket: args[6]
890
+ requiresSocket: args[6],
891
+ resolve: args[3]
892
892
  };
893
893
  };
894
894
  const handleJsonRpcMessage = async (...args) => {
895
895
  const options = normalizeParams(args);
896
896
  const {
897
- message,
898
- ipc,
899
897
  execute,
900
- resolve,
901
- preparePrettyError,
898
+ ipc,
902
899
  logError,
903
- requiresSocket
900
+ message,
901
+ preparePrettyError,
902
+ requiresSocket,
903
+ resolve
904
904
  } = options;
905
905
  if ('id' in message) {
906
906
  if ('method' in message) {
@@ -961,7 +961,6 @@ const registerPromise = map => {
961
961
  };
962
962
  };
963
963
 
964
- // @ts-ignore
965
964
  const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
966
965
  const {
967
966
  id,
@@ -1043,6 +1042,41 @@ const listen$1 = async (module, options) => {
1043
1042
  return ipc;
1044
1043
  };
1045
1044
 
1045
+ const create$a = async ({
1046
+ commandMap,
1047
+ isMessagePortOpen = true,
1048
+ messagePort
1049
+ }) => {
1050
+ // TODO create a commandMap per rpc instance
1051
+ register(commandMap);
1052
+ const rawIpc = await IpcParentWithMessagePort$1.create({
1053
+ isMessagePortOpen,
1054
+ messagePort
1055
+ });
1056
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1057
+ handleIpc(ipc);
1058
+ const rpc = createRpc(ipc);
1059
+ messagePort.start();
1060
+ return rpc;
1061
+ };
1062
+
1063
+ const create$9 = async ({
1064
+ commandMap,
1065
+ isMessagePortOpen,
1066
+ send
1067
+ }) => {
1068
+ const {
1069
+ port1,
1070
+ port2
1071
+ } = new MessageChannel();
1072
+ await send(port1);
1073
+ return create$a({
1074
+ commandMap,
1075
+ isMessagePortOpen,
1076
+ messagePort: port2
1077
+ });
1078
+ };
1079
+
1046
1080
  const createSharedLazyRpc = factory => {
1047
1081
  let rpcPromise;
1048
1082
  const getOrCreate = () => {
@@ -1071,13 +1105,13 @@ const createSharedLazyRpc = factory => {
1071
1105
  };
1072
1106
  };
1073
1107
 
1074
- const create$a = async ({
1108
+ const create$8 = async ({
1075
1109
  commandMap,
1076
1110
  isMessagePortOpen,
1077
1111
  send
1078
1112
  }) => {
1079
1113
  return createSharedLazyRpc(() => {
1080
- return create$5({
1114
+ return create$9({
1081
1115
  commandMap,
1082
1116
  isMessagePortOpen,
1083
1117
  send
@@ -1105,7 +1139,7 @@ const getProtocol$1 = () => {
1105
1139
  return location.protocol;
1106
1140
  };
1107
1141
 
1108
- const create$9 = async ({
1142
+ const create$7 = async ({
1109
1143
  commandMap,
1110
1144
  webSocket
1111
1145
  }) => {
@@ -1120,7 +1154,7 @@ const create$9 = async ({
1120
1154
  return rpc;
1121
1155
  };
1122
1156
 
1123
- const create$8 = async ({
1157
+ const create$6 = async ({
1124
1158
  commandMap,
1125
1159
  type
1126
1160
  }) => {
@@ -1128,69 +1162,102 @@ const create$8 = async ({
1128
1162
  const protocol = getProtocol$1();
1129
1163
  const wsUrl = getWebSocketUrl(type, host, protocol);
1130
1164
  const webSocket = new WebSocket(wsUrl);
1131
- const rpc = await create$9({
1165
+ const rpc = await create$7({
1132
1166
  commandMap,
1133
1167
  webSocket
1134
1168
  });
1135
1169
  return rpc;
1136
1170
  };
1137
1171
 
1138
- const create$7 = async ({
1172
+ const create$5 = async ({
1139
1173
  commandMap,
1140
1174
  type
1141
1175
  }) => {
1142
1176
  return createSharedLazyRpc(() => {
1143
- return create$8({
1177
+ return create$6({
1144
1178
  commandMap,
1145
1179
  type
1146
1180
  });
1147
1181
  });
1148
1182
  };
1149
1183
 
1150
- const create$6 = async ({
1151
- commandMap,
1152
- isMessagePortOpen = true,
1153
- messagePort
1184
+ const create$4 = async ({
1185
+ commandMap
1154
1186
  }) => {
1155
1187
  // TODO create a commandMap per rpc instance
1156
1188
  register(commandMap);
1157
- const rawIpc = await IpcParentWithMessagePort$1.create({
1158
- isMessagePortOpen,
1159
- messagePort
1160
- });
1161
- const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1189
+ const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
1162
1190
  handleIpc(ipc);
1163
1191
  const rpc = createRpc(ipc);
1164
- messagePort.start();
1165
1192
  return rpc;
1166
1193
  };
1167
1194
 
1168
- const create$5 = async ({
1169
- commandMap,
1170
- isMessagePortOpen,
1171
- send
1195
+ const createMockRpc = ({
1196
+ commandMap
1172
1197
  }) => {
1173
- const {
1174
- port1,
1175
- port2
1176
- } = new MessageChannel();
1177
- await send(port1);
1178
- return create$6({
1179
- commandMap,
1180
- isMessagePortOpen,
1181
- messagePort: port2
1182
- });
1198
+ const invocations = [];
1199
+ const invoke = (method, ...params) => {
1200
+ invocations.push([method, ...params]);
1201
+ const command = commandMap[method];
1202
+ if (!command) {
1203
+ throw new Error(`command ${method} not found`);
1204
+ }
1205
+ return command(...params);
1206
+ };
1207
+ const mockRpc = {
1208
+ invocations,
1209
+ invoke,
1210
+ invokeAndTransfer: invoke
1211
+ };
1212
+ return mockRpc;
1183
1213
  };
1184
1214
 
1185
- const create$4 = async ({
1186
- commandMap
1187
- }) => {
1188
- // TODO create a commandMap per rpc instance
1189
- register(commandMap);
1190
- const ipc = await listen$1(IpcChildWithModuleWorkerAndMessagePort$1);
1191
- handleIpc(ipc);
1192
- const rpc = createRpc(ipc);
1193
- return rpc;
1215
+ const rpcs = Object.create(null);
1216
+ const set$4 = (id, rpc) => {
1217
+ rpcs[id] = rpc;
1218
+ };
1219
+ const get$2 = id => {
1220
+ return rpcs[id];
1221
+ };
1222
+ const remove$2 = id => {
1223
+ delete rpcs[id];
1224
+ };
1225
+
1226
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1227
+ const create$3 = rpcId => {
1228
+ return {
1229
+ async dispose() {
1230
+ const rpc = get$2(rpcId);
1231
+ await rpc.dispose();
1232
+ },
1233
+ // @ts-ignore
1234
+ invoke(method, ...params) {
1235
+ const rpc = get$2(rpcId);
1236
+ // @ts-ignore
1237
+ return rpc.invoke(method, ...params);
1238
+ },
1239
+ // @ts-ignore
1240
+ invokeAndTransfer(method, ...params) {
1241
+ const rpc = get$2(rpcId);
1242
+ // @ts-ignore
1243
+ return rpc.invokeAndTransfer(method, ...params);
1244
+ },
1245
+ registerMockRpc(commandMap) {
1246
+ const mockRpc = createMockRpc({
1247
+ commandMap
1248
+ });
1249
+ set$4(rpcId, mockRpc);
1250
+ // @ts-ignore
1251
+ mockRpc[Symbol.dispose] = () => {
1252
+ remove$2(rpcId);
1253
+ };
1254
+ // @ts-ignore
1255
+ return mockRpc;
1256
+ },
1257
+ set(rpc) {
1258
+ set$4(rpcId, rpc);
1259
+ }
1260
+ };
1194
1261
  };
1195
1262
 
1196
1263
  const Alert = 'alert';
@@ -1328,74 +1395,6 @@ const FocusSearchWholeWord = 34;
1328
1395
  const FocusToggleDetails = 1010;
1329
1396
  const FocusToggleReplace = 1020;
1330
1397
 
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
-
1351
- const rpcs = Object.create(null);
1352
- const set$4 = (id, rpc) => {
1353
- rpcs[id] = rpc;
1354
- };
1355
- const get$2 = id => {
1356
- return rpcs[id];
1357
- };
1358
- const remove$2 = id => {
1359
- delete rpcs[id];
1360
- };
1361
-
1362
- /* eslint-disable @typescript-eslint/explicit-function-return-type */
1363
- const create$3 = rpcId => {
1364
- return {
1365
- async dispose() {
1366
- const rpc = get$2(rpcId);
1367
- await rpc.dispose();
1368
- },
1369
- // @ts-ignore
1370
- invoke(method, ...params) {
1371
- const rpc = get$2(rpcId);
1372
- // @ts-ignore
1373
- return rpc.invoke(method, ...params);
1374
- },
1375
- // @ts-ignore
1376
- invokeAndTransfer(method, ...params) {
1377
- const rpc = get$2(rpcId);
1378
- // @ts-ignore
1379
- return rpc.invokeAndTransfer(method, ...params);
1380
- },
1381
- registerMockRpc(commandMap) {
1382
- const mockRpc = createMockRpc({
1383
- commandMap
1384
- });
1385
- set$4(rpcId, mockRpc);
1386
- // @ts-ignore
1387
- mockRpc[Symbol.dispose] = () => {
1388
- remove$2(rpcId);
1389
- };
1390
- // @ts-ignore
1391
- return mockRpc;
1392
- },
1393
- set(rpc) {
1394
- set$4(rpcId, rpc);
1395
- }
1396
- };
1397
- };
1398
-
1399
1398
  const {
1400
1399
  invoke: invoke$2,
1401
1400
  set: set$3
@@ -1482,7 +1481,7 @@ const create$2 = () => {
1482
1481
  },
1483
1482
  getKeys() {
1484
1483
  return Object.keys(states).map(key => {
1485
- return Number.parseInt(key);
1484
+ return Number.parseFloat(key);
1486
1485
  });
1487
1486
  },
1488
1487
  registerCommands(commandMap) {
@@ -1524,6 +1523,37 @@ const create$2 = () => {
1524
1523
  return fn(newState, ...args);
1525
1524
  };
1526
1525
  return wrapped;
1526
+ },
1527
+ wrapLoadContent(fn) {
1528
+ const wrapped = async (uid, ...args) => {
1529
+ const {
1530
+ newState,
1531
+ oldState
1532
+ } = states[uid];
1533
+ const result = await fn(newState, ...args);
1534
+ const {
1535
+ error,
1536
+ state
1537
+ } = result;
1538
+ if (oldState === state || newState === state) {
1539
+ return {
1540
+ error
1541
+ };
1542
+ }
1543
+ const latestOld = states[uid];
1544
+ const latestNew = {
1545
+ ...latestOld.newState,
1546
+ ...state
1547
+ };
1548
+ states[uid] = {
1549
+ newState: latestNew,
1550
+ oldState: latestOld.oldState
1551
+ };
1552
+ return {
1553
+ error
1554
+ };
1555
+ };
1556
+ return wrapped;
1527
1557
  }
1528
1558
  };
1529
1559
  };
@@ -2026,15 +2056,38 @@ const hasUseIgnoreFiles = flags => {
2026
2056
  return (flags & UseIgnoreFiles) === UseIgnoreFiles;
2027
2057
  };
2028
2058
 
2059
+ const getTopHeight = flags => {
2060
+ if (flags & ReplaceExpanded && flags & DetailsExpanded) {
2061
+ return 190;
2062
+ }
2063
+ if (flags & DetailsExpanded) {
2064
+ return 158;
2065
+ }
2066
+ if (flags & ReplaceExpanded) {
2067
+ return 93;
2068
+ }
2069
+ return 61;
2070
+ };
2071
+
2072
+ const getHeaderHeightForFlags = (headerHeight, oldFlags, newFlags) => {
2073
+ const oldTopHeight = getTopHeight(oldFlags);
2074
+ const newTopHeight = getTopHeight(newFlags);
2075
+ const warningHeight = Math.max(headerHeight - oldTopHeight, 0);
2076
+ return newTopHeight + warningHeight;
2077
+ };
2078
+
2029
2079
  const collapseDetails = state => {
2030
2080
  const {
2031
- flags
2081
+ flags,
2082
+ headerHeight
2032
2083
  } = state;
2084
+ const newFlags = flags & -33;
2033
2085
  return {
2034
2086
  ...state,
2035
- flags: flags & -33,
2087
+ flags: newFlags,
2036
2088
  focus: FocusSearchInput,
2037
- focusSource: Script
2089
+ focusSource: Script,
2090
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
2038
2091
  };
2039
2092
  };
2040
2093
 
@@ -2107,6 +2160,7 @@ const create$1 = ({
2107
2160
  };
2108
2161
 
2109
2162
  const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '', platform) => {
2163
+ const headerHeight = getTopHeight(0);
2110
2164
  const state = {
2111
2165
  disposed: false,
2112
2166
  fileCount: 0,
@@ -2120,8 +2174,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
2120
2174
  x,
2121
2175
  y,
2122
2176
  ...create$1({
2123
- headerHeight: 61,
2124
- // TODO
2177
+ headerHeight,
2125
2178
  itemHeight: itemHeight || 22,
2126
2179
  minimumSliderSize: minimumSliderSize
2127
2180
  }),
@@ -2673,13 +2726,16 @@ const enableRenderFolderPaths = state => {
2673
2726
 
2674
2727
  const expandDetails = state => {
2675
2728
  const {
2676
- flags
2729
+ flags,
2730
+ headerHeight
2677
2731
  } = state;
2732
+ const newFlags = flags | DetailsExpanded;
2678
2733
  return {
2679
2734
  ...state,
2680
- flags: flags | DetailsExpanded,
2735
+ flags: newFlags,
2681
2736
  focus: FocusSearchIncludeInput,
2682
- focusSource: Script
2737
+ focusSource: Script,
2738
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
2683
2739
  };
2684
2740
  };
2685
2741
 
@@ -3095,6 +3151,24 @@ const getProtocol = uri => {
3095
3151
  return '';
3096
3152
  };
3097
3153
 
3154
+ const measureTextHeight = (text, fontFamily, fontSize, lineHeight, width) => {
3155
+ return invoke$1('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, `${lineHeight}px`, width);
3156
+ };
3157
+
3158
+ const SearchWarningFontFamily = 'system-ui';
3159
+ const SearchWarningFontSize = 12;
3160
+ const SearchWarningLineHeight = 18;
3161
+ const SearchWarningHorizontalPadding = 10;
3162
+ const SearchWarningVerticalPadding = 8;
3163
+ const getSearchWarningMessageHeight = async (limitHitWarning, width) => {
3164
+ if (!limitHitWarning) {
3165
+ return 0;
3166
+ }
3167
+ const availableWidth = Math.max(width - SearchWarningHorizontalPadding, 1);
3168
+ const textHeight = await measureTextHeight(limitHitWarning, SearchWarningFontFamily, SearchWarningFontSize, SearchWarningLineHeight, availableWidth);
3169
+ return textHeight + SearchWarningVerticalPadding;
3170
+ };
3171
+
3098
3172
  const getTextSearchResultCounts = results => {
3099
3173
  let resultCount = 0;
3100
3174
  let fileCount = 0;
@@ -3145,7 +3219,6 @@ const handleUpdateFull = async (state, update) => {
3145
3219
  excludeValue,
3146
3220
  fileIconCache,
3147
3221
  flags,
3148
- headerHeight,
3149
3222
  height,
3150
3223
  includeValue,
3151
3224
  itemHeight,
@@ -3155,7 +3228,8 @@ const handleUpdateFull = async (state, update) => {
3155
3228
  threads,
3156
3229
  uid,
3157
3230
  usePullBasedSearch,
3158
- value
3231
+ value,
3232
+ width
3159
3233
  } = partialNewState;
3160
3234
  const root = state.workspacePath;
3161
3235
  const scheme = getProtocol(root);
@@ -3189,6 +3263,9 @@ const handleUpdateFull = async (state, update) => {
3189
3263
  resultCount
3190
3264
  } = getTextSearchResultCounts(results);
3191
3265
  const message = getStatusMessage(resultCount, fileCount);
3266
+ const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
3267
+ const warningHeight = await getSearchWarningMessageHeight(limitHitWarning, width);
3268
+ const headerHeight = getTopHeight(flags) + warningHeight;
3192
3269
  const total = results.length;
3193
3270
  const contentHeight = total * itemHeight;
3194
3271
  const listHeight = height - headerHeight;
@@ -3201,7 +3278,6 @@ const handleUpdateFull = async (state, update) => {
3201
3278
  icons,
3202
3279
  newFileIconCache
3203
3280
  } = await getFileIcons(visible, fileIconCache);
3204
- const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
3205
3281
  return {
3206
3282
  ...partialNewState,
3207
3283
  collapsedPaths: [],
@@ -3209,6 +3285,7 @@ const handleUpdateFull = async (state, update) => {
3209
3285
  fileCount,
3210
3286
  fileIconCache: newFileIconCache,
3211
3287
  finalDeltaY,
3288
+ headerHeight,
3212
3289
  icons,
3213
3290
  items: results,
3214
3291
  limitHit,
@@ -3361,8 +3438,11 @@ const handleUpdateIncremental = async (state, update) => {
3361
3438
  return state;
3362
3439
  };
3363
3440
 
3441
+ const getsearchid = () => {
3442
+ return crypto.randomUUID();
3443
+ };
3364
3444
  const handleUpdatePullBased = async (state, update) => {
3365
- const searchId = crypto.randomUUID();
3445
+ const searchId = getsearchid();
3366
3446
  const partialNewState = {
3367
3447
  ...state,
3368
3448
  ...update,
@@ -3383,7 +3463,8 @@ const handleUpdatePullBased = async (state, update) => {
3383
3463
  threads,
3384
3464
  uid,
3385
3465
  usePullBasedSearch,
3386
- value
3466
+ value,
3467
+ width
3387
3468
  } = partialNewState;
3388
3469
  const root = state.workspacePath;
3389
3470
  const scheme = getProtocol(root);
@@ -3412,6 +3493,8 @@ const handleUpdatePullBased = async (state, update) => {
3412
3493
  return state;
3413
3494
  }
3414
3495
  const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
3496
+ const warningHeight = await getSearchWarningMessageHeight(limitHitWarning, width);
3497
+ const headerHeight = getTopHeight(flags) + warningHeight;
3415
3498
  const {
3416
3499
  fileCount,
3417
3500
  resultCount
@@ -3419,6 +3502,7 @@ const handleUpdatePullBased = async (state, update) => {
3419
3502
  const message = getStatusMessage(resultCount, fileCount);
3420
3503
  return {
3421
3504
  ...latest.newState,
3505
+ headerHeight,
3422
3506
  limitHit,
3423
3507
  limitHitWarning,
3424
3508
  message
@@ -3547,10 +3631,6 @@ const getReplacedMessage = (fileCount, replaceCount, replacement) => {
3547
3631
  };
3548
3632
 
3549
3633
  const getReplaceElements = (items, workspacePath, replacement) => {
3550
- let element = {
3551
- changes: [],
3552
- uri: ''
3553
- };
3554
3634
  const bulkChanges = [];
3555
3635
  let changes = [];
3556
3636
  // TODO simplify code by first matching files with their elements, then creating bulk edits
@@ -3566,11 +3646,10 @@ const getReplaceElements = (items, workspacePath, replacement) => {
3566
3646
  changes = [];
3567
3647
  const fileName = getFilePath(text);
3568
3648
  const absolutePath = `${workspacePath}/${fileName}`;
3569
- element = {
3649
+ bulkChanges.push({
3570
3650
  changes,
3571
3651
  uri: absolutePath
3572
- };
3573
- bulkChanges.push(element);
3652
+ });
3574
3653
  } else {
3575
3654
  changes.push({
3576
3655
  endColumnIndex: end,
@@ -3638,21 +3717,27 @@ const togglePreserveCase = state => {
3638
3717
 
3639
3718
  const collapseReplace = state => {
3640
3719
  const {
3641
- flags
3720
+ flags,
3721
+ headerHeight
3642
3722
  } = state;
3723
+ const newFlags = flags & -5;
3643
3724
  return {
3644
3725
  ...state,
3645
- flags: flags & -5
3726
+ flags: newFlags,
3727
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
3646
3728
  };
3647
3729
  };
3648
3730
 
3649
3731
  const expandReplace = state => {
3650
3732
  const {
3651
- flags
3733
+ flags,
3734
+ headerHeight
3652
3735
  } = state;
3736
+ const newFlags = flags | ReplaceExpanded;
3653
3737
  return {
3654
3738
  ...state,
3655
- flags: flags | ReplaceExpanded
3739
+ flags: newFlags,
3740
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
3656
3741
  };
3657
3742
  };
3658
3743
 
@@ -4184,7 +4269,7 @@ const send = async port => {
4184
4269
  };
4185
4270
  const launchIconThemeWorker = async () => {
4186
4271
  // TODO connect to icon theme worker
4187
- const rpc = await create$5({
4272
+ const rpc = await create$9({
4188
4273
  commandMap: {},
4189
4274
  send
4190
4275
  });
@@ -4197,7 +4282,7 @@ const initializeIconThemeWorker = async () => {
4197
4282
  };
4198
4283
 
4199
4284
  const launchSearchProcessElectron = async () => {
4200
- const rpc = await create$a({
4285
+ const rpc = await create$8({
4201
4286
  commandMap: {},
4202
4287
  send: sendMessagePortToSearchProcess
4203
4288
  });
@@ -4205,7 +4290,7 @@ const launchSearchProcessElectron = async () => {
4205
4290
  };
4206
4291
 
4207
4292
  const launchSearchProcessNode = async () => {
4208
- const rpc = await create$7({
4293
+ const rpc = await create$5({
4209
4294
  commandMap: {},
4210
4295
  // @ts-ignore
4211
4296
  type: 'search-process'
@@ -4536,19 +4621,6 @@ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemC
4536
4621
  return index;
4537
4622
  };
4538
4623
 
4539
- const getTopHeight = flags => {
4540
- if (flags & ReplaceExpanded && flags & DetailsExpanded) {
4541
- return 190;
4542
- }
4543
- if (flags & DetailsExpanded) {
4544
- return 158;
4545
- }
4546
- if (flags & ReplaceExpanded) {
4547
- return 93;
4548
- }
4549
- return 61;
4550
- };
4551
-
4552
4624
  const getFilteredResults = (results, collapsedPaths) => {
4553
4625
  if (collapsedPaths.length === 0) {
4554
4626
  return results;
@@ -4699,14 +4771,13 @@ const selectIndex = async (state, index) => {
4699
4771
  const handleClickAt = async (state, eventX, eventY, name) => {
4700
4772
  const {
4701
4773
  deltaY,
4702
- flags,
4774
+ headerHeight,
4703
4775
  itemHeight,
4704
4776
  listItems,
4705
4777
  x,
4706
4778
  y
4707
4779
  } = state;
4708
- const topHeight = getTopHeight(flags);
4709
- const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
4780
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight, listItems.length);
4710
4781
  const isRemoveButton = name === Remove;
4711
4782
  if (isRemoveButton) {
4712
4783
  return removeIndex(state, index);
@@ -4828,12 +4899,15 @@ const loadContent = async (state, savedState) => {
4828
4899
  threads
4829
4900
  } = restoreState(savedState);
4830
4901
  const usePullBasedSearch = await getUsePullBasedSearch();
4902
+ const warningHeight = await getSearchWarningMessageHeight(state.limitHitWarning, state.width);
4903
+ const headerHeight = getTopHeight(flags) + warningHeight;
4831
4904
  const update = {
4832
4905
  collapsedPaths: savedCollapsedPaths,
4833
4906
  excludeValue,
4834
4907
  flags,
4835
4908
  focus: 0,
4836
4909
  // TODO
4910
+ headerHeight,
4837
4911
  includeValue,
4838
4912
  inputSource: Script,
4839
4913
  replacement,
@@ -6251,15 +6325,14 @@ const handleContextMenuKeyboard = async state => {
6251
6325
  const handleContextMenuMouseAt = async (state, eventX, eventY) => {
6252
6326
  const {
6253
6327
  deltaY,
6254
- flags,
6328
+ headerHeight,
6255
6329
  itemHeight,
6256
6330
  listItems,
6257
6331
  uid,
6258
6332
  x,
6259
6333
  y
6260
6334
  } = state;
6261
- const topHeight = getTopHeight(flags);
6262
- const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
6335
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight, listItems.length);
6263
6336
  const {
6264
6337
  newState,
6265
6338
  oldState
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "6.4.0",
3
+ "version": "6.6.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"