@lvce-editor/quick-pick-worker 4.24.4 → 4.24.6

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.
@@ -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
  };
@@ -3069,9 +3062,35 @@ const searchFile = async (path, value) => {
3069
3062
  const files = await searchFile$1(/* path */path, /* searchTerm */value, prepare, '');
3070
3063
  return files;
3071
3064
  };
3065
+ const hasUriScheme = path => /^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path);
3066
+ const isAbsolutePath = path => path.startsWith('/') || /^[a-z]:[\\/]/i.test(path);
3067
+ const trimTrailingSeparators = path => {
3068
+ let result = path;
3069
+ while (result.endsWith('/') || result.endsWith('\\')) {
3070
+ result = result.slice(0, -1);
3071
+ }
3072
+ return result;
3073
+ };
3074
+ const resolveFileUri = (workspace, path) => {
3075
+ if (hasUriScheme(path)) {
3076
+ return path;
3077
+ }
3078
+ if (hasUriScheme(workspace)) {
3079
+ const workspaceUrl = new URL(workspace);
3080
+ const normalizedPath = path.replaceAll('\\', '/').replaceAll('%', '%25');
3081
+ const workspacePath = trimTrailingSeparators(workspaceUrl.pathname);
3082
+ workspaceUrl.pathname = normalizedPath.startsWith('/') ? normalizedPath : `${workspacePath}/${normalizedPath}`;
3083
+ return workspaceUrl.href;
3084
+ }
3085
+ if (isAbsolutePath(path)) {
3086
+ return path;
3087
+ }
3088
+ return `${trimTrailingSeparators(workspace)}/${path}`;
3089
+ };
3072
3090
  const convertToPick = uri => {
3073
- const baseName = pathBaseName(uri);
3074
- const dirName = pathDirName(uri);
3091
+ const displayPath = hasUriScheme(uri) ? decodeURIComponent(new URL(uri).pathname) : uri.replaceAll('\\', '/');
3092
+ const baseName = pathBaseName(displayPath);
3093
+ const dirName = pathDirName(displayPath);
3075
3094
  return {
3076
3095
  description: dirName,
3077
3096
  direntType: File,
@@ -3094,7 +3113,7 @@ const getPicks$b = async searchValue => {
3094
3113
  return [];
3095
3114
  }
3096
3115
  const files = await searchFile(workspace, searchValue);
3097
- const picks = files.map(convertToPick);
3116
+ const picks = files.map(path => convertToPick(resolveFileUri(workspace, path)));
3098
3117
  return picks;
3099
3118
  };
3100
3119
 
@@ -3665,17 +3684,20 @@ const selectPick$9 = async pick => {
3665
3684
  };
3666
3685
 
3667
3686
  const openUri = async uri => {
3668
- await openUri$1(uri);
3687
+ await invoke$3('Main.openUri', uri);
3669
3688
  };
3670
3689
 
3690
+ const toFileUri = path => {
3691
+ // Preserve already-qualified URIs, but treat Windows drive letters as paths.
3692
+ if (/^[a-z][a-z\d+.-]*:/i.test(path) && !/^[a-z]:[\\/]/i.test(path)) {
3693
+ return path;
3694
+ }
3695
+ const url = new URL('file:///');
3696
+ url.pathname = path.replaceAll('\\', '/').replaceAll('%', '%25');
3697
+ return url.href;
3698
+ };
3671
3699
  const selectPick$8 = async pick => {
3672
- const {
3673
- description
3674
- } = pick;
3675
- const fileName = pick.label;
3676
- const workspace = await getWorkspacePath();
3677
- const absolutePath = `${workspace}/${description}/${fileName}`;
3678
- await openUri(absolutePath);
3700
+ await openUri(toFileUri(pick.uri));
3679
3701
  return {
3680
3702
  command: Hide
3681
3703
  };
@@ -3739,7 +3761,7 @@ const selectPick$5 = async pick => {
3739
3761
  const selectPick$4 = async pick => {
3740
3762
  const editorId = await getActiveEditorId();
3741
3763
  const value = pick.value;
3742
- await invoke$3('Viewlet.executeViewletCommand', editorId, 'setLanguageId', value.languageId, value.tokenizePath);
3764
+ await invoke$3('Viewlet.executeViewletCommand', editorId, 'setLanguageId', value.languageId, value.tokenizePath, true);
3743
3765
  return {
3744
3766
  command: Hide
3745
3767
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.24.4",
3
+ "version": "4.24.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"