@lvce-editor/search-process 15.5.0 → 15.6.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.
- package/dist/index.js +37 -21
- package/package.json +1 -2
package/dist/index.js
CHANGED
|
@@ -1594,15 +1594,13 @@ const processData = async (stdout, handleData) => {
|
|
|
1594
1594
|
};
|
|
1595
1595
|
|
|
1596
1596
|
const Begin = 'begin';
|
|
1597
|
+
const Context$1 = 'context';
|
|
1597
1598
|
const Match$1 = 'match';
|
|
1598
1599
|
const Summary = 'summary';
|
|
1599
1600
|
|
|
1600
1601
|
const File = 1;
|
|
1601
1602
|
const Match = 2;
|
|
1602
|
-
|
|
1603
|
-
const getStringIndexFromByteOffset = (text, byteOffset) => {
|
|
1604
|
-
return Buffer.from(text).subarray(0, byteOffset).toString().length;
|
|
1605
|
-
};
|
|
1603
|
+
const Context = 3;
|
|
1606
1604
|
|
|
1607
1605
|
const parseRipGrepLines = parsedLineData => {
|
|
1608
1606
|
if (parsedLineData.lines.text) {
|
|
@@ -1614,6 +1612,23 @@ const parseRipGrepLines = parsedLineData => {
|
|
|
1614
1612
|
throw new Error(`unable to parse line data`);
|
|
1615
1613
|
};
|
|
1616
1614
|
|
|
1615
|
+
const toTextSearchContext = parsedLine => {
|
|
1616
|
+
const {
|
|
1617
|
+
data
|
|
1618
|
+
} = parsedLine;
|
|
1619
|
+
return {
|
|
1620
|
+
end: 0,
|
|
1621
|
+
lineNumber: data.line_number,
|
|
1622
|
+
start: 0,
|
|
1623
|
+
text: parseRipGrepLines(data),
|
|
1624
|
+
type: Context
|
|
1625
|
+
};
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
const getStringIndexFromByteOffset = (text, byteOffset) => {
|
|
1629
|
+
return Buffer.from(text).subarray(0, byteOffset).toString().length;
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1617
1632
|
const toTextSearchResult = (parsedLine, remaining, charsBefore, charsAfter) => {
|
|
1618
1633
|
const results = [];
|
|
1619
1634
|
const parsedLineData = parsedLine.data;
|
|
@@ -1676,6 +1691,9 @@ const collectStdout = async (stdout, kill, maxSearchResults, charsBefore, charsA
|
|
|
1676
1691
|
type: File
|
|
1677
1692
|
}];
|
|
1678
1693
|
break;
|
|
1694
|
+
case Context$1:
|
|
1695
|
+
allSearchResults[data.path.text].push(toTextSearchContext(parsedLine));
|
|
1696
|
+
break;
|
|
1679
1697
|
case Match$1:
|
|
1680
1698
|
const remaining = maxSearchResults - numberOfResults;
|
|
1681
1699
|
const matches = toTextSearchResult(parsedLine, remaining, charsBefore, charsAfter);
|
|
@@ -1836,6 +1854,9 @@ const collectStdoutIncremental = async (id, stdout, kill, maxSearchResults, char
|
|
|
1836
1854
|
type: File
|
|
1837
1855
|
}];
|
|
1838
1856
|
break;
|
|
1857
|
+
case Context$1:
|
|
1858
|
+
allSearchResults[data.path.text].push(toTextSearchContext(parsedLine));
|
|
1859
|
+
break;
|
|
1839
1860
|
case Match$1:
|
|
1840
1861
|
const remaining = maxSearchResults - numberOfResults;
|
|
1841
1862
|
const matches = toTextSearchResult(parsedLine, remaining, charsBefore, charsAfter);
|
|
@@ -1956,6 +1977,10 @@ const collectStdoutPull = async (searchId, stdout, kill, maxSearchResults, chars
|
|
|
1956
1977
|
});
|
|
1957
1978
|
maybeNotifyResultsFound();
|
|
1958
1979
|
break;
|
|
1980
|
+
case Context$1:
|
|
1981
|
+
allSearchResults.push(toTextSearchContext(parsedLine));
|
|
1982
|
+
maybeNotifyResultsFound();
|
|
1983
|
+
break;
|
|
1959
1984
|
case Match$1:
|
|
1960
1985
|
const remaining = maxSearchResults - numberOfResults;
|
|
1961
1986
|
const matches = toTextSearchResult(parsedLine, remaining, charsBefore, charsAfter);
|
|
@@ -1999,11 +2024,6 @@ const collectStdoutPull = async (searchId, stdout, kill, maxSearchResults, chars
|
|
|
1999
2024
|
};
|
|
2000
2025
|
};
|
|
2001
2026
|
|
|
2002
|
-
const rpcMap = new Map();
|
|
2003
|
-
const removeById = id => {
|
|
2004
|
-
rpcMap.delete(id);
|
|
2005
|
-
};
|
|
2006
|
-
|
|
2007
2027
|
const textSearchPull = async (rpc, {
|
|
2008
2028
|
charsAfter,
|
|
2009
2029
|
charsBefore,
|
|
@@ -2025,20 +2045,16 @@ const textSearchPull = async (rpc, {
|
|
|
2025
2045
|
params: [uid, searchId]
|
|
2026
2046
|
});
|
|
2027
2047
|
};
|
|
2028
|
-
|
|
2029
|
-
|
|
2030
|
-
|
|
2031
|
-
|
|
2032
|
-
if (exitResult.
|
|
2033
|
-
|
|
2034
|
-
throw new RipGrepNotFoundError(exitResult.event);
|
|
2035
|
-
}
|
|
2036
|
-
throw new TextSearchError(exitResult.event);
|
|
2048
|
+
const pipeLinePromise = collectStdoutPull(searchId, childProcess.stdout, childProcess.kill, maxSearchResults, charsBefore, charsAfter, notifyResultsFound);
|
|
2049
|
+
const closePromise = waitForProcessToExit(childProcess);
|
|
2050
|
+
const [pipeLineResult, exitResult] = await Promise.all([pipeLinePromise, closePromise]);
|
|
2051
|
+
if (exitResult.type === Error$1) {
|
|
2052
|
+
if (isEnoentError(exitResult.event)) {
|
|
2053
|
+
throw new RipGrepNotFoundError(exitResult.event);
|
|
2037
2054
|
}
|
|
2038
|
-
|
|
2039
|
-
} finally {
|
|
2040
|
-
removeById(searchId);
|
|
2055
|
+
throw new TextSearchError(exitResult.event);
|
|
2041
2056
|
}
|
|
2057
|
+
return pipeLineResult;
|
|
2042
2058
|
};
|
|
2043
2059
|
|
|
2044
2060
|
const commandMap = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/search-process",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.6.1",
|
|
4
4
|
"description": "Search Process",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lvce Editor",
|
|
@@ -18,7 +18,6 @@
|
|
|
18
18
|
"search-process": "bin/searchProcess.js"
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@lvce-editor/constants": "^5.14.0",
|
|
22
21
|
"execa": "^9.6.1",
|
|
23
22
|
"ws": "^8.21.1"
|
|
24
23
|
},
|