@lvce-editor/quick-pick-worker 4.23.0 → 4.23.2

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.
@@ -3441,7 +3441,7 @@ const getPath = uri => {
3441
3441
  }
3442
3442
  return uri;
3443
3443
  };
3444
- const toProtoVisibleItem = uri => {
3444
+ const toProtoVisibleItem = (uri, homeDir) => {
3445
3445
  const path = getPath(uri);
3446
3446
  const isRemoteSsh = uri.startsWith(remoteSshScheme);
3447
3447
  const authority = isRemoteSsh ? getRemoteSshAuthority(uri) : '';
@@ -3455,6 +3455,9 @@ const toProtoVisibleItem = uri => {
3455
3455
  let description = '';
3456
3456
  if (path.startsWith('/')) {
3457
3457
  description = pathDirName(path);
3458
+ if (homeDir && !isRemoteSsh && description.startsWith(homeDir) && (description.length === homeDir.length || description[homeDir.length] === '/')) {
3459
+ description = `~${description.slice(homeDir.length)}`;
3460
+ }
3458
3461
  }
3459
3462
  if (path === '/' && isRemoteSsh) {
3460
3463
  description = '/';
@@ -3474,7 +3477,13 @@ const toProtoVisibleItem = uri => {
3474
3477
  };
3475
3478
  const getPicks$6 = async () => {
3476
3479
  const recentlyOpened = await getRecentlyOpened();
3477
- const picks = recentlyOpened.map(toProtoVisibleItem);
3480
+ let homeDir;
3481
+ try {
3482
+ homeDir = await invoke$3('Workspace.getHomeDir');
3483
+ } catch {
3484
+ // Ignore unavailable workspace RPCs and keep the full path.
3485
+ }
3486
+ const picks = recentlyOpened.map(uri => toProtoVisibleItem(uri, homeDir));
3478
3487
  return picks;
3479
3488
  };
3480
3489
 
@@ -4094,11 +4103,20 @@ const getLoadedState = async state => {
4094
4103
  platform
4095
4104
  });
4096
4105
  array(newPicks);
4106
+ let colorTheme = '';
4107
+ if (subId === ColorTheme$1) {
4108
+ try {
4109
+ colorTheme = await invoke$3('ColorTheme.getColorTheme');
4110
+ } catch {
4111
+ // The worker can be released before the renderer endpoint.
4112
+ }
4113
+ }
4097
4114
  const filterValue = getFilterValue(id, subId, value);
4098
4115
  const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
4099
- const minLineY = 0;
4100
- const maxLineY = Math.min(minLineY + maxVisibleItems, newPicks.length);
4101
- const sliced = newPicks.slice(minLineY, maxLineY);
4116
+ const focusedIndex = subId === ColorTheme$1 ? Math.max(items.findIndex(item => item.label === colorTheme), 0) : 0;
4117
+ const minLineY = Math.max(Math.min(focusedIndex - maxVisibleItems + 1, items.length - maxVisibleItems), 0);
4118
+ const maxLineY = Math.min(minLineY + maxVisibleItems, items.length);
4119
+ const sliced = items.slice(minLineY, maxLineY);
4102
4120
  const {
4103
4121
  icons,
4104
4122
  newFileIconCache
@@ -4111,10 +4129,11 @@ const getLoadedState = async state => {
4111
4129
  ...state,
4112
4130
  args,
4113
4131
  cursorOffset: value.length,
4132
+ deltaY: minLineY * itemHeight,
4114
4133
  fileIconCache: newFileIconCache,
4115
4134
  finalDeltaY,
4116
4135
  focused: true,
4117
- focusedIndex: 0,
4136
+ focusedIndex,
4118
4137
  icons,
4119
4138
  initial: false,
4120
4139
  inputSource: Script,
@@ -4139,6 +4158,7 @@ const loadContentWithContext = async context => {
4139
4158
  await context.updateState(latestState => ({
4140
4159
  ...latestState,
4141
4160
  cursorOffset: loadedState.cursorOffset,
4161
+ deltaY: loadedState.deltaY,
4142
4162
  fileIconCache: loadedState.fileIconCache,
4143
4163
  finalDeltaY: loadedState.finalDeltaY,
4144
4164
  focused: loadedState.focused,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.23.0",
3
+ "version": "4.23.2",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"