@lvce-editor/text-search-worker 7.19.0 → 7.20.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/textSearchWorkerMain.js +46 -12
- package/package.json +1 -1
|
@@ -708,6 +708,9 @@ const restoreExistingError = (error, currentStack) => {
|
|
|
708
708
|
};
|
|
709
709
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
710
710
|
const restoredError = new JsonRpcError(error.message);
|
|
711
|
+
Object.assign(restoredError, {
|
|
712
|
+
code: error.code
|
|
713
|
+
});
|
|
711
714
|
const parentStack = getParentStack(error);
|
|
712
715
|
setStack(restoredError, `${parentStack}${NewLine}${currentStack}`);
|
|
713
716
|
return restoredError;
|
|
@@ -727,9 +730,13 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
727
730
|
// @ts-ignore
|
|
728
731
|
restoredError.codeFrame = error.data.codeFrame;
|
|
729
732
|
}
|
|
730
|
-
if (error.data.code) {
|
|
733
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
731
734
|
// @ts-ignore
|
|
732
|
-
restoredError
|
|
735
|
+
Object.defineProperty(restoredError, 'code', {
|
|
736
|
+
configurable: true,
|
|
737
|
+
value: error.data.code,
|
|
738
|
+
writable: true
|
|
739
|
+
});
|
|
733
740
|
}
|
|
734
741
|
if (error.data.type) {
|
|
735
742
|
// @ts-ignore
|
|
@@ -750,7 +757,14 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
750
757
|
}
|
|
751
758
|
};
|
|
752
759
|
const restoreMessageError = (error, _currentStack) => {
|
|
753
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
760
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
761
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
762
|
+
Object.defineProperty(restoredError, 'code', {
|
|
763
|
+
configurable: true,
|
|
764
|
+
value: error.code,
|
|
765
|
+
writable: true
|
|
766
|
+
});
|
|
767
|
+
}
|
|
754
768
|
if (error.data) {
|
|
755
769
|
applyDataProperties(restoredError, error);
|
|
756
770
|
} else {
|
|
@@ -829,9 +843,9 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
829
843
|
return {
|
|
830
844
|
code: Custom,
|
|
831
845
|
data: {
|
|
832
|
-
code: prettyError.code,
|
|
846
|
+
code: prettyError.code ?? error?.code,
|
|
833
847
|
codeFrame: prettyError.codeFrame,
|
|
834
|
-
name: prettyError.name,
|
|
848
|
+
name: prettyError.name ?? error?.name,
|
|
835
849
|
stack: getStack(prettyError),
|
|
836
850
|
type: getErrorType(prettyError)
|
|
837
851
|
},
|
|
@@ -866,7 +880,12 @@ const getErrorResponseSimple = (id, error) => {
|
|
|
866
880
|
return {
|
|
867
881
|
error: {
|
|
868
882
|
code: Custom,
|
|
869
|
-
data: error
|
|
883
|
+
data: error instanceof Error ? {
|
|
884
|
+
...error,
|
|
885
|
+
code: 'code' in error ? error.code : undefined,
|
|
886
|
+
stack: error.stack,
|
|
887
|
+
type: error.name
|
|
888
|
+
} : error,
|
|
870
889
|
// @ts-ignore
|
|
871
890
|
message: error.message
|
|
872
891
|
},
|
|
@@ -1412,6 +1431,7 @@ const launchSearchProcessElectron = async () => {
|
|
|
1412
1431
|
});
|
|
1413
1432
|
};
|
|
1414
1433
|
|
|
1434
|
+
const commandNotFoundRegex = /command not found|not found/i;
|
|
1415
1435
|
const launchSearchProcessNode = async () => {
|
|
1416
1436
|
try {
|
|
1417
1437
|
const {
|
|
@@ -1423,7 +1443,7 @@ const launchSearchProcessNode = async () => {
|
|
|
1423
1443
|
webSocket: new WebSocket(url, protocols)
|
|
1424
1444
|
});
|
|
1425
1445
|
} catch (error) {
|
|
1426
|
-
if (!(error instanceof Error && (error.message.includes('WebSocketCapability.create') || error.message.includes('module WebSocketCapability not found')) &&
|
|
1446
|
+
if (!(error instanceof Error && (error.message.includes('WebSocketCapability.create') || error.message.includes('module WebSocketCapability not found')) && commandNotFoundRegex.test(error.message))) {
|
|
1427
1447
|
throw error;
|
|
1428
1448
|
}
|
|
1429
1449
|
}
|
|
@@ -1488,8 +1508,18 @@ const getContextArgs = contextLines => {
|
|
|
1488
1508
|
const trimPart = part => {
|
|
1489
1509
|
return part.trim();
|
|
1490
1510
|
};
|
|
1511
|
+
const hasGlob = pattern => {
|
|
1512
|
+
return pattern.includes('*') || pattern.includes('?') || pattern.includes('[') || pattern.includes('{');
|
|
1513
|
+
};
|
|
1491
1514
|
const toGlob = pattern => {
|
|
1492
|
-
|
|
1515
|
+
const args = ['--glob', pattern];
|
|
1516
|
+
if (!hasGlob(pattern)) {
|
|
1517
|
+
const normalizedPattern = pattern.endsWith('/') ? pattern.slice(0, -1) : pattern;
|
|
1518
|
+
if (normalizedPattern) {
|
|
1519
|
+
args.push('--glob', `${normalizedPattern}/**`);
|
|
1520
|
+
}
|
|
1521
|
+
}
|
|
1522
|
+
return args;
|
|
1493
1523
|
};
|
|
1494
1524
|
const getIncludeArgs = include => {
|
|
1495
1525
|
return (include || '').split(',').map(trimPart).filter(Boolean).flatMap(toGlob);
|
|
@@ -1622,23 +1652,27 @@ const textSearch$2 = async (scheme, root, query, options, assetDir) => {
|
|
|
1622
1652
|
}
|
|
1623
1653
|
};
|
|
1624
1654
|
|
|
1655
|
+
const windowsDrivePathRegex = /^\/[A-Za-z]:\//;
|
|
1656
|
+
const windowsDriveRegex = /^[A-Za-z]:[\\/]/;
|
|
1657
|
+
const uriSchemeRegex = /^[A-Za-z][A-Za-z\d+.-]*:/;
|
|
1658
|
+
const trailingSlashRegex = /\/$/;
|
|
1625
1659
|
const normalizeWindowsDrive = path => {
|
|
1626
|
-
return
|
|
1660
|
+
return windowsDrivePathRegex.test(path) ? path.slice(1) : path;
|
|
1627
1661
|
};
|
|
1628
1662
|
const toPath = uri => {
|
|
1629
1663
|
if (uri.startsWith('file://')) {
|
|
1630
1664
|
return normalizeWindowsDrive(decodeURIComponent(new URL(uri).pathname)).replaceAll('\\', '/');
|
|
1631
1665
|
}
|
|
1632
|
-
if (
|
|
1666
|
+
if (windowsDriveRegex.test(uri)) {
|
|
1633
1667
|
return uri.replaceAll('\\', '/');
|
|
1634
1668
|
}
|
|
1635
|
-
if (
|
|
1669
|
+
if (uriSchemeRegex.test(uri)) {
|
|
1636
1670
|
return '';
|
|
1637
1671
|
}
|
|
1638
1672
|
return uri.replaceAll('\\', '/');
|
|
1639
1673
|
};
|
|
1640
1674
|
const getOpenEditorPaths = (root, openEditorUris) => {
|
|
1641
|
-
const rootPath = toPath(root).replace(
|
|
1675
|
+
const rootPath = toPath(root).replace(trailingSlashRegex, '');
|
|
1642
1676
|
const rootPrefix = `${rootPath}/`;
|
|
1643
1677
|
const paths = openEditorUris.map(toPath).filter(path => path.startsWith(rootPrefix)).map(path => path.slice(rootPrefix.length));
|
|
1644
1678
|
return [...new Set(paths)];
|