@lvce-editor/quick-pick-worker 4.22.3 → 4.23.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.
@@ -3468,6 +3468,7 @@ const toProtoVisibleItem = uri => {
3468
3468
  iconName: isRemoteSsh ? folderName : undefined,
3469
3469
  label,
3470
3470
  matches: [],
3471
+ removeButton: true,
3471
3472
  uri
3472
3473
  };
3473
3474
  };
@@ -3969,20 +3970,6 @@ const getIndex = (top, headerHeight, itemHeight, y) => {
3969
3970
  return index;
3970
3971
  };
3971
3972
 
3972
- const getPick = (items, index) => {
3973
- array(items);
3974
- number(index);
3975
- // if (index < state.recentPicks.length) {
3976
- // return state.recentPicks[index]
3977
- // }
3978
- // index -= state.recentPicks.length
3979
- if (index < items.length) {
3980
- return items[index];
3981
- }
3982
- console.warn('no pick matching index', index);
3983
- return undefined;
3984
- };
3985
-
3986
3973
  const Commands = 'quickPick://commands';
3987
3974
  const EveryThing = 'quickPick://everything';
3988
3975
  const Recent = 'quickPick://recent';
@@ -4107,11 +4094,20 @@ const getLoadedState = async state => {
4107
4094
  platform
4108
4095
  });
4109
4096
  array(newPicks);
4097
+ let colorTheme = '';
4098
+ if (subId === ColorTheme$1) {
4099
+ try {
4100
+ colorTheme = await invoke$3('ColorTheme.getColorTheme');
4101
+ } catch {
4102
+ // The worker can be released before the renderer endpoint.
4103
+ }
4104
+ }
4110
4105
  const filterValue = getFilterValue(id, subId, value);
4111
4106
  const items = isTextInput(args) ? newPicks : filterQuickPickItems(newPicks, filterValue, subId === Commands$1);
4112
- const minLineY = 0;
4113
- const maxLineY = Math.min(minLineY + maxVisibleItems, newPicks.length);
4114
- const sliced = newPicks.slice(minLineY, maxLineY);
4107
+ const focusedIndex = subId === ColorTheme$1 ? Math.max(items.findIndex(item => item.label === colorTheme), 0) : 0;
4108
+ const minLineY = Math.max(Math.min(focusedIndex - maxVisibleItems + 1, items.length - maxVisibleItems), 0);
4109
+ const maxLineY = Math.min(minLineY + maxVisibleItems, items.length);
4110
+ const sliced = items.slice(minLineY, maxLineY);
4115
4111
  const {
4116
4112
  icons,
4117
4113
  newFileIconCache
@@ -4124,10 +4120,11 @@ const getLoadedState = async state => {
4124
4120
  ...state,
4125
4121
  args,
4126
4122
  cursorOffset: value.length,
4123
+ deltaY: minLineY * itemHeight,
4127
4124
  fileIconCache: newFileIconCache,
4128
4125
  finalDeltaY,
4129
4126
  focused: true,
4130
- focusedIndex: 0,
4127
+ focusedIndex,
4131
4128
  icons,
4132
4129
  initial: false,
4133
4130
  inputSource: Script,
@@ -4152,6 +4149,7 @@ const loadContentWithContext = async context => {
4152
4149
  await context.updateState(latestState => ({
4153
4150
  ...latestState,
4154
4151
  cursorOffset: loadedState.cursorOffset,
4152
+ deltaY: loadedState.deltaY,
4155
4153
  fileIconCache: loadedState.fileIconCache,
4156
4154
  finalDeltaY: loadedState.finalDeltaY,
4157
4155
  focused: loadedState.focused,
@@ -4171,6 +4169,20 @@ const loadContentWithContext = async context => {
4171
4169
  notifyVisible();
4172
4170
  };
4173
4171
 
4172
+ const getPick = (items, index) => {
4173
+ array(items);
4174
+ number(index);
4175
+ // if (index < state.recentPicks.length) {
4176
+ // return state.recentPicks[index]
4177
+ // }
4178
+ // index -= state.recentPicks.length
4179
+ if (index < items.length) {
4180
+ return items[index];
4181
+ }
4182
+ console.warn('no pick matching index', index);
4183
+ return undefined;
4184
+ };
4185
+
4174
4186
  const createCustomPick = value => {
4175
4187
  return {
4176
4188
  description: '',
@@ -4256,7 +4268,18 @@ const selectIndex = async (state, index, button = /* left */0) => {
4256
4268
  // }
4257
4269
  };
4258
4270
 
4259
- const handleClickAt = (state, x, y) => {
4271
+ const handleClickAt = async (state, x, y, uri) => {
4272
+ if (uri) {
4273
+ if (state.providerId !== Recent$1 || state.items.every(item => item.uri !== uri)) {
4274
+ return state;
4275
+ }
4276
+ await invoke$3('RecentlyOpened.removeRecentlyOpened', uri);
4277
+ const next = await loadContent({
4278
+ ...state,
4279
+ value: ''
4280
+ });
4281
+ return state.value ? setValue(next, state.value) : next;
4282
+ }
4260
4283
  const {
4261
4284
  headerHeight,
4262
4285
  itemHeight,
@@ -4928,7 +4951,9 @@ const getQuickPickItemVirtualDom = visibleItem => {
4928
4951
  isActive,
4929
4952
  label,
4930
4953
  posInSet,
4931
- setSize
4954
+ removeButton,
4955
+ setSize,
4956
+ uri
4932
4957
  } = visibleItem;
4933
4958
  const dom = [{
4934
4959
  ariaPosInSet: posInSet,
@@ -4964,6 +4989,17 @@ const getQuickPickItemVirtualDom = visibleItem => {
4964
4989
  type: Div
4965
4990
  }, text(description));
4966
4991
  }
4992
+ if (removeButton) {
4993
+ parent.childCount++;
4994
+ dom.push({
4995
+ ariaLabel: 'Remove from Recently Opened',
4996
+ childCount: 1,
4997
+ className: 'QuickPickItemRemove',
4998
+ 'data-uri': uri,
4999
+ title: 'Remove from Recently Opened',
5000
+ type: Button
5001
+ }, text('×'));
5002
+ }
4967
5003
  return dom;
4968
5004
  };
4969
5005
 
@@ -5154,7 +5190,7 @@ const render2 = (uid, diffResult) => {
5154
5190
  const renderEventListeners = () => {
5155
5191
  return [{
5156
5192
  name: HandlePointerDown,
5157
- params: ['handleClickAt', 'event.clientX', 'event.clientY'],
5193
+ params: ['handleClickAt', 'event.clientX', 'event.clientY', 'event.target.dataset.uri'],
5158
5194
  preventDefault: true
5159
5195
  }, {
5160
5196
  name: HandleWheel,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "4.22.3",
3
+ "version": "4.23.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"