@lvce-editor/text-search-worker 7.17.0 → 7.18.1

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.
@@ -1470,7 +1470,7 @@ const getTextSearchProvider = scheme => {
1470
1470
  return get(scheme);
1471
1471
  };
1472
1472
 
1473
- const textSearch$6 = async (root, query, options, assetDir, platform, searchId, uid) => {
1473
+ const textSearch$7 = async (root, query, options, assetDir, platform, searchId, uid) => {
1474
1474
  string(root);
1475
1475
  string(query);
1476
1476
  const scheme = getProtocol(root);
@@ -1559,21 +1559,31 @@ const commandMap = {
1559
1559
  'TextSearch.getPullResults': getPullResults,
1560
1560
  'TextSearch.handlePullResultsFound': handlePullResultsFound,
1561
1561
  'TextSearch.initialize': initialize,
1562
- 'TextSearch.search': textSearch$6,
1562
+ 'TextSearch.search': textSearch$7,
1563
1563
  'TextSearch.searchIncremental': textSearchIncremental
1564
1564
  };
1565
1565
 
1566
- const textSearch$5 = async (scheme, root, query) => {
1566
+ const textSearch$6 = async (scheme, root, query, options) => {
1567
1567
  string(scheme);
1568
1568
  string(query);
1569
- const results = await invoke$3('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query);
1569
+ const ripGrepArgs = getRipGrepArgs({
1570
+ isCaseSensitive: false,
1571
+ threads: 1,
1572
+ useRegularExpression: false,
1573
+ ...options,
1574
+ searchString: query
1575
+ });
1576
+ const results = await invoke$3('ExtensionHostTextSearch.executeTextSearchProvider', scheme, query, root, ripGrepArgs);
1577
+ if (!Array.isArray(results)) {
1578
+ return results;
1579
+ }
1570
1580
  return {
1571
1581
  limitHit: false,
1572
1582
  results
1573
1583
  };
1574
1584
  };
1575
1585
 
1576
- const textSearch$4 = async (scheme, root, query, options, assetDir) => {
1586
+ const textSearch$5 = async (scheme, root, query, options, assetDir) => {
1577
1587
  const results = await invoke$3('ExtensionHostTextSearch.textSearchFetch', scheme, root, query, options, assetDir);
1578
1588
  return {
1579
1589
  limitHit: false,
@@ -1581,7 +1591,7 @@ const textSearch$4 = async (scheme, root, query, options, assetDir) => {
1581
1591
  };
1582
1592
  };
1583
1593
 
1584
- const textSearch$3 = async (scheme, root, query) => {
1594
+ const textSearch$4 = async (scheme, root, query) => {
1585
1595
  const results = await invoke$3('ExtensionHostTextSearch.textSearchHtml', scheme, root, query);
1586
1596
  return {
1587
1597
  limitHit: false,
@@ -1589,7 +1599,7 @@ const textSearch$3 = async (scheme, root, query) => {
1589
1599
  };
1590
1600
  };
1591
1601
 
1592
- const textSearch$2 = async (scheme, root, query, options, assetDir) => {
1602
+ const textSearch$3 = async (scheme, root, query, options, assetDir) => {
1593
1603
  try {
1594
1604
  // @ts-ignore
1595
1605
  const result = await invoke$3('ExtensionHostTextSearch.textSearchMemory2', scheme, root, query, options, assetDir);
@@ -1628,7 +1638,7 @@ const getOpenEditorPaths = (root, openEditorUris) => {
1628
1638
  return [...new Set(paths)];
1629
1639
  };
1630
1640
 
1631
- const textSearch$1 = async (scheme, root, query, options, assetDir, _platform, searchId, uid) => {
1641
+ const textSearch$2 = async (scheme, root, query, options, assetDir, _platform, searchId, uid) => {
1632
1642
  const openEditorPaths = options.openEditorUris ? getOpenEditorPaths(root, options.openEditorUris) : undefined;
1633
1643
  if (openEditorPaths && openEditorPaths.length === 0) {
1634
1644
  return {
@@ -1667,6 +1677,26 @@ const textSearch$1 = async (scheme, root, query, options, assetDir, _platform, s
1667
1677
  };
1668
1678
  };
1669
1679
 
1680
+ const textSearch$1 = async (_scheme, root, query, options, assetDir, platform, searchId, uid) => {
1681
+ const workspace = new URL(root);
1682
+ const openEditorUris = options.openEditorUris?.flatMap(uri => {
1683
+ if (!uri.startsWith('remote-ssh://')) {
1684
+ return [];
1685
+ }
1686
+ const editor = new URL(uri);
1687
+ if (editor.host !== workspace.host || editor.username !== workspace.username) {
1688
+ return [];
1689
+ }
1690
+ return [decodeURIComponent(editor.pathname)];
1691
+ });
1692
+ return textSearch$2('file', decodeURIComponent(workspace.pathname), query, {
1693
+ ...options,
1694
+ ...(openEditorUris && {
1695
+ openEditorUris
1696
+ })
1697
+ }, assetDir, platform, searchId, uid);
1698
+ };
1699
+
1670
1700
  const textSearch = async (scheme, root, query) => {
1671
1701
  // TODO ask renderer worker for files
1672
1702
  return {
@@ -1676,13 +1706,14 @@ const textSearch = async (scheme, root, query) => {
1676
1706
  };
1677
1707
 
1678
1708
  const textSearchProviderMap = {
1679
- '': textSearch$1,
1709
+ '': textSearch$2,
1680
1710
  // TODO deprecate/remove workspaces without scheme
1681
- default: textSearch$5,
1682
- fetch: textSearch$4,
1683
- file: textSearch$1,
1684
- html: textSearch$3,
1685
- memfs: textSearch$2,
1711
+ default: textSearch$6,
1712
+ fetch: textSearch$5,
1713
+ file: textSearch$2,
1714
+ html: textSearch$4,
1715
+ memfs: textSearch$3,
1716
+ 'remote-ssh': textSearch$1,
1686
1717
  web: textSearch
1687
1718
  };
1688
1719
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "7.17.0",
3
+ "version": "7.18.1",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"