@lvce-editor/search-process 15.12.0 → 15.13.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/index.js +24 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1457,14 +1457,13 @@ const isEnoentErrorLinux = error => {
|
|
|
1457
1457
|
};
|
|
1458
1458
|
|
|
1459
1459
|
const isEnoentErrorWindows = error => {
|
|
1460
|
-
|
|
1460
|
+
const candidate = error;
|
|
1461
|
+
const message = candidate?.message;
|
|
1462
|
+
return message && message.includes('The system cannot find the path specified.');
|
|
1461
1463
|
};
|
|
1462
1464
|
|
|
1463
1465
|
const isEnoentError = error => {
|
|
1464
|
-
|
|
1465
|
-
return false;
|
|
1466
|
-
}
|
|
1467
|
-
return isEnoentErrorLinux(error) || isEnoentErrorWindows(error);
|
|
1466
|
+
return !!error && (isEnoentErrorLinux(error) || isEnoentErrorWindows(error));
|
|
1468
1467
|
};
|
|
1469
1468
|
|
|
1470
1469
|
const getNewLineIndex = (string, startIndex = 0) => {
|
|
@@ -1607,7 +1606,6 @@ const searchFile = async ({
|
|
|
1607
1606
|
info(`[search-process] ripgrep could not be found at "${ripGrepPath}"`);
|
|
1608
1607
|
return EmptyString;
|
|
1609
1608
|
}
|
|
1610
|
-
// @ts-ignore
|
|
1611
1609
|
if (error$1 && error$1.stderr === EmptyString) {
|
|
1612
1610
|
return EmptyString;
|
|
1613
1611
|
}
|
|
@@ -1703,7 +1701,7 @@ const getPreviewStart = (text, matchStart, charsBefore) => {
|
|
|
1703
1701
|
}
|
|
1704
1702
|
return preferredStart;
|
|
1705
1703
|
};
|
|
1706
|
-
const toTextSearchResult = (parsedLine,
|
|
1704
|
+
const toTextSearchResult = (parsedLine, charsBefore, charsAfter) => {
|
|
1707
1705
|
const results = [];
|
|
1708
1706
|
const parsedLineData = parsedLine.data;
|
|
1709
1707
|
const lines = parseRipGrepLines(parsedLineData);
|
|
@@ -1770,8 +1768,7 @@ const collectStdout = async (stdout, kill, maxSearchResults, charsBefore, charsA
|
|
|
1770
1768
|
allSearchResults[data.path.text].push(toTextSearchContext(parsedLine));
|
|
1771
1769
|
break;
|
|
1772
1770
|
case Match$1:
|
|
1773
|
-
const
|
|
1774
|
-
const matches = toTextSearchResult(parsedLine, remaining, charsBefore, charsAfter);
|
|
1771
|
+
const matches = toTextSearchResult(parsedLine, charsBefore, charsAfter);
|
|
1775
1772
|
numberOfResults += matches.length;
|
|
1776
1773
|
allSearchResults[data.path.text].push(...matches);
|
|
1777
1774
|
break;
|
|
@@ -1796,10 +1793,12 @@ const collectStdout = async (stdout, kill, maxSearchResults, charsBefore, charsA
|
|
|
1796
1793
|
newLineIndex = getNewLineIndex(dataString, previousIndex);
|
|
1797
1794
|
}
|
|
1798
1795
|
buffer = dataString.slice(previousIndex);
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1796
|
+
const overLimit = numberOfResults > maxSearchResults;
|
|
1797
|
+
if (!overLimit) {
|
|
1798
|
+
return;
|
|
1802
1799
|
}
|
|
1800
|
+
limitHit = true;
|
|
1801
|
+
kill();
|
|
1803
1802
|
};
|
|
1804
1803
|
await processData(stdout, handleData);
|
|
1805
1804
|
const results = Object.values(allSearchResults).flat();
|
|
@@ -1933,8 +1932,7 @@ const collectStdoutIncremental = async (id, stdout, kill, maxSearchResults, char
|
|
|
1933
1932
|
allSearchResults[data.path.text].push(toTextSearchContext(parsedLine));
|
|
1934
1933
|
break;
|
|
1935
1934
|
case Match$1:
|
|
1936
|
-
const
|
|
1937
|
-
const matches = toTextSearchResult(parsedLine, remaining, charsBefore, charsAfter);
|
|
1935
|
+
const matches = toTextSearchResult(parsedLine, charsBefore, charsAfter);
|
|
1938
1936
|
numberOfResults += matches.length;
|
|
1939
1937
|
allSearchResults[data.path.text].push(...matches);
|
|
1940
1938
|
break;
|
|
@@ -1959,10 +1957,12 @@ const collectStdoutIncremental = async (id, stdout, kill, maxSearchResults, char
|
|
|
1959
1957
|
newLineIndex = getNewLineIndex(dataString, previousIndex);
|
|
1960
1958
|
}
|
|
1961
1959
|
buffer = dataString.slice(previousIndex);
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1960
|
+
const overLimit = numberOfResults > maxSearchResults;
|
|
1961
|
+
if (!overLimit) {
|
|
1962
|
+
return;
|
|
1965
1963
|
}
|
|
1964
|
+
limitHit = true;
|
|
1965
|
+
kill();
|
|
1966
1966
|
};
|
|
1967
1967
|
await processData(stdout, handleData);
|
|
1968
1968
|
return {
|
|
@@ -2057,8 +2057,7 @@ const collectStdoutPull = async (searchId, stdout, kill, maxSearchResults, chars
|
|
|
2057
2057
|
maybeNotifyResultsFound();
|
|
2058
2058
|
break;
|
|
2059
2059
|
case Match$1:
|
|
2060
|
-
const
|
|
2061
|
-
const matches = toTextSearchResult(parsedLine, remaining, charsBefore, charsAfter);
|
|
2060
|
+
const matches = toTextSearchResult(parsedLine, charsBefore, charsAfter);
|
|
2062
2061
|
numberOfResults += matches.length;
|
|
2063
2062
|
if (matches.length > 0) {
|
|
2064
2063
|
allSearchResults.push(...matches);
|
|
@@ -2086,10 +2085,12 @@ const collectStdoutPull = async (searchId, stdout, kill, maxSearchResults, chars
|
|
|
2086
2085
|
newLineIndex = getNewLineIndex(dataString, previousIndex);
|
|
2087
2086
|
}
|
|
2088
2087
|
buffer = dataString.slice(previousIndex);
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2088
|
+
const overLimit = numberOfResults > maxSearchResults;
|
|
2089
|
+
if (!overLimit) {
|
|
2090
|
+
return;
|
|
2092
2091
|
}
|
|
2092
|
+
limitHit = true;
|
|
2093
|
+
kill();
|
|
2093
2094
|
};
|
|
2094
2095
|
await processData(stdout, handleData);
|
|
2095
2096
|
done = true;
|
|
@@ -2113,12 +2114,7 @@ const textSearchPull = async (rpc, {
|
|
|
2113
2114
|
cwd: ensurePath(searchDir)
|
|
2114
2115
|
});
|
|
2115
2116
|
const notifyResultsFound = () => {
|
|
2116
|
-
|
|
2117
|
-
rpc.send({
|
|
2118
|
-
jsonrpc: '2.0',
|
|
2119
|
-
method: 'TextSearch.handlePullResultsFound',
|
|
2120
|
-
params: [uid, searchId]
|
|
2121
|
-
});
|
|
2117
|
+
rpc.send('TextSearch.handlePullResultsFound', uid, searchId);
|
|
2122
2118
|
};
|
|
2123
2119
|
const pipeLinePromise = collectStdoutPull(searchId, childProcess.stdout, childProcess.kill, maxSearchResults, charsBefore, charsAfter, notifyResultsFound);
|
|
2124
2120
|
const closePromise = waitForProcessToExit(childProcess);
|