@lvce-editor/text-search-view 1.0.1 → 1.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.
@@ -435,9 +435,6 @@ const IpcChildWithModuleWorkerAndMessagePort$1 = {
435
435
  listen: listen$6,
436
436
  wrap: wrap$e
437
437
  };
438
- const Error$3 = 1;
439
- const Open = 2;
440
- const Close = 3;
441
438
  const addListener = (emitter, type, callback) => {
442
439
  if ('addEventListener' in emitter) {
443
440
  emitter.addEventListener(type, callback);
@@ -532,66 +529,6 @@ const IpcParentWithMessagePort$1 = {
532
529
  signal: signal$1,
533
530
  wrap: wrap$5
534
531
  };
535
- const stringifyCompact = value => {
536
- return JSON.stringify(value);
537
- };
538
- const parse = content => {
539
- if (content === 'undefined') {
540
- return null;
541
- }
542
- try {
543
- return JSON.parse(content);
544
- } catch (error) {
545
- throw new VError(error, 'failed to parse json');
546
- }
547
- };
548
- const waitForWebSocketToBeOpen = webSocket => {
549
- return getFirstEvent(webSocket, {
550
- close: Close,
551
- error: Error$3,
552
- open: Open
553
- });
554
- };
555
- const create$f = async ({
556
- webSocket
557
- }) => {
558
- const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
559
- if (firstWebSocketEvent.type === Error$3) {
560
- throw new IpcError(`WebSocket connection error`);
561
- }
562
- if (firstWebSocketEvent.type === Close) {
563
- throw new IpcError('Websocket connection was immediately closed');
564
- }
565
- return webSocket;
566
- };
567
- class IpcParentWithWebSocket extends Ipc {
568
- getData(event) {
569
- return parse(event.data);
570
- }
571
- send(message) {
572
- this._rawIpc.send(stringifyCompact(message));
573
- }
574
- sendAndTransfer(message) {
575
- throw new Error('sendAndTransfer not supported');
576
- }
577
- dispose() {
578
- this._rawIpc.close();
579
- }
580
- onClose(callback) {
581
- this._rawIpc.addEventListener('close', callback);
582
- }
583
- onMessage(callback) {
584
- this._rawIpc.addEventListener('message', callback);
585
- }
586
- }
587
- const wrap = webSocket => {
588
- return new IpcParentWithWebSocket(webSocket);
589
- };
590
- const IpcParentWithWebSocket$1 = {
591
- __proto__: null,
592
- create: create$f,
593
- wrap
594
- };
595
532
 
596
533
  class CommandNotFoundError extends Error {
597
534
  constructor(command) {
@@ -616,7 +553,7 @@ const execute = (command, ...args) => {
616
553
 
617
554
  const Two$1 = '2.0';
618
555
  const callbacks = Object.create(null);
619
- const get$3 = id => {
556
+ const get$2 = id => {
620
557
  return callbacks[id];
621
558
  };
622
559
  const remove$3 = id => {
@@ -806,7 +743,7 @@ const warn = (...args) => {
806
743
  console.warn(...args);
807
744
  };
808
745
  const resolve = (id, response) => {
809
- const fn = get$3(id);
746
+ const fn = get$2(id);
810
747
  if (!fn) {
811
748
  console.log(response);
812
749
  warn(`callback ${id} may already be disposed`);
@@ -869,7 +806,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
869
806
  const errorProperty = getErrorProperty(error, prettyError);
870
807
  return create$1$1(id, errorProperty);
871
808
  };
872
- const create$e = (message, result) => {
809
+ const create$b = (message, result) => {
873
810
  return {
874
811
  id: message.id,
875
812
  jsonrpc: Two$1,
@@ -878,7 +815,7 @@ const create$e = (message, result) => {
878
815
  };
879
816
  const getSuccessResponse = (message, result) => {
880
817
  const resultProperty = result ?? null;
881
- return create$e(message, resultProperty);
818
+ return create$b(message, resultProperty);
882
819
  };
883
820
  const getErrorResponseSimple = (id, error) => {
884
821
  return {
@@ -972,7 +909,7 @@ const handleJsonRpcMessage = async (...args) => {
972
909
 
973
910
  const Two = '2.0';
974
911
 
975
- const create$d = (method, params) => {
912
+ const create$a = (method, params) => {
976
913
  return {
977
914
  jsonrpc: Two,
978
915
  method,
@@ -980,7 +917,7 @@ const create$d = (method, params) => {
980
917
  };
981
918
  };
982
919
 
983
- const create$c = (id, method, params) => {
920
+ const create$9 = (id, method, params) => {
984
921
  const message = {
985
922
  id,
986
923
  jsonrpc: Two,
@@ -991,12 +928,12 @@ const create$c = (id, method, params) => {
991
928
  };
992
929
 
993
930
  let id = 0;
994
- const create$b = () => {
931
+ const create$8 = () => {
995
932
  return ++id;
996
933
  };
997
934
 
998
935
  const registerPromise = map => {
999
- const id = create$b();
936
+ const id = create$8();
1000
937
  const {
1001
938
  promise,
1002
939
  resolve
@@ -1013,7 +950,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
1013
950
  id,
1014
951
  promise
1015
952
  } = registerPromise(callbacks);
1016
- const message = create$c(id, method, params);
953
+ const message = create$9(id, method, params);
1017
954
  if (useSendAndTransfer && ipc.sendAndTransfer) {
1018
955
  ipc.sendAndTransfer(message);
1019
956
  } else {
@@ -1049,7 +986,7 @@ const createRpc = ipc => {
1049
986
  * @deprecated
1050
987
  */
1051
988
  send(method, ...params) {
1052
- const message = create$d(method, params);
989
+ const message = create$a(method, params);
1053
990
  ipc.send(message);
1054
991
  }
1055
992
  };
@@ -1089,7 +1026,7 @@ const listen$1 = async (module, options) => {
1089
1026
  return ipc;
1090
1027
  };
1091
1028
 
1092
- const create$a = async ({
1029
+ const create$7 = async ({
1093
1030
  commandMap,
1094
1031
  isMessagePortOpen = true,
1095
1032
  messagePort
@@ -1107,7 +1044,7 @@ const create$a = async ({
1107
1044
  return rpc;
1108
1045
  };
1109
1046
 
1110
- const create$9 = async ({
1047
+ const create$6 = async ({
1111
1048
  commandMap,
1112
1049
  isMessagePortOpen,
1113
1050
  send
@@ -1117,7 +1054,7 @@ const create$9 = async ({
1117
1054
  port2
1118
1055
  } = new MessageChannel();
1119
1056
  await send(port1);
1120
- return create$a({
1057
+ return create$7({
1121
1058
  commandMap,
1122
1059
  isMessagePortOpen,
1123
1060
  messagePort: port2
@@ -1152,13 +1089,13 @@ const createSharedLazyRpc = factory => {
1152
1089
  };
1153
1090
  };
1154
1091
 
1155
- const create$8 = async ({
1092
+ const create$5 = async ({
1156
1093
  commandMap,
1157
1094
  isMessagePortOpen,
1158
1095
  send
1159
1096
  }) => {
1160
1097
  return createSharedLazyRpc(() => {
1161
- return create$9({
1098
+ return create$6({
1162
1099
  commandMap,
1163
1100
  isMessagePortOpen,
1164
1101
  send
@@ -1166,73 +1103,6 @@ const create$8 = async ({
1166
1103
  });
1167
1104
  };
1168
1105
 
1169
- const Https = 'https:';
1170
- const Ws = 'ws:';
1171
- const Wss = 'wss:';
1172
-
1173
- const getWebSocketProtocol = locationProtocol => {
1174
- return locationProtocol === Https ? Wss : Ws;
1175
- };
1176
-
1177
- const getWebSocketUrl = (type, host, locationProtocol) => {
1178
- const wsProtocol = getWebSocketProtocol(locationProtocol);
1179
- return `${wsProtocol}//${host}/websocket/${type}`;
1180
- };
1181
-
1182
- const getHost = () => {
1183
- return location.host;
1184
- };
1185
- const getProtocol$1 = () => {
1186
- return location.protocol;
1187
- };
1188
-
1189
- const create$7 = async ({
1190
- commandMap,
1191
- webSocket
1192
- }) => {
1193
- // TODO create a commandMap per rpc instance
1194
- register(commandMap);
1195
- let rawIpc;
1196
- try {
1197
- rawIpc = await IpcParentWithWebSocket$1.create({
1198
- webSocket
1199
- });
1200
- } catch (error) {
1201
- throw new VError(error, 'Failed to create rpc connection');
1202
- }
1203
- const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
1204
- handleIpc(ipc);
1205
- const rpc = createRpc(ipc);
1206
- return rpc;
1207
- };
1208
-
1209
- const create$6 = async ({
1210
- commandMap,
1211
- type
1212
- }) => {
1213
- const host = getHost();
1214
- const protocol = getProtocol$1();
1215
- const wsUrl = getWebSocketUrl(type, host, protocol);
1216
- const webSocket = new WebSocket(wsUrl);
1217
- const rpc = await create$7({
1218
- commandMap,
1219
- webSocket
1220
- });
1221
- return rpc;
1222
- };
1223
-
1224
- const create$5 = async ({
1225
- commandMap,
1226
- type
1227
- }) => {
1228
- return createSharedLazyRpc(() => {
1229
- return create$6({
1230
- commandMap,
1231
- type
1232
- });
1233
- });
1234
- };
1235
-
1236
1106
  const create$4 = async ({
1237
1107
  commandMap
1238
1108
  }) => {
@@ -1268,7 +1138,7 @@ const rpcs = Object.create(null);
1268
1138
  const set$4 = (id, rpc) => {
1269
1139
  rpcs[id] = rpc;
1270
1140
  };
1271
- const get$2 = id => {
1141
+ const get$1 = id => {
1272
1142
  return rpcs[id];
1273
1143
  };
1274
1144
  const remove$2 = id => {
@@ -1279,18 +1149,18 @@ const remove$2 = id => {
1279
1149
  const create$3 = rpcId => {
1280
1150
  return {
1281
1151
  async dispose() {
1282
- const rpc = get$2(rpcId);
1152
+ const rpc = get$1(rpcId);
1283
1153
  await rpc.dispose();
1284
1154
  },
1285
1155
  // @ts-ignore
1286
1156
  invoke(method, ...params) {
1287
- const rpc = get$2(rpcId);
1157
+ const rpc = get$1(rpcId);
1288
1158
  // @ts-ignore
1289
1159
  return rpc.invoke(method, ...params);
1290
1160
  },
1291
1161
  // @ts-ignore
1292
1162
  invokeAndTransfer(method, ...params) {
1293
- const rpc = get$2(rpcId);
1163
+ const rpc = get$1(rpcId);
1294
1164
  // @ts-ignore
1295
1165
  return rpc.invokeAndTransfer(method, ...params);
1296
1166
  },
@@ -1335,6 +1205,7 @@ const HighlightDeleted = 'HighlightDeleted';
1335
1205
  const HighlightInserted = 'HighlightInserted';
1336
1206
  const IconButton = 'IconButton';
1337
1207
  const IconButtonDisabled = 'IconButtonDisabled';
1208
+ const InputBox = 'InputBox';
1338
1209
  const Label$1 = 'Label';
1339
1210
  const List$1 = 'List';
1340
1211
  const MaskIcon = 'MaskIcon';
@@ -1572,12 +1443,9 @@ const None$1 = 0;
1572
1443
 
1573
1444
  const LeftClick = 0;
1574
1445
 
1575
- const Electron = 2;
1576
- const Remote = 3;
1577
-
1578
1446
  const IconThemeWorker = 7009;
1579
1447
  const RendererWorker = 1;
1580
- const SearchProcess = 77;
1448
+ const TextSearchWorker = 7010;
1581
1449
 
1582
1450
  const File$1 = 1;
1583
1451
  const Match$1 = 2;
@@ -1626,6 +1494,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1626
1494
  number(y);
1627
1495
  await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1628
1496
  };
1497
+ const sendMessagePortToTextSearchWorker = async (port, rpcId) => {
1498
+ const command = 'HandleMessagePort.handleMessagePort';
1499
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextSearchWorker', port, command, rpcId);
1500
+ };
1629
1501
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1630
1502
  const command = 'IconTheme.handleMessagePort';
1631
1503
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
@@ -1633,9 +1505,6 @@ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1633
1505
  const handleWorkspaceRefresh = async () => {
1634
1506
  return invoke$1('Layout.handleWorkspaceRefresh');
1635
1507
  };
1636
- const sendMessagePortToSearchProcess = async port => {
1637
- await invokeAndTransfer('SendMessagePortToElectron.sendMessagePortToElectron', port, 'HandleMessagePortForSearchProcess.handleMessagePortForSearchProcess');
1638
- };
1639
1508
  const writeClipBoardText = async text => {
1640
1509
  await invoke$1('ClipBoard.writeText', /* text */text);
1641
1510
  };
@@ -1649,7 +1518,16 @@ const openUri$1 = async (uri, focus, options) => {
1649
1518
  const {
1650
1519
  invoke,
1651
1520
  set: set$1
1652
- } = create$3(SearchProcess);
1521
+ } = create$3(TextSearchWorker);
1522
+ const getIncrementalResults = async (searchId, minLineY, maxLineY) => {
1523
+ return invoke('TextSearch.getIncrementalResults', searchId, minLineY, maxLineY);
1524
+ };
1525
+ const search$1 = async (...args) => {
1526
+ return invoke('TextSearch.search', ...args);
1527
+ };
1528
+ const searchIncremental = async (...args) => {
1529
+ return invoke('TextSearch.searchIncremental', ...args);
1530
+ };
1653
1531
 
1654
1532
  const toCommandId = key => {
1655
1533
  const dotIndex = key.indexOf('.');
@@ -2545,7 +2423,7 @@ defaultExcludes.join(',');
2545
2423
  const minimumSliderSize = 20;
2546
2424
 
2547
2425
  const {
2548
- get: get$1,
2426
+ get,
2549
2427
  getCommandIds,
2550
2428
  registerCommands,
2551
2429
  set,
@@ -2580,7 +2458,7 @@ const create$1 = ({
2580
2458
  };
2581
2459
  };
2582
2460
 
2583
- const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '', platform) => {
2461
+ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '', platform, isSearchEditor = false) => {
2584
2462
  const headerHeight = getTopHeight(0);
2585
2463
  const state = {
2586
2464
  disposed: false,
@@ -2601,6 +2479,8 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
2601
2479
  }),
2602
2480
  assetDir,
2603
2481
  collapsedPaths: [],
2482
+ contextLines: 1,
2483
+ contextLinesEnabled: false,
2604
2484
  defaultExcludes: defaultExcludes,
2605
2485
  deltaY: 0,
2606
2486
  excludeValue: '',
@@ -2618,6 +2498,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
2618
2498
  includeValue: '',
2619
2499
  incrementalSearch: false,
2620
2500
  inputSource: User,
2501
+ isSearchEditor,
2621
2502
  limit: 20_000,
2622
2503
  limitHit: false,
2623
2504
  limitHitWarning: '',
@@ -2693,7 +2574,7 @@ const isEqual$3 = (oldState, newState) => {
2693
2574
  };
2694
2575
 
2695
2576
  const isEqual$2 = (oldState, newState) => {
2696
- return oldState.collapsedPaths === newState.collapsedPaths && oldState.deltaY === newState.deltaY && oldState.flags === newState.flags && oldState.focus === newState.focus && oldState.icons === newState.icons && oldState.items === newState.items && oldState.listFocused === newState.listFocused && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.loaded === newState.loaded && oldState.maxLineY === newState.maxLineY && oldState.message === newState.message && oldState.minLineY === newState.minLineY && oldState.renderFolderPaths === newState.renderFolderPaths && oldState.replacement === newState.replacement && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
2577
+ return oldState.collapsedPaths === newState.collapsedPaths && oldState.contextLinesEnabled === newState.contextLinesEnabled && oldState.deltaY === newState.deltaY && oldState.flags === newState.flags && oldState.focus === newState.focus && oldState.icons === newState.icons && oldState.items === newState.items && oldState.isSearchEditor === newState.isSearchEditor && oldState.listFocused === newState.listFocused && oldState.listFocusedIndex === newState.listFocusedIndex && oldState.loaded === newState.loaded && oldState.maxLineY === newState.maxLineY && oldState.message === newState.message && oldState.minLineY === newState.minLineY && oldState.renderFolderPaths === newState.renderFolderPaths && oldState.replacement === newState.replacement && oldState.searchInputErrorMessage === newState.searchInputErrorMessage;
2697
2578
  };
2698
2579
 
2699
2580
  const isEqual$1 = (oldState, newState) => {
@@ -2722,7 +2603,7 @@ const diff2 = uid => {
2722
2603
  const {
2723
2604
  newState,
2724
2605
  oldState
2725
- } = get$1(uid);
2606
+ } = get(uid);
2726
2607
  const diffResult = diff(oldState, newState);
2727
2608
  return diffResult;
2728
2609
  };
@@ -2881,6 +2762,8 @@ const MatchWholeWord$1 = 'Match Whole Word';
2881
2762
  const NoResults = 'No results found';
2882
2763
  const Oneresult = '1 result in 1 file';
2883
2764
  const OpenNewSearchEditor = 'Open New Search Editor';
2765
+ const ContextLines$1 = 'Context Lines';
2766
+ const ToggleContextLines$1 = 'Toggle Context Lines';
2884
2767
  const PreserveCase$1 = 'Preserve Case';
2885
2768
  const Refresh$2 = 'Refresh';
2886
2769
  const Replace = 'Replace';
@@ -3042,6 +2925,12 @@ const clearSearchResults = () => {
3042
2925
  const openNewSearchEditor = () => {
3043
2926
  return i18nString(OpenNewSearchEditor);
3044
2927
  };
2928
+ const contextLines = () => {
2929
+ return i18nString(ContextLines$1);
2930
+ };
2931
+ const toggleContextLines$1 = () => {
2932
+ return i18nString(ToggleContextLines$1);
2933
+ };
3045
2934
  const viewAsTree$1 = () => {
3046
2935
  return i18nString(ViewAsTree$1);
3047
2936
  };
@@ -3555,6 +3444,7 @@ const getMenuEntryIds = () => {
3555
3444
 
3556
3445
  const ClearAll$1 = 'ClearAll';
3557
3446
  const CollapseAll$1 = 'CollapseAll';
3447
+ const ContextLines = 'ContextLines';
3558
3448
  const FilesToExclude = 'FilesToExclude';
3559
3449
  const FilesToInclude = 'FilesToInclude';
3560
3450
  const MatchCase = 'MatchCase';
@@ -3566,6 +3456,7 @@ const ReplaceValue = 'ReplaceValue';
3566
3456
  const SearchOnlyOpenEditors = 'SearchOnlyOpenEditors';
3567
3457
  const SearchValue = 'SearchValue';
3568
3458
  const ToggleReplace = 'ToggleReplace';
3459
+ const ToggleContextLines = 'ToggleContextLines';
3569
3460
  const ToggleSearchDetails = 'ToggleSearchDetails';
3570
3461
  const UseExcludeSettings = 'UseExcludeSettings';
3571
3462
  const UseRegularExpression = 'UseRegularExpression';
@@ -3701,25 +3592,8 @@ const getTextSearchResultCounts = results => {
3701
3592
  };
3702
3593
  };
3703
3594
 
3704
- const providers = Object.create(null);
3705
- const add = providerMap => {
3706
- Object.assign(providers, providerMap);
3707
- };
3708
- const get = protocol => {
3709
- return providers[protocol] || providers['default'];
3710
- };
3711
-
3712
- const getTextSearchProvider = scheme => {
3713
- return get(scheme);
3714
- };
3715
-
3716
- const textSearch$6 = async (root, query, options, assetDir, platform, searchId, uid) => {
3717
- string(root);
3718
- string(query);
3719
- const scheme = getProtocol(root);
3720
- const provider = getTextSearchProvider(scheme);
3721
- const results = await provider(scheme, root, query, options, assetDir, platform, searchId, uid);
3722
- return results;
3595
+ const textSearch = async (root, query, options, assetDir, platform, searchId, uid) => {
3596
+ return search$1(root, query, options, assetDir, platform, searchId, uid);
3723
3597
  };
3724
3598
 
3725
3599
  const handleUpdateFull = async (state, update) => {
@@ -3755,7 +3629,7 @@ const handleUpdateFull = async (state, update) => {
3755
3629
  const {
3756
3630
  limitHit,
3757
3631
  results
3758
- } = await textSearch$6(root, value, {
3632
+ } = await textSearch(root, value, {
3759
3633
  assetDir,
3760
3634
  defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
3761
3635
  exclude: excludeValue,
@@ -3820,44 +3694,6 @@ const handleUpdateFull = async (state, update) => {
3820
3694
  };
3821
3695
  };
3822
3696
 
3823
- const getRipGrepArgs = ({
3824
- defaultExcludes,
3825
- exclude,
3826
- isCaseSensitive,
3827
- searchString,
3828
- threads,
3829
- useRegularExpression
3830
- }) => {
3831
- const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json', '--threads', `${threads}`];
3832
- const excludePatternsFromValue = exclude ? exclude.split(',').map(part => part.trim()).filter(Boolean) : [];
3833
- const excludePatternsFromDefaults = defaultExcludes?.filter(Boolean) || [];
3834
- const uniqueExcludePatterns = [...new Set([...excludePatternsFromDefaults, ...excludePatternsFromValue])];
3835
- for (const excludePattern of uniqueExcludePatterns) {
3836
- if (excludePattern.includes('*')) {
3837
- ripGrepArgs.push('--glob', `!${excludePattern}`);
3838
- if (!excludePattern.endsWith('/**')) {
3839
- ripGrepArgs.push('--glob', `!${excludePattern}/**`);
3840
- }
3841
- } else {
3842
- ripGrepArgs.push('--glob', `!**/${excludePattern}/**`);
3843
- }
3844
- }
3845
- if (isCaseSensitive) {
3846
- ripGrepArgs.push('--case-sensitive');
3847
- } else {
3848
- ripGrepArgs.push('--ignore-case');
3849
- }
3850
- if (useRegularExpression) {
3851
- ripGrepArgs.push('--regexp', searchString);
3852
- } else {
3853
- ripGrepArgs.push('--fixed-strings');
3854
- ripGrepArgs.push('--');
3855
- ripGrepArgs.push(searchString);
3856
- }
3857
- ripGrepArgs.push('.');
3858
- return ripGrepArgs;
3859
- };
3860
-
3861
3697
  const waitForNextFrame = async () => {
3862
3698
  const {
3863
3699
  promise,
@@ -3868,20 +3704,9 @@ const waitForNextFrame = async () => {
3868
3704
  };
3869
3705
 
3870
3706
  const textSearchIncremental = async (root, query, options, assetDir, platform, searchId, uid) => {
3871
- string(root);
3872
- string(query);
3873
- const ripGrepArgs = getRipGrepArgs({
3874
- ...options,
3875
- searchString: query
3876
- });
3877
- const actualOptions = {
3878
- id: searchId,
3879
- ripGrepArgs,
3880
- searchDir: root
3881
- };
3882
- const resultPromise = invoke('TextSearch.searchIncremental', actualOptions);
3707
+ const resultPromise = searchIncremental(root, query, options, assetDir, platform, searchId, uid);
3883
3708
  for (let i = 0; i < 100; i++) {
3884
- const latest = get$1(uid);
3709
+ const latest = get(uid);
3885
3710
  const {
3886
3711
  newState
3887
3712
  } = latest;
@@ -3893,8 +3718,8 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
3893
3718
  } = newState;
3894
3719
  const listHeight = height - headerHeight;
3895
3720
  const numberOfVisible = getNumberOfVisibleItems$1(listHeight, itemHeight);
3896
- const visible = await invoke('TextSearch.getIncrementalResults', searchId, minLineY, minLineY + numberOfVisible);
3897
- const latest2 = get$1(uid);
3721
+ const visible = await getIncrementalResults(searchId, minLineY, minLineY + numberOfVisible);
3722
+ const latest2 = get(uid);
3898
3723
  if (!latest2 || latest2.newState.searchId !== searchId) {
3899
3724
  return;
3900
3725
  }
@@ -3936,7 +3761,7 @@ const handleUpdateIncremental = async (state, update) => {
3936
3761
  const root = workspacePath;
3937
3762
  const scheme = getProtocol(root);
3938
3763
  const searchId = crypto.randomUUID(); // TODO try to avoid side effect
3939
- const latest1 = get$1(uid);
3764
+ const latest1 = get(uid);
3940
3765
  const updatedState1 = {
3941
3766
  ...latest1.newState,
3942
3767
  ...partialNewState,
@@ -4002,7 +3827,7 @@ const handleUpdatePullBased = async (state, update) => {
4002
3827
  const shouldUsePullBasedSearch = usePullBasedSearch && isFileSearch;
4003
3828
  const {
4004
3829
  limitHit
4005
- } = await textSearch$6(root, value, {
3830
+ } = await textSearch(root, value, {
4006
3831
  assetDir,
4007
3832
  defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
4008
3833
  exclude: excludeValue,
@@ -4018,7 +3843,7 @@ const handleUpdatePullBased = async (state, update) => {
4018
3843
  usePullBasedSearch: shouldUsePullBasedSearch,
4019
3844
  useRegularExpression: Boolean(flags & UseRegularExpression$2)
4020
3845
  }, assetDir, platform, searchId, uid);
4021
- const latest = get$1(uid);
3846
+ const latest = get(uid);
4022
3847
  if (!latest) {
4023
3848
  return state;
4024
3849
  }
@@ -4209,6 +4034,44 @@ const getReplacingMessage = (fileCount, replaceCount) => {
4209
4034
  return replacingManyOccurrencesInManyFiles(replaceCount, fileCount);
4210
4035
  };
4211
4036
 
4037
+ const prompt = (text, options) => {
4038
+ return invoke$1('ConfirmPrompt.prompt', text, options);
4039
+ };
4040
+
4041
+ const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
4042
+ if (matchCount === 1) {
4043
+ if (replacement) {
4044
+ return confirmReplaceOneOccurrenceInOneFile(replacement);
4045
+ }
4046
+ return confirmReplaceOneOccurrenceInOneFileNoValue();
4047
+ }
4048
+ if (fileCount === 1) {
4049
+ if (replacement) {
4050
+ return confirmReplaceManyOccurrencesInOneFile(matchCount, replacement);
4051
+ }
4052
+ return confirmReplaceManyOccurrencesInOneFileNoValue(matchCount);
4053
+ }
4054
+ if (replacement) {
4055
+ return confirmReplaceManyOccurrencesInManyFiles(matchCount, fileCount, replacement);
4056
+ }
4057
+ return confirmReplaceManyOccurrencesInManyFilesNoValue(matchCount, fileCount);
4058
+ };
4059
+
4060
+ const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount, fileCount) => {
4061
+ string(workspacePath);
4062
+ array(items);
4063
+ string(replacement);
4064
+ number(matchCount);
4065
+ number(fileCount);
4066
+ const confirmTitle = replaceAll$1();
4067
+ const confirmAccept = replace();
4068
+ const confirmText = getReplaceAllConfirmText(matchCount, fileCount, replacement);
4069
+ return prompt(confirmText, {
4070
+ confirmMessage: confirmAccept,
4071
+ title: confirmTitle
4072
+ });
4073
+ };
4074
+
4212
4075
  const getActualIndex = state => {
4213
4076
  const {
4214
4077
  focusedIndex,
@@ -4304,9 +4167,22 @@ const replaceAllInFocusedFile = async (state, fileIndex) => {
4304
4167
  scrollBarHeight
4305
4168
  };
4306
4169
  };
4307
- const replaceAll = async state => {
4308
- const actualIndex = getActualIndex(state);
4309
- const fileIndex = getFileIndex$1(state, actualIndex);
4170
+ const confirmReplaceAll = async (state, fileIndex) => {
4171
+ const {
4172
+ items,
4173
+ matchCount: totalMatchCount,
4174
+ replacement,
4175
+ workspacePath
4176
+ } = state;
4177
+ const targetItems = fileIndex === -1 ? items : getFileItems(state, fileIndex);
4178
+ const fileCount = fileIndex === -1 ? targetItems.filter(item => item.type === File).length : 1;
4179
+ const matchCount = fileIndex === -1 ? totalMatchCount : Math.max(targetItems.length - 1, 0);
4180
+ if (matchCount === 0) {
4181
+ return true;
4182
+ }
4183
+ return replaceAllAndPrompt(workspacePath, targetItems, replacement, matchCount, fileCount);
4184
+ };
4185
+ const replaceAllConfirmed = async (state, fileIndex) => {
4310
4186
  if (fileIndex !== -1) {
4311
4187
  return replaceAllInFocusedFile(state, fileIndex);
4312
4188
  }
@@ -4331,6 +4207,15 @@ const replaceAll = async state => {
4331
4207
  minLineY: 0
4332
4208
  };
4333
4209
  };
4210
+ const replaceAll = async state => {
4211
+ const actualIndex = getActualIndex(state);
4212
+ const fileIndex = getFileIndex$1(state, actualIndex);
4213
+ const shouldReplace = await confirmReplaceAll(state, fileIndex);
4214
+ if (!shouldReplace) {
4215
+ return state;
4216
+ }
4217
+ return replaceAllConfirmed(state, fileIndex);
4218
+ };
4334
4219
  const replaceAllWithProgress = async context => {
4335
4220
  const state = context.getState();
4336
4221
  const {
@@ -4341,16 +4226,30 @@ const replaceAllWithProgress = async context => {
4341
4226
  const fileIndex = getFileIndex$1(state, actualIndex);
4342
4227
  const fileCount = fileIndex === -1 ? totalFileCount : 1;
4343
4228
  const matchCount = fileIndex === -1 ? totalMatchCount : Math.max(getFileItems(state, fileIndex).length - 1, 0);
4229
+ const shouldReplace = await confirmReplaceAll(state, fileIndex);
4230
+ if (!shouldReplace) {
4231
+ return;
4232
+ }
4344
4233
  const message = getReplacingMessage(fileCount, matchCount);
4345
4234
  await context.updateState(latestState => ({
4346
4235
  ...latestState,
4347
4236
  message
4348
4237
  }));
4349
4238
  await invoke$1('Search.rerender');
4350
- const updatedState = await replaceAll(context.getState());
4239
+ const updatedState = await replaceAllConfirmed(context.getState(), fileIndex);
4351
4240
  await context.updateState(() => updatedState);
4352
4241
  };
4353
4242
 
4243
+ const toggleContextLines = async state => {
4244
+ const {
4245
+ contextLinesEnabled
4246
+ } = state;
4247
+ return {
4248
+ ...state,
4249
+ contextLinesEnabled: !contextLinesEnabled
4250
+ };
4251
+ };
4252
+
4354
4253
  const toggleDetailsExpanded = state => {
4355
4254
  const {
4356
4255
  flags
@@ -4447,6 +4346,8 @@ const getClickHandler = name => {
4447
4346
  return toggleOpenEditors;
4448
4347
  case SearchValue:
4449
4348
  return focusSearchValue$1;
4349
+ case ToggleContextLines:
4350
+ return toggleContextLines;
4450
4351
  case ToggleReplace:
4451
4352
  return toggleReplace;
4452
4353
  case ToggleSearchDetails:
@@ -4512,6 +4413,17 @@ const handleIncludeInput = (state, includeValue, inputSource = Script) => {
4512
4413
  });
4513
4414
  };
4514
4415
 
4416
+ const handleContextLinesInput = async (state, value) => {
4417
+ const contextLines = Math.trunc(Number(value));
4418
+ if (!Number.isFinite(contextLines)) {
4419
+ return state;
4420
+ }
4421
+ return {
4422
+ ...state,
4423
+ contextLines: Math.max(0, contextLines)
4424
+ };
4425
+ };
4426
+
4515
4427
  const handleInput = (state, value, inputSource = Script) => {
4516
4428
  return handleUpdate(state, {
4517
4429
  inputSource,
@@ -4528,6 +4440,8 @@ const handleReplaceInput = (state, value, inputSource = Script) => {
4528
4440
 
4529
4441
  const getInputHandler = name => {
4530
4442
  switch (name) {
4443
+ case ContextLines:
4444
+ return handleContextLinesInput;
4531
4445
  case FilesToExclude:
4532
4446
  return handleExcludeInput;
4533
4447
  case FilesToInclude:
@@ -4818,7 +4732,7 @@ const handleListFocus = async state => {
4818
4732
  };
4819
4733
  };
4820
4734
 
4821
- const handlePullResultsFound = async (state, resultSearchId) => {
4735
+ const handlePullResultsFound = async (state, resultSearchId, newResults) => {
4822
4736
  const {
4823
4737
  fileIconCache,
4824
4738
  headerHeight,
@@ -4826,15 +4740,12 @@ const handlePullResultsFound = async (state, resultSearchId) => {
4826
4740
  itemHeight,
4827
4741
  listItems,
4828
4742
  minimumSliderSize,
4829
- platform,
4830
4743
  searchId,
4831
4744
  uid
4832
4745
  } = state;
4833
4746
  if (searchId !== resultSearchId) {
4834
4747
  return state;
4835
4748
  }
4836
- const result = platform === Remote || platform === Electron ? await invoke('TextSearch.getPullResults', searchId) : await invoke$1('SearchProcess.invoke', 'TextSearch.getPullResults', searchId);
4837
- const newResults = result;
4838
4749
  const allResults = [...listItems, ...newResults];
4839
4750
  const {
4840
4751
  fileCount,
@@ -4853,7 +4764,7 @@ const handlePullResultsFound = async (state, resultSearchId) => {
4853
4764
  icons,
4854
4765
  newFileIconCache
4855
4766
  } = await getFileIcons(visible, fileIconCache);
4856
- const latest = get$1(uid);
4767
+ const latest = get(uid);
4857
4768
  const updatedState = {
4858
4769
  ...latest.newState,
4859
4770
  fileCount,
@@ -4940,14 +4851,14 @@ const handleWorkspaceChange = state => {
4940
4851
  };
4941
4852
  };
4942
4853
 
4943
- const send = async port => {
4854
+ const send$1 = async port => {
4944
4855
  await sendMessagePortToIconThemeWorker(port, 0);
4945
4856
  };
4946
4857
  const launchIconThemeWorker = async () => {
4947
4858
  // TODO connect to icon theme worker
4948
- const rpc = await create$8({
4859
+ const rpc = await create$5({
4949
4860
  commandMap: {},
4950
- send
4861
+ send: send$1
4951
4862
  });
4952
4863
  return rpc;
4953
4864
  };
@@ -4957,35 +4868,27 @@ const initializeIconThemeWorker = async () => {
4957
4868
  set$3(rpc);
4958
4869
  };
4959
4870
 
4960
- const launchSearchProcessElectron = async () => {
4961
- const rpc = await create$8({
4962
- commandMap: {},
4963
- send: sendMessagePortToSearchProcess
4964
- });
4965
- return rpc;
4871
+ const commandMap$1 = {
4872
+ 'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound)
4966
4873
  };
4967
4874
 
4968
- const launchSearchProcessNode = async () => {
4969
- const rpc = await create$5({
4970
- commandMap: {},
4971
- // @ts-ignore
4972
- type: 'search-process'
4875
+ const send = async port => {
4876
+ await sendMessagePortToTextSearchWorker(port, 0);
4877
+ };
4878
+ const launchTextSearchWorker = async () => {
4879
+ return create$5({
4880
+ commandMap: commandMap$1,
4881
+ send
4973
4882
  });
4974
- return rpc;
4975
4883
  };
4976
4884
 
4977
- const initializeSearchProcess = async platform => {
4978
- if (platform === Electron) {
4979
- const rpc = await launchSearchProcessElectron();
4980
- set$1(rpc);
4981
- } else if (platform === Remote) {
4982
- const rpc = await launchSearchProcessNode();
4983
- set$1(rpc);
4984
- }
4885
+ const initializeTextSearchWorker = async () => {
4886
+ const rpc = await launchTextSearchWorker();
4887
+ set$1(rpc);
4985
4888
  };
4986
4889
 
4987
- const initialize = async platform => {
4988
- await Promise.all([initializeSearchProcess(platform), initializeIconThemeWorker()]);
4890
+ const initialize = async () => {
4891
+ await Promise.all([initializeTextSearchWorker(), initializeIconThemeWorker()]);
4989
4892
  };
4990
4893
 
4991
4894
  // TODO optimize this function to return the minimum number
@@ -6205,6 +6108,26 @@ const getReplacePlaceholder = focus => {
6205
6108
  return replace();
6206
6109
  };
6207
6110
 
6111
+ const getSearchEditorContextLinesVirtualDom = (contextLines$1, contextLinesEnabled) => {
6112
+ const button = {
6113
+ flag: contextLinesEnabled ? CheckBoxEnabled : CheckBoxDisabled,
6114
+ icon: 'MaskIconListSelection',
6115
+ name: ToggleContextLines,
6116
+ title: toggleContextLines$1()
6117
+ };
6118
+ return [{
6119
+ ariaLabel: contextLines(),
6120
+ childCount: 0,
6121
+ className: `${InputBox} SearchEditorContextLinesInput`,
6122
+ inputType: 'number',
6123
+ min: 0,
6124
+ name: ContextLines,
6125
+ onInput: HandleInput2,
6126
+ type: Input,
6127
+ value: `${contextLines$1}`
6128
+ }, ...getSearchFieldButtonVirtualDom(button)];
6129
+ };
6130
+
6208
6131
  const getSearchPlaceholder = focus => {
6209
6132
  if (focus === FocusSearchInput) {
6210
6133
  return searchForHistory();
@@ -6230,7 +6153,7 @@ const getSearchToggleVirtualDom = replaceExpanded => {
6230
6153
  }];
6231
6154
  };
6232
6155
 
6233
- const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus) => {
6156
+ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount, focus, isSearchEditor = false, contextLines = 1, contextLinesEnabled = false) => {
6234
6157
  const inputActions = getInputActionsInput(flags);
6235
6158
  const replaceActions = getInputActionsReplace(flags, matchCount);
6236
6159
  const searchPlaceholder = getSearchPlaceholder(focus);
@@ -6246,14 +6169,25 @@ const getSearchHeaderTopVirtualDom = (flags, searchInputErrorMessage, matchCount
6246
6169
  className: SearchHeaderTopRight,
6247
6170
  role: None$2,
6248
6171
  type: Div
6249
- }, ...getSearchFieldVirtualDom(SearchValue, searchPlaceholder, HandleInput2, inputActions.inside, inputActions.outside, Boolean(searchInputErrorMessage))];
6172
+ }];
6173
+ const searchFieldDom = getSearchFieldVirtualDom(SearchValue, searchPlaceholder, HandleInput2, inputActions.inside, inputActions.outside, Boolean(searchInputErrorMessage));
6174
+ if (isSearchEditor) {
6175
+ dom.push({
6176
+ childCount: 3,
6177
+ className: SearchFieldContainer,
6178
+ role: None$2,
6179
+ type: Div
6180
+ }, ...searchFieldDom, ...getSearchEditorContextLinesVirtualDom(contextLines, contextLinesEnabled));
6181
+ } else {
6182
+ dom.push(...searchFieldDom);
6183
+ }
6250
6184
  if (flags & ReplaceExpanded) {
6251
6185
  dom.push(...getSearchFieldVirtualDom(ReplaceValue, replacePlaceholder, HandleInput2, replaceActions.inside, replaceActions.outside));
6252
6186
  }
6253
6187
  return dom;
6254
6188
  };
6255
6189
 
6256
- const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount, focus, limitHitWarning) => {
6190
+ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matchCount, focus, limitHitWarning, isSearchEditor = false, contextLines = 1, contextLinesEnabled = false) => {
6257
6191
  const warningDom = getSearchHeaderLimitHitVirtualDom(limitHitWarning);
6258
6192
  const parentNode = {
6259
6193
  childCount: 2 + (warningDom.length > 0 ? 1 : 0),
@@ -6262,7 +6196,7 @@ const getSearchHeaderVirtualDom = (flags, message, searchInputErrorMessage, matc
6262
6196
  role: None$2,
6263
6197
  type: Div
6264
6198
  };
6265
- const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount, focus), ...getSearchHeaderDetailsVirtualDom(flags, message), ...warningDom];
6199
+ const dom = [parentNode, ...getSearchHeaderTopVirtualDom(flags, searchInputErrorMessage, matchCount, focus, isSearchEditor, contextLines, contextLinesEnabled), ...getSearchHeaderDetailsVirtualDom(flags, message), ...warningDom];
6266
6200
  return dom;
6267
6201
  };
6268
6202
 
@@ -6512,7 +6446,7 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
6512
6446
  };
6513
6447
 
6514
6448
  const className = mergeClassNames(Viewlet, Search$3);
6515
- const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0, initial = false) => {
6449
+ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0, initial = false, isSearchEditor = false, contextLines = 1, contextLinesEnabled = false) => {
6516
6450
  if (initial) {
6517
6451
  return [];
6518
6452
  }
@@ -6522,12 +6456,12 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
6522
6456
  childCount,
6523
6457
  className,
6524
6458
  type: Div
6525
- }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus, limitHitWarning), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
6459
+ }, ...getSearchHeaderVirtualDom(flags, message, searchInputErrorMessage, matchCount, focus, limitHitWarning, isSearchEditor, contextLines, contextLinesEnabled), ...errorDom, ...getSearchResultsVirtualDom(visibleItems, focusOutline, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight)];
6526
6460
  };
6527
6461
 
6528
6462
  const getDom = newState => {
6529
6463
  const viewModel = createViewModel(newState);
6530
- const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus, newState.initial);
6464
+ const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus, newState.initial, newState.isSearchEditor, newState.contextLines, newState.contextLinesEnabled);
6531
6465
  return dom;
6532
6466
  };
6533
6467
 
@@ -6597,7 +6531,7 @@ const render2 = (uid, diffResult) => {
6597
6531
  const {
6598
6532
  newState,
6599
6533
  oldState
6600
- } = get$1(uid);
6534
+ } = get(uid);
6601
6535
  set(uid, newState, newState);
6602
6536
  const commands = applyRender(oldState, newState, diffResult);
6603
6537
  return commands;
@@ -6783,45 +6717,6 @@ const renderEventListeners = () => {
6783
6717
  }];
6784
6718
  };
6785
6719
 
6786
- const prompt = (text, options) => {
6787
- return invoke$1('ConfirmPrompt.prompt', text, options);
6788
- };
6789
-
6790
- const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
6791
- if (matchCount === 1) {
6792
- if (replacement) {
6793
- return confirmReplaceOneOccurrenceInOneFile(replacement);
6794
- }
6795
- return confirmReplaceOneOccurrenceInOneFileNoValue();
6796
- }
6797
- if (fileCount === 1) {
6798
- if (replacement) {
6799
- return confirmReplaceManyOccurrencesInOneFile(matchCount, replacement);
6800
- }
6801
- return confirmReplaceManyOccurrencesInOneFileNoValue(matchCount);
6802
- }
6803
- if (replacement) {
6804
- return confirmReplaceManyOccurrencesInManyFiles(matchCount, fileCount, replacement);
6805
- }
6806
- return confirmReplaceManyOccurrencesInManyFilesNoValue(matchCount, fileCount);
6807
- };
6808
-
6809
- const replaceAllAndPrompt = async (workspacePath, items, replacement, matchCount, fileCount) => {
6810
- string(workspacePath);
6811
- array(items);
6812
- string(replacement);
6813
- number(matchCount);
6814
- number(fileCount);
6815
- const confirmTitle = replaceAll$1();
6816
- const confirmAccept = replace();
6817
- const confirmText = getReplaceAllConfirmText(matchCount, fileCount, replacement);
6818
- const shouldReplace = await prompt(confirmText, {
6819
- confirmMessage: confirmAccept,
6820
- title: confirmTitle
6821
- });
6822
- return shouldReplace;
6823
- };
6824
-
6825
6720
  const replaceAllInFile = async state => {
6826
6721
  // TODO replace occurrance for focused file
6827
6722
  return {
@@ -6981,7 +6876,7 @@ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
6981
6876
  const {
6982
6877
  newState,
6983
6878
  oldState
6984
- } = get$1(uid);
6879
+ } = get(uid);
6985
6880
  set(uid, oldState, {
6986
6881
  ...newState,
6987
6882
  focusedIndex: index,
@@ -7108,7 +7003,7 @@ const commandMap = {
7108
7003
  'TextSearch.setLimit': wrapCommand(setLimit),
7109
7004
  'TextSearch.submit': wrapCommand(submit),
7110
7005
  'TextSearch.terminate': terminate,
7111
- 'TextSearch.textSearch': textSearch$6,
7006
+ 'TextSearch.textSearch': textSearch,
7112
7007
  'TextSearch.toggleMatchCase': wrapCommand(toggleMatchCase),
7113
7008
  'TextSearch.toggleMatchWholeWord': wrapCommand(toggleMatchWholeWord),
7114
7009
  'TextSearch.toggleOpenEditors': wrapCommand(toggleOpenEditors),
@@ -7120,124 +7015,8 @@ const commandMap = {
7120
7015
  'TextSearch.viewAsTree': wrapCommand(viewAsTree)
7121
7016
  };
7122
7017
 
7123
- const textSearch$5 = async (scheme, root, query) => {
7124
- string(scheme);
7125
- string(query);
7126
- const results = await invoke$1('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
7127
- return {
7128
- limitHit: false,
7129
- results
7130
- };
7131
- };
7132
-
7133
- const textSearch$4 = async (scheme, root, query, options, assetDir) => {
7134
- const results = await invoke$1('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
7135
- return {
7136
- limitHit: false,
7137
- results
7138
- };
7139
- };
7140
-
7141
- const textSearch$3 = async (scheme, root, query) => {
7142
- const results = await invoke$1('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
7143
- return {
7144
- limitHit: false,
7145
- results
7146
- };
7147
- };
7148
-
7149
- const textSearch$2 = async (scheme, root, query, options, assetDir) => {
7150
- try {
7151
- // @ts-ignore
7152
- const result = await invoke$1('ExtensionHostTextSearch.textSearchMemory2', scheme, root, query, options, assetDir);
7153
- if (!result || !result.results) {
7154
- throw new Error(`new api not supported`);
7155
- }
7156
- return result;
7157
- } catch {
7158
- const results = await invoke$1('ExtensionHostTextSearch.textSearchMemory', scheme, root, query, options, assetDir);
7159
- return {
7160
- limitHit: false,
7161
- results
7162
- };
7163
- }
7164
- };
7165
-
7166
- const textSearch$1 = async (scheme, root, query, options, assetDir, platform, searchId, uid) => {
7167
- const ripGrepArgs = getRipGrepArgs({
7168
- ...options,
7169
- searchString: query
7170
- });
7171
- if (options.usePullBasedSearch && searchId && (scheme === '' || scheme === 'file')) {
7172
- const pullSearchOptions = {
7173
- ripGrepArgs,
7174
- searchDir: root,
7175
- searchId,
7176
- uid
7177
- };
7178
- if (platform === Remote || platform === Electron) {
7179
- await invoke('TextSearch.searchPull', pullSearchOptions);
7180
- } else {
7181
- await invoke$1('SearchProcess.invoke', 'TextSearch.searchPull', pullSearchOptions);
7182
- }
7183
- return {
7184
- limitHit: false,
7185
- results: []
7186
- };
7187
- }
7188
- const actualOptions = {
7189
- ripGrepArgs,
7190
- searchDir: root
7191
- };
7192
- if (platform === Remote || platform === Electron) {
7193
- const result = await invoke('TextSearch.search', actualOptions);
7194
- return {
7195
- limitHit: result.limitHit,
7196
- results: result.results
7197
- };
7198
- }
7199
- // TODO always create search process messageport rpc to have one api, in web can send the messageport to renderer worker
7200
- const result = await invoke$1('SearchProcess.invoke', 'TextSearch.search', actualOptions);
7201
- // TODO api is weird
7202
- return {
7203
- limitHit: result.limitHit,
7204
- results: result.results
7205
- };
7206
- };
7207
-
7208
- const textSearch = async (scheme, root, query) => {
7209
- // TODO ask renderer worker for files
7210
- const entries = Object.entries({});
7211
- const results = [];
7212
- for (const [key, value] of entries) {
7213
- // @ts-ignore
7214
- if (value.includes(query)) {
7215
- results.push([key, [{
7216
- absoluteOffset: 0,
7217
- preview: value
7218
- }]]);
7219
- }
7220
- }
7221
- return {
7222
- limitHit: false,
7223
- results
7224
- };
7225
- };
7226
-
7227
- const textSearchProviderMap = {
7228
- '': textSearch$1,
7229
- // TODO deprecate/remove workspaces without scheme
7230
- default: textSearch$5,
7231
- fetch: textSearch$4,
7232
- file: textSearch$1,
7233
- html: textSearch$3,
7234
- memfs: textSearch$2,
7235
- web: textSearch
7236
- };
7237
-
7238
7018
  const listen = async () => {
7239
7019
  registerCommands(commandMap);
7240
- add(textSearchProviderMap);
7241
7020
  const rpc = await create$4({
7242
7021
  commandMap: commandMap
7243
7022
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-view",
3
- "version": "1.0.1",
3
+ "version": "1.2.0",
4
4
  "description": "Text Search View",
5
5
  "keywords": [
6
6
  "text-search"