@lvce-editor/quick-pick-worker 4.28.1 → 4.29.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.
@@ -2834,7 +2834,7 @@ const getPicks$e = async (value, args, {
2834
2834
  const extensionPicks = await getExtensionPicks(assetDir, platform, applicationId);
2835
2835
  const allPicks = [...builtinPicks, ...extensionPicks];
2836
2836
  const converted = allPicks.map(toProtoVisibleItem$3);
2837
- return converted;
2837
+ return value === '>' ? converted.toSorted((a, b) => a.label.localeCompare(b.label)) : converted;
2838
2838
  };
2839
2839
 
2840
2840
  const state$3 = {
@@ -3015,6 +3015,41 @@ const trimTrailingSeparators = path => {
3015
3015
  }
3016
3016
  return result;
3017
3017
  };
3018
+ const normalizePath = path => path.replaceAll('\\', '/');
3019
+ const getWorkspaceDisplayPath = workspace => {
3020
+ if (!hasUriScheme(workspace)) {
3021
+ return {
3022
+ path: normalizePath(workspace)
3023
+ };
3024
+ }
3025
+ const url = new URL(workspace);
3026
+ return {
3027
+ host: url.host,
3028
+ path: decodeURIComponent(url.pathname),
3029
+ scheme: url.protocol
3030
+ };
3031
+ };
3032
+ const getRelativeDirectory = (workspace, uri, dirName) => {
3033
+ const workspacePath = getWorkspaceDisplayPath(workspace);
3034
+ if (hasUriScheme(uri)) {
3035
+ const url = new URL(uri);
3036
+ if (workspacePath.scheme !== url.protocol || workspacePath.host !== url.host) {
3037
+ return dirName;
3038
+ }
3039
+ } else if (workspacePath.scheme) {
3040
+ return dirName;
3041
+ }
3042
+ const normalizedWorkspace = trimTrailingSeparators(workspacePath.path);
3043
+ const normalizedDirectory = normalizePath(dirName);
3044
+ const prefix = normalizedWorkspace.endsWith('/') ? normalizedWorkspace : `${normalizedWorkspace}/`;
3045
+ if (normalizedDirectory === normalizedWorkspace) {
3046
+ return '';
3047
+ }
3048
+ if (!normalizedDirectory.startsWith(prefix)) {
3049
+ return dirName;
3050
+ }
3051
+ return normalizedDirectory.slice(prefix.length);
3052
+ };
3018
3053
  const resolveFileUri = (workspace, path) => {
3019
3054
  if (hasUriScheme(path)) {
3020
3055
  return path;
@@ -3031,12 +3066,13 @@ const resolveFileUri = (workspace, path) => {
3031
3066
  }
3032
3067
  return `${trimTrailingSeparators(workspace)}/${path}`;
3033
3068
  };
3034
- const convertToPick = uri => {
3069
+ const convertToPick = (workspace, uri) => {
3035
3070
  const displayPath = hasUriScheme(uri) ? decodeURIComponent(new URL(uri).pathname) : uri.replaceAll('\\', '/');
3036
3071
  const baseName = pathBaseName(displayPath);
3037
3072
  const dirName = pathDirName(displayPath);
3073
+ const description = getRelativeDirectory(workspace, uri, dirName);
3038
3074
  return {
3039
- description: dirName,
3075
+ description,
3040
3076
  direntType: File,
3041
3077
  fileIcon: '',
3042
3078
  icon: '',
@@ -3078,7 +3114,7 @@ const getPicks$b = async searchValue => {
3078
3114
  });
3079
3115
  }
3080
3116
  }
3081
- const picks = files.map(path => convertToPick(resolveFileUri(workspace, path)));
3117
+ const picks = files.map(path => convertToPick(workspace, resolveFileUri(workspace, path)));
3082
3118
  return picks;
3083
3119
  };
3084
3120
 
@@ -3545,7 +3581,7 @@ const shouldHide = item => {
3545
3581
  return true;
3546
3582
  };
3547
3583
 
3548
- const selectPickBuiltin = async item => {
3584
+ const selectPickBuiltin = async (item, applicationId) => {
3549
3585
  if (item.id === 'QuickPick.showColorTheme') {
3550
3586
  return {
3551
3587
  command: OpenColorTheme
@@ -3558,7 +3594,11 @@ const selectPickBuiltin = async item => {
3558
3594
  }
3559
3595
  const args = item.args || [];
3560
3596
  // TODO ids should be all numbers for efficiency -> also directly can call command
3561
- await invoke$4(item.id, ...args);
3597
+ if (applicationId === undefined) {
3598
+ await invoke$4(item.id, ...args);
3599
+ } else {
3600
+ await invoke$4('Application.execute', applicationId, item.id, ...args);
3601
+ }
3562
3602
  if (shouldHide(item)) {
3563
3603
  return {
3564
3604
  command: Hide
@@ -3595,7 +3635,7 @@ const selectPick$b = async (item, _value = '', applicationId) => {
3595
3635
  if (id.startsWith('ext.')) {
3596
3636
  return selectPickExtension(item, applicationId);
3597
3637
  }
3598
- return selectPickBuiltin(item);
3638
+ return selectPickBuiltin(item, applicationId);
3599
3639
  };
3600
3640
 
3601
3641
  const getOptions = args => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.28.1",
3
+ "version": "4.29.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"