@lvce-editor/quick-pick-worker 4.24.5 → 4.24.7
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/quickPickWorkerMain.js +52 -20
- package/package.json +1 -1
|
@@ -1458,13 +1458,6 @@ const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
|
|
|
1458
1458
|
const command = 'Extensions.handleMessagePort';
|
|
1459
1459
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1460
1460
|
};
|
|
1461
|
-
const openUri$1 = async (uri, focus, options) => {
|
|
1462
|
-
await invoke$3('Main.openUri', {
|
|
1463
|
-
...options,
|
|
1464
|
-
focus,
|
|
1465
|
-
uri
|
|
1466
|
-
});
|
|
1467
|
-
};
|
|
1468
1461
|
const showErrorDialog$1 = async errorInfo => {
|
|
1469
1462
|
await invoke$3('ErrorHandling.showErrorDialog', errorInfo);
|
|
1470
1463
|
};
|
|
@@ -2658,13 +2651,23 @@ const filterQuickPickItem = (pattern, word) => {
|
|
|
2658
2651
|
return matches;
|
|
2659
2652
|
};
|
|
2660
2653
|
|
|
2661
|
-
const getMatchRank = (label, value) => {
|
|
2654
|
+
const getMatchRank = (label, matches, value) => {
|
|
2662
2655
|
if (label === value) {
|
|
2663
2656
|
return 4;
|
|
2664
2657
|
}
|
|
2665
2658
|
if (label.startsWith(value)) {
|
|
2666
2659
|
return 3;
|
|
2667
2660
|
}
|
|
2661
|
+
let wordStartMatches = 0;
|
|
2662
|
+
for (let i = 1; i < matches.length; i += 2) {
|
|
2663
|
+
const start = matches[i];
|
|
2664
|
+
if (start === 0 || !/[\p{L}\p{N}]/u.test(label[start - 1])) {
|
|
2665
|
+
wordStartMatches++;
|
|
2666
|
+
if (wordStartMatches >= 2) {
|
|
2667
|
+
return 2;
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
}
|
|
2668
2671
|
let index = label.indexOf(value);
|
|
2669
2672
|
if (index === -1) {
|
|
2670
2673
|
return 0;
|
|
@@ -2681,7 +2684,7 @@ const rankCommandPicks = (items, value) => {
|
|
|
2681
2684
|
const normalizedValue = value.toLowerCase();
|
|
2682
2685
|
const ranked = items.map(item => ({
|
|
2683
2686
|
item,
|
|
2684
|
-
rank: getMatchRank(item.label.toLowerCase(), normalizedValue)
|
|
2687
|
+
rank: getMatchRank(item.label.toLowerCase(), item.matches, normalizedValue)
|
|
2685
2688
|
}));
|
|
2686
2689
|
// The first match entry is the fuzzy score; the remaining entries describe highlights.
|
|
2687
2690
|
ranked.sort((a, b) => b.rank - a.rank || b.item.matches[0] - a.item.matches[0]);
|
|
@@ -3069,9 +3072,35 @@ const searchFile = async (path, value) => {
|
|
|
3069
3072
|
const files = await searchFile$1(/* path */path, /* searchTerm */value, prepare, '');
|
|
3070
3073
|
return files;
|
|
3071
3074
|
};
|
|
3075
|
+
const hasUriScheme = path => /^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path);
|
|
3076
|
+
const isAbsolutePath = path => path.startsWith('/') || /^[a-z]:[\\/]/i.test(path);
|
|
3077
|
+
const trimTrailingSeparators = path => {
|
|
3078
|
+
let result = path;
|
|
3079
|
+
while (result.endsWith('/') || result.endsWith('\\')) {
|
|
3080
|
+
result = result.slice(0, -1);
|
|
3081
|
+
}
|
|
3082
|
+
return result;
|
|
3083
|
+
};
|
|
3084
|
+
const resolveFileUri = (workspace, path) => {
|
|
3085
|
+
if (hasUriScheme(path)) {
|
|
3086
|
+
return path;
|
|
3087
|
+
}
|
|
3088
|
+
if (hasUriScheme(workspace)) {
|
|
3089
|
+
const workspaceUrl = new URL(workspace);
|
|
3090
|
+
const normalizedPath = path.replaceAll('\\', '/').replaceAll('%', '%25');
|
|
3091
|
+
const workspacePath = trimTrailingSeparators(workspaceUrl.pathname);
|
|
3092
|
+
workspaceUrl.pathname = normalizedPath.startsWith('/') ? normalizedPath : `${workspacePath}/${normalizedPath}`;
|
|
3093
|
+
return workspaceUrl.href;
|
|
3094
|
+
}
|
|
3095
|
+
if (isAbsolutePath(path)) {
|
|
3096
|
+
return path;
|
|
3097
|
+
}
|
|
3098
|
+
return `${trimTrailingSeparators(workspace)}/${path}`;
|
|
3099
|
+
};
|
|
3072
3100
|
const convertToPick = uri => {
|
|
3073
|
-
const
|
|
3074
|
-
const
|
|
3101
|
+
const displayPath = hasUriScheme(uri) ? decodeURIComponent(new URL(uri).pathname) : uri.replaceAll('\\', '/');
|
|
3102
|
+
const baseName = pathBaseName(displayPath);
|
|
3103
|
+
const dirName = pathDirName(displayPath);
|
|
3075
3104
|
return {
|
|
3076
3105
|
description: dirName,
|
|
3077
3106
|
direntType: File,
|
|
@@ -3094,7 +3123,7 @@ const getPicks$b = async searchValue => {
|
|
|
3094
3123
|
return [];
|
|
3095
3124
|
}
|
|
3096
3125
|
const files = await searchFile(workspace, searchValue);
|
|
3097
|
-
const picks = files.map(convertToPick);
|
|
3126
|
+
const picks = files.map(path => convertToPick(resolveFileUri(workspace, path)));
|
|
3098
3127
|
return picks;
|
|
3099
3128
|
};
|
|
3100
3129
|
|
|
@@ -3665,17 +3694,20 @@ const selectPick$9 = async pick => {
|
|
|
3665
3694
|
};
|
|
3666
3695
|
|
|
3667
3696
|
const openUri = async uri => {
|
|
3668
|
-
await
|
|
3697
|
+
await invoke$3('Main.openUri', uri);
|
|
3669
3698
|
};
|
|
3670
3699
|
|
|
3700
|
+
const toFileUri = path => {
|
|
3701
|
+
// Preserve already-qualified URIs, but treat Windows drive letters as paths.
|
|
3702
|
+
if (/^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) {
|
|
3703
|
+
return path;
|
|
3704
|
+
}
|
|
3705
|
+
const url = new URL('file:///');
|
|
3706
|
+
url.pathname = path.replaceAll('\\', '/').replaceAll('%', '%25');
|
|
3707
|
+
return url.href;
|
|
3708
|
+
};
|
|
3671
3709
|
const selectPick$8 = async pick => {
|
|
3672
|
-
|
|
3673
|
-
description
|
|
3674
|
-
} = pick;
|
|
3675
|
-
const fileName = pick.label;
|
|
3676
|
-
const workspace = await getWorkspacePath();
|
|
3677
|
-
const absolutePath = `${workspace}/${description}/${fileName}`;
|
|
3678
|
-
await openUri(absolutePath);
|
|
3710
|
+
await openUri(toFileUri(pick.uri));
|
|
3679
3711
|
return {
|
|
3680
3712
|
command: Hide
|
|
3681
3713
|
};
|