@lvce-editor/quick-pick-worker 3.3.0 → 4.1.0

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.
@@ -546,12 +546,12 @@ const execute = (command, ...args) => {
546
546
  };
547
547
 
548
548
  const Two$1 = '2.0';
549
- const callbacks$1 = Object.create(null);
550
- const get$2 = id => {
551
- return callbacks$1[id];
549
+ const callbacks$2 = Object.create(null);
550
+ const get$3 = id => {
551
+ return callbacks$2[id];
552
552
  };
553
- const remove$1 = id => {
554
- delete callbacks$1[id];
553
+ const remove$2 = id => {
554
+ delete callbacks$2[id];
555
555
  };
556
556
  class JsonRpcError extends Error {
557
557
  constructor(message) {
@@ -696,14 +696,14 @@ const warn$1 = (...args) => {
696
696
  console.warn(...args);
697
697
  };
698
698
  const resolve = (id, response) => {
699
- const fn = get$2(id);
699
+ const fn = get$3(id);
700
700
  if (!fn) {
701
701
  console.log(response);
702
702
  warn$1(`callback ${id} may already be disposed`);
703
703
  return;
704
704
  }
705
705
  fn(response);
706
- remove$1(id);
706
+ remove$2(id);
707
707
  };
708
708
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
709
709
  const getErrorType = prettyError => {
@@ -759,7 +759,7 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
759
759
  const errorProperty = getErrorProperty(error, prettyError);
760
760
  return create$1$1(id, errorProperty);
761
761
  };
762
- const create$b = (message, result) => {
762
+ const create$c = (message, result) => {
763
763
  return {
764
764
  id: message.id,
765
765
  jsonrpc: Two$1,
@@ -768,7 +768,7 @@ const create$b = (message, result) => {
768
768
  };
769
769
  const getSuccessResponse = (message, result) => {
770
770
  const resultProperty = result ?? null;
771
- return create$b(message, resultProperty);
771
+ return create$c(message, resultProperty);
772
772
  };
773
773
  const getErrorResponseSimple = (id, error) => {
774
774
  return {
@@ -862,7 +862,7 @@ const handleJsonRpcMessage = async (...args) => {
862
862
 
863
863
  const Two = '2.0';
864
864
 
865
- const create$a = (method, params) => {
865
+ const create$b = (method, params) => {
866
866
  return {
867
867
  jsonrpc: Two,
868
868
  method,
@@ -870,7 +870,7 @@ const create$a = (method, params) => {
870
870
  };
871
871
  };
872
872
 
873
- const create$9 = (id, method, params) => {
873
+ const create$a = (id, method, params) => {
874
874
  const message = {
875
875
  id,
876
876
  jsonrpc: Two,
@@ -880,13 +880,13 @@ const create$9 = (id, method, params) => {
880
880
  return message;
881
881
  };
882
882
 
883
- let id = 0;
884
- const create$8 = () => {
885
- return ++id;
883
+ let id$2 = 0;
884
+ const create$9 = () => {
885
+ return ++id$2;
886
886
  };
887
887
 
888
888
  const registerPromise = map => {
889
- const id = create$8();
889
+ const id = create$9();
890
890
  const {
891
891
  promise,
892
892
  resolve
@@ -903,7 +903,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
903
903
  id,
904
904
  promise
905
905
  } = registerPromise(callbacks);
906
- const message = create$9(id, method, params);
906
+ const message = create$a(id, method, params);
907
907
  if (useSendAndTransfer && ipc.sendAndTransfer) {
908
908
  ipc.sendAndTransfer(message);
909
909
  } else {
@@ -939,7 +939,7 @@ const createRpc = ipc => {
939
939
  * @deprecated
940
940
  */
941
941
  send(method, ...params) {
942
- const message = create$a(method, params);
942
+ const message = create$b(method, params);
943
943
  ipc.send(message);
944
944
  }
945
945
  };
@@ -979,7 +979,7 @@ const listen$1 = async (module, options) => {
979
979
  return ipc;
980
980
  };
981
981
 
982
- const create$7 = async ({
982
+ const create$8 = async ({
983
983
  commandMap,
984
984
  isMessagePortOpen = true,
985
985
  messagePort
@@ -997,7 +997,7 @@ const create$7 = async ({
997
997
  return rpc;
998
998
  };
999
999
 
1000
- const create$6 = async ({
1000
+ const create$7 = async ({
1001
1001
  commandMap,
1002
1002
  isMessagePortOpen,
1003
1003
  send
@@ -1007,7 +1007,7 @@ const create$6 = async ({
1007
1007
  port2
1008
1008
  } = new MessageChannel();
1009
1009
  await send(port1);
1010
- return create$7({
1010
+ return create$8({
1011
1011
  commandMap,
1012
1012
  isMessagePortOpen,
1013
1013
  messagePort: port2
@@ -1042,13 +1042,13 @@ const createSharedLazyRpc = factory => {
1042
1042
  };
1043
1043
  };
1044
1044
 
1045
- const create$5 = async ({
1045
+ const create$6 = async ({
1046
1046
  commandMap,
1047
1047
  isMessagePortOpen,
1048
1048
  send
1049
1049
  }) => {
1050
1050
  return createSharedLazyRpc(() => {
1051
- return create$6({
1051
+ return create$7({
1052
1052
  commandMap,
1053
1053
  isMessagePortOpen,
1054
1054
  send
@@ -1056,7 +1056,7 @@ const create$5 = async ({
1056
1056
  });
1057
1057
  };
1058
1058
 
1059
- const create$4 = async ({
1059
+ const create$5 = async ({
1060
1060
  commandMap
1061
1061
  }) => {
1062
1062
  // TODO create a commandMap per rpc instance
@@ -1088,32 +1088,32 @@ const createMockRpc = ({
1088
1088
  };
1089
1089
 
1090
1090
  const rpcs = Object.create(null);
1091
- const set$4 = (id, rpc) => {
1091
+ const set$5 = (id, rpc) => {
1092
1092
  rpcs[id] = rpc;
1093
1093
  };
1094
- const get$1 = id => {
1094
+ const get$2 = id => {
1095
1095
  return rpcs[id];
1096
1096
  };
1097
- const remove = id => {
1097
+ const remove$1 = id => {
1098
1098
  delete rpcs[id];
1099
1099
  };
1100
1100
 
1101
1101
  /* eslint-disable @typescript-eslint/explicit-function-return-type */
1102
- const create$3 = rpcId => {
1102
+ const create$4 = rpcId => {
1103
1103
  return {
1104
1104
  async dispose() {
1105
- const rpc = get$1(rpcId);
1105
+ const rpc = get$2(rpcId);
1106
1106
  await rpc.dispose();
1107
1107
  },
1108
1108
  // @ts-ignore
1109
1109
  invoke(method, ...params) {
1110
- const rpc = get$1(rpcId);
1110
+ const rpc = get$2(rpcId);
1111
1111
  // @ts-ignore
1112
1112
  return rpc.invoke(method, ...params);
1113
1113
  },
1114
1114
  // @ts-ignore
1115
1115
  invokeAndTransfer(method, ...params) {
1116
- const rpc = get$1(rpcId);
1116
+ const rpc = get$2(rpcId);
1117
1117
  // @ts-ignore
1118
1118
  return rpc.invokeAndTransfer(method, ...params);
1119
1119
  },
@@ -1121,16 +1121,16 @@ const create$3 = rpcId => {
1121
1121
  const mockRpc = createMockRpc({
1122
1122
  commandMap
1123
1123
  });
1124
- set$4(rpcId, mockRpc);
1124
+ set$5(rpcId, mockRpc);
1125
1125
  // @ts-ignore
1126
1126
  mockRpc[Symbol.dispose] = () => {
1127
- remove(rpcId);
1127
+ remove$1(rpcId);
1128
1128
  };
1129
1129
  // @ts-ignore
1130
1130
  return mockRpc;
1131
1131
  },
1132
1132
  set(rpc) {
1133
- set$4(rpcId, rpc);
1133
+ set$5(rpcId, rpc);
1134
1134
  }
1135
1135
  };
1136
1136
  };
@@ -1151,52 +1151,52 @@ const SetPatches = 'Viewlet.setPatches';
1151
1151
  const FocusQuickPickInput = 20;
1152
1152
 
1153
1153
  const {
1154
- invoke: invoke$2,
1155
- set: set$3
1156
- } = create$3(EditorWorker);
1154
+ invoke: invoke$3,
1155
+ set: set$4
1156
+ } = create$4(EditorWorker);
1157
1157
  const getLines = async editorUid => {
1158
- const lines = await invoke$2('Editor.getLines2', editorUid);
1158
+ const lines = await invoke$3('Editor.getLines2', editorUid);
1159
1159
  return lines;
1160
1160
  };
1161
1161
 
1162
1162
  const {
1163
- invoke: invoke$1,
1164
- set: set$2
1165
- } = create$3(7013);
1163
+ invoke: invoke$2,
1164
+ set: set$3
1165
+ } = create$4(7013);
1166
1166
 
1167
1167
  const {
1168
- invoke,
1168
+ invoke: invoke$1,
1169
1169
  invokeAndTransfer,
1170
- set: set$1
1171
- } = create$3(RendererWorker);
1170
+ set: set$2
1171
+ } = create$4(RendererWorker);
1172
1172
  const sendMessagePortToEditorWorker = async (port, rpcId) => {
1173
1173
  const command = 'HandleMessagePort.handleMessagePort';
1174
1174
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
1175
1175
  };
1176
1176
  const setFocus = key => {
1177
- return invoke('Focus.setFocus', key);
1177
+ return invoke$1('Focus.setFocus', key);
1178
1178
  };
1179
1179
  const getFileIcon = async options => {
1180
- return invoke('IconTheme.getFileIcon', options);
1180
+ return invoke$1('IconTheme.getFileIcon', options);
1181
1181
  };
1182
1182
  const getFolderIcon = async options => {
1183
- return invoke('IconTheme.getFolderIcon', options);
1183
+ return invoke$1('IconTheme.getFolderIcon', options);
1184
1184
  };
1185
1185
  const closeWidget$1 = async widgetId => {
1186
- return invoke('Viewlet.closeWidget', widgetId);
1186
+ return invoke$1('Viewlet.closeWidget', widgetId);
1187
1187
  };
1188
1188
  const sendMessagePortToFileSearchWorker2 = async (port, rpcId = 0) => {
1189
1189
  const command = 'FileSearch.handleMessagePort';
1190
1190
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSearchWorker', port, command, rpcId);
1191
1191
  };
1192
1192
  const getActiveEditorId = () => {
1193
- return invoke('GetActiveEditor.getActiveEditorId');
1193
+ return invoke$1('GetActiveEditor.getActiveEditorId');
1194
1194
  };
1195
1195
  const openUri$1 = async (uri, focus, options) => {
1196
- await invoke('Main.openUri', uri, focus, options);
1196
+ await invoke$1('Main.openUri', uri, focus, options);
1197
1197
  };
1198
1198
  const showErrorDialog$1 = async errorInfo => {
1199
- await invoke('ErrorHandling.showErrorDialog', errorInfo);
1199
+ await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
1200
1200
  };
1201
1201
 
1202
1202
  const closeWidget = async id => {
@@ -1204,7 +1204,73 @@ const closeWidget = async id => {
1204
1204
  await closeWidget$1(id);
1205
1205
  };
1206
1206
 
1207
+ let id$1 = 0;
1208
+ const create$3 = () => {
1209
+ return ++id$1;
1210
+ };
1211
+
1212
+ const callbacks$1 = Object.create(null);
1213
+ const registerCallback = () => {
1214
+ const id = create$3();
1215
+ const {
1216
+ promise,
1217
+ resolve
1218
+ } = Promise.withResolvers();
1219
+ callbacks$1[id] = resolve;
1220
+ return {
1221
+ id,
1222
+ promise
1223
+ };
1224
+ };
1225
+ const executeCallback = (id, value) => {
1226
+ const fn = callbacks$1[id];
1227
+ delete callbacks$1[id];
1228
+ fn(value);
1229
+ };
1230
+
1231
+ const ColorTheme$1 = 0;
1232
+ const Commands$1 = 1;
1233
+ const Custom$1 = 2;
1234
+ const File$1 = 3;
1235
+ const GoToColumn$1 = 4;
1236
+ const GoToLine$2 = 5;
1237
+ const Help$2 = 6;
1238
+ const Recent$1 = 7;
1239
+ const Symbol$3 = 8;
1240
+ const View$3 = 9;
1241
+ const WorkspaceSymbol$2 = 10;
1242
+ const EveryThing$1 = 100;
1243
+
1244
+ const getCancelResult$1 = args => {
1245
+ const last = args.at(-1);
1246
+ if (last && typeof last === 'object' &&
1247
+ // @ts-ignore
1248
+ last.mode === 'quickPick') {
1249
+ return undefined;
1250
+ }
1251
+ return {
1252
+ canceled: true,
1253
+ inputValue: ''
1254
+ };
1255
+ };
1207
1256
  const close = async state => {
1257
+ const {
1258
+ args,
1259
+ providerId
1260
+ } = state;
1261
+ if (providerId === Custom$1) {
1262
+ const resolveId = args[2];
1263
+ const options = args.at(-1);
1264
+ const result = getCancelResult$1(args);
1265
+ if (options?.callbackOwner === 'quickPickWorker') {
1266
+ if (typeof resolveId !== 'number') {
1267
+ throw new TypeError('expected resolve id to be a number');
1268
+ }
1269
+ executeCallback(resolveId, result);
1270
+ } else {
1271
+ await invoke$1('QuickPick.executeCallback', resolveId, result);
1272
+ }
1273
+ }
1208
1274
  await closeWidget(state.uid);
1209
1275
  return state;
1210
1276
  };
@@ -1336,13 +1402,47 @@ const create$2 = () => {
1336
1402
 
1337
1403
  const {
1338
1404
  dispose: dispose$1,
1339
- get,
1405
+ get: get$1,
1340
1406
  getCommandIds,
1341
1407
  registerCommands,
1342
- set,
1408
+ set: set$1,
1343
1409
  wrapCommand
1344
1410
  } = create$2();
1345
1411
 
1412
+ const getListHeight$1 = (itemsLength, itemHeight, maxHeight) => {
1413
+ number(itemsLength);
1414
+ number(itemHeight);
1415
+ number(maxHeight);
1416
+ if (itemsLength === 0) {
1417
+ return itemHeight;
1418
+ }
1419
+ const totalHeight = itemsLength * itemHeight;
1420
+ return Math.min(totalHeight, maxHeight);
1421
+ };
1422
+
1423
+ const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
1424
+ if (size >= contentSize) {
1425
+ return 0;
1426
+ }
1427
+ return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
1428
+ };
1429
+
1430
+ const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
1431
+ if (finalDelta <= 0) {
1432
+ return 0;
1433
+ }
1434
+ const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
1435
+ return scrollBarOffset;
1436
+ };
1437
+ const getScrollBarY = getScrollBarOffset;
1438
+ const getDeltaY = (scrollBarY, finalDelta, size, scrollBarSize) => {
1439
+ const scrollBarRange = size - scrollBarSize;
1440
+ if (finalDelta <= 0 || scrollBarRange <= 0) {
1441
+ return 0;
1442
+ }
1443
+ return scrollBarY / scrollBarRange * finalDelta;
1444
+ };
1445
+
1346
1446
  const create$1 = ({
1347
1447
  headerHeight = 0,
1348
1448
  itemHeight,
@@ -1360,17 +1460,40 @@ const create$1 = ({
1360
1460
  minLineY: 0,
1361
1461
  scrollBarActive: false,
1362
1462
  scrollBarHeight: 0,
1463
+ scrollBarPointerId: -1,
1464
+ scrollBarPointerOffsetY: 0,
1363
1465
  touchDifference: 0,
1364
1466
  touchOffsetY: 0,
1365
1467
  touchTimeStamp: 0
1366
1468
  };
1367
1469
  };
1368
- const getListHeight$1 = (height, headerHeight) => {
1470
+ const getListHeight = (height, headerHeight) => {
1369
1471
  if (headerHeight) {
1370
1472
  return height - headerHeight;
1371
1473
  }
1372
1474
  return headerHeight;
1373
1475
  };
1476
+ const clamp = (value, min, max) => {
1477
+ return Math.min(Math.max(value, min), max);
1478
+ };
1479
+ const getScrollBarHeight = state => {
1480
+ const {
1481
+ height,
1482
+ itemHeight,
1483
+ items,
1484
+ minimumSliderSize
1485
+ } = state;
1486
+ const listHeight = getListHeight$1(items.length, itemHeight, height);
1487
+ const contentHeight = items.length * itemHeight;
1488
+ return getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
1489
+ };
1490
+ const getScrollBarTop = (state, scrollBarHeight) => {
1491
+ const scrollBarSize = state.height - state.headerHeight;
1492
+ return getScrollBarY(state.deltaY, state.finalDeltaY, scrollBarSize, scrollBarHeight);
1493
+ };
1494
+ const getRelativePointerY = (state, clientY) => {
1495
+ return clientY - state.top - state.headerHeight;
1496
+ };
1374
1497
  const setDeltaY = (state, deltaY) => {
1375
1498
  object(state);
1376
1499
  number(deltaY);
@@ -1380,7 +1503,7 @@ const setDeltaY = (state, deltaY) => {
1380
1503
  itemHeight,
1381
1504
  items
1382
1505
  } = state;
1383
- const listHeight = getListHeight$1(height, headerHeight);
1506
+ const listHeight = getListHeight(height, headerHeight);
1384
1507
  const itemsLength = items.length;
1385
1508
  const finalDeltaY = itemsLength * itemHeight - listHeight;
1386
1509
  if (deltaY < 0) {
@@ -1408,8 +1531,55 @@ const handleWheel = (state, deltaMode, deltaY) => {
1408
1531
  number(deltaY);
1409
1532
  return setDeltaY(state, state.deltaY + deltaY);
1410
1533
  };
1534
+ const handleScrollBarPointerDown = (state, clientY, pointerId) => {
1535
+ object(state);
1536
+ number(clientY);
1537
+ number(pointerId);
1538
+ const scrollBarHeight = getScrollBarHeight(state);
1539
+ if (scrollBarHeight <= 0) {
1540
+ return state;
1541
+ }
1542
+ const scrollBarTop = getScrollBarTop(state, scrollBarHeight);
1543
+ const relativePointerY = getRelativePointerY(state, clientY);
1544
+ const scrollBarPointerOffsetY = clamp(relativePointerY - scrollBarTop, 0, scrollBarHeight);
1545
+ const newState = {
1546
+ ...state,
1547
+ scrollBarActive: true,
1548
+ scrollBarPointerId: pointerId,
1549
+ scrollBarPointerOffsetY
1550
+ };
1551
+ return handleScrollBarPointerMove(newState, clientY, pointerId);
1552
+ };
1553
+ const handleScrollBarPointerMove = (state, clientY, pointerId) => {
1554
+ object(state);
1555
+ number(clientY);
1556
+ number(pointerId);
1557
+ if (!state.scrollBarActive || state.scrollBarPointerId !== pointerId) {
1558
+ return state;
1559
+ }
1560
+ const scrollBarHeight = getScrollBarHeight(state);
1561
+ const scrollBarSize = state.height - state.headerHeight;
1562
+ const maxScrollBarTop = Math.max(scrollBarSize - scrollBarHeight, 0);
1563
+ const relativePointerY = getRelativePointerY(state, clientY) - state.scrollBarPointerOffsetY;
1564
+ const scrollBarTop = clamp(relativePointerY, 0, maxScrollBarTop);
1565
+ const deltaY = Math.round(getDeltaY(scrollBarTop, state.finalDeltaY, scrollBarSize, scrollBarHeight));
1566
+ return setDeltaY(state, deltaY);
1567
+ };
1568
+ const handleScrollBarPointerUp = (state, pointerId) => {
1569
+ object(state);
1570
+ number(pointerId);
1571
+ if (!state.scrollBarActive || state.scrollBarPointerId !== pointerId) {
1572
+ return state;
1573
+ }
1574
+ return {
1575
+ ...state,
1576
+ scrollBarActive: false,
1577
+ scrollBarPointerId: -1,
1578
+ scrollBarPointerOffsetY: 0
1579
+ };
1580
+ };
1411
1581
 
1412
- const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, workspaceUri, assetDir) => {
1582
+ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, _renderAllItems, workspaceUri, assetDir) => {
1413
1583
  const state = {
1414
1584
  allowEmptyResult: false,
1415
1585
  cursorOffset: 0,
@@ -1442,7 +1612,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, w
1442
1612
  platform,
1443
1613
  value: ''
1444
1614
  };
1445
- set(uid, state, state);
1615
+ set$1(uid, state, state);
1446
1616
  };
1447
1617
 
1448
1618
  const RenderItems = 1;
@@ -1492,7 +1662,7 @@ const diff2 = uid => {
1492
1662
  const {
1493
1663
  newState,
1494
1664
  oldState
1495
- } = get(uid);
1665
+ } = get$1(uid);
1496
1666
  return diff(oldState, newState);
1497
1667
  };
1498
1668
 
@@ -1501,7 +1671,7 @@ const dispose = uid => {
1501
1671
  };
1502
1672
 
1503
1673
  const setColorTheme = id => {
1504
- return invoke(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1674
+ return invoke$1(/* ColorTheme.setColorTheme */'ColorTheme.setColorTheme', /* colorThemeId */id);
1505
1675
  };
1506
1676
 
1507
1677
  const focusPick$1 = async pick => {
@@ -1511,19 +1681,6 @@ const focusPick$1 = async pick => {
1511
1681
  await setColorTheme(label);
1512
1682
  };
1513
1683
 
1514
- const ColorTheme$1 = 0;
1515
- const Commands$1 = 1;
1516
- const Custom$1 = 2;
1517
- const File$1 = 3;
1518
- const GoToColumn$1 = 4;
1519
- const GoToLine$2 = 5;
1520
- const Help$2 = 6;
1521
- const Recent$1 = 7;
1522
- const Symbol$3 = 8;
1523
- const View$3 = 9;
1524
- const WorkspaceSymbol$2 = 10;
1525
- const EveryThing$1 = 100;
1526
-
1527
1684
  const noop$1 = async () => {};
1528
1685
  const getFn$1 = id => {
1529
1686
  switch (id) {
@@ -1559,6 +1716,10 @@ const getMissingIconRequests = (dirents, fileIconCache) => {
1559
1716
  return missingRequests;
1560
1717
  };
1561
1718
 
1719
+ const getPath$1 = dirent => {
1720
+ return dirent.path;
1721
+ };
1722
+
1562
1723
  const None$2 = 0;
1563
1724
  const Directory = 3;
1564
1725
  const File = 7;
@@ -1578,6 +1739,15 @@ const requestFileIcons = async requests => {
1578
1739
  return Promise.all(promises);
1579
1740
  };
1580
1741
 
1742
+ const toDirent = pick => {
1743
+ const dirent = {
1744
+ name: pick.label,
1745
+ path: pick.uri,
1746
+ type: pick.direntType
1747
+ };
1748
+ return dirent;
1749
+ };
1750
+
1581
1751
  const updateIconCache = (iconCache, missingRequests, newIcons) => {
1582
1752
  if (missingRequests.length === 0) {
1583
1753
  return iconCache;
@@ -1593,17 +1763,6 @@ const updateIconCache = (iconCache, missingRequests, newIcons) => {
1593
1763
  return newFileIconCache;
1594
1764
  };
1595
1765
 
1596
- const getPath$1 = dirent => {
1597
- return dirent.path;
1598
- };
1599
- const toDirent = pick => {
1600
- const dirent = {
1601
- name: pick.label,
1602
- path: pick.uri,
1603
- type: pick.direntType
1604
- };
1605
- return dirent;
1606
- };
1607
1766
  const getQuickPickFileIcons = async (items, fileIconCache) => {
1608
1767
  const dirents = items.map(toDirent);
1609
1768
  const missingRequests = getMissingIconRequests(dirents, fileIconCache);
@@ -1620,6 +1779,7 @@ const getQuickPickFileIcons = async (items, fileIconCache) => {
1620
1779
  const focusIndex = async (state, index) => {
1621
1780
  const {
1622
1781
  fileIconCache,
1782
+ itemHeight,
1623
1783
  items,
1624
1784
  maxLineY,
1625
1785
  maxVisibleItems,
@@ -1639,6 +1799,7 @@ const focusIndex = async (state, index) => {
1639
1799
  // TODO need to scroll up
1640
1800
  return {
1641
1801
  ...state,
1802
+ deltaY: minLineY * itemHeight,
1642
1803
  fileIconCache: newFileIconCache,
1643
1804
  focusedIndex: index,
1644
1805
  icons,
@@ -1657,6 +1818,7 @@ const focusIndex = async (state, index) => {
1657
1818
  } = await getQuickPickFileIcons(sliced, fileIconCache);
1658
1819
  return {
1659
1820
  ...state,
1821
+ deltaY: minLineY * itemHeight,
1660
1822
  fileIconCache: newFileIconCache,
1661
1823
  focusedIndex: index,
1662
1824
  icons,
@@ -1728,8 +1890,7 @@ const DownArrow = 16;
1728
1890
 
1729
1891
  const getKeyBindings = () => {
1730
1892
  return [{
1731
- args: ['QuickPick'],
1732
- command: 'Viewlet.closeWidget',
1893
+ command: 'QuickPick.close',
1733
1894
  key: Escape,
1734
1895
  when: FocusQuickPickInput
1735
1896
  }, {
@@ -2156,19 +2317,8 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
2156
2317
  return finalDeltaY;
2157
2318
  };
2158
2319
 
2159
- const getListHeight = (itemsLength, itemHeight, maxHeight) => {
2160
- number(itemsLength);
2161
- number(itemHeight);
2162
- number(maxHeight);
2163
- if (itemsLength === 0) {
2164
- return itemHeight;
2165
- }
2166
- const totalHeight = itemsLength * itemHeight;
2167
- return Math.min(totalHeight, maxHeight);
2168
- };
2169
-
2170
2320
  const getColorThemeNames = async (assetDir, platform) => {
2171
- return invoke('ColorTheme.getColorThemeNames', assetDir, platform);
2321
+ return invoke$1('ColorTheme.getColorThemeNames', assetDir, platform);
2172
2322
  };
2173
2323
 
2174
2324
  const toProtoVisibleItem$3 = name => {
@@ -2226,14 +2376,14 @@ const state$1 = {
2226
2376
  const getAll = async () => {
2227
2377
  try {
2228
2378
  // @ts-ignore
2229
- const entries = await invoke('Layout.getAllQuickPickMenuEntries');
2379
+ const entries = await invoke$1('Layout.getAllQuickPickMenuEntries');
2230
2380
  return entries || [];
2231
2381
  } catch {
2232
2382
  // ignore
2233
2383
  }
2234
2384
  return state$1.menuEntries;
2235
2385
  };
2236
- const add = menuEntries => {
2386
+ const add$1 = menuEntries => {
2237
2387
  state$1.menuEntries = [...state$1.menuEntries, ...menuEntries];
2238
2388
  };
2239
2389
 
@@ -2262,7 +2412,7 @@ const getExtensionPicks = async (assetDir, platform) => {
2262
2412
  // Assert.number(platform)
2263
2413
  // TODO ask extension management worker directly
2264
2414
  // TODO don't call this every time, cache the results
2265
- const extensionPicks = await invoke('ExtensionHost.getCommands', assetDir, platform);
2415
+ const extensionPicks = await invoke$1('ExtensionHost.getCommands', assetDir, platform);
2266
2416
  if (!extensionPicks) {
2267
2417
  return [];
2268
2418
  }
@@ -2302,22 +2452,53 @@ const getPicks$b = async (value, args, {
2302
2452
  return converted;
2303
2453
  };
2304
2454
 
2455
+ const state = {
2456
+ args: [],
2457
+ items: Object.create(null)
2458
+ };
2459
+
2460
+ let id = 0;
2461
+ const add = items => {
2462
+ const nextId = ++id;
2463
+ state.items[nextId] = items;
2464
+ return nextId;
2465
+ };
2466
+ const get = id => {
2467
+ return state.items[id] || [];
2468
+ };
2469
+ const remove = id => {
2470
+ delete state.items[id];
2471
+ };
2472
+
2473
+ let rpc;
2474
+ const set = newRpc => {
2475
+ rpc = newRpc;
2476
+ };
2477
+ const invoke = (method, ...args) => {
2478
+ return rpc.invoke(method, ...args);
2479
+ };
2480
+
2305
2481
  const toProtoVisibleItem$1 = item => {
2306
2482
  const {
2307
- label
2483
+ description = '',
2484
+ label,
2485
+ value
2308
2486
  } = item;
2309
2487
  return {
2310
- description: '',
2488
+ description,
2311
2489
  direntType: 0,
2312
2490
  fileIcon: '',
2313
2491
  icon: '',
2314
2492
  label,
2315
2493
  matches: [],
2316
- uri: ''
2494
+ uri: '',
2495
+ value
2317
2496
  };
2318
2497
  };
2319
2498
  const getPicks$a = async (searchValue, args) => {
2320
- const items = args[1] || [];
2499
+ state.args = args;
2500
+ const options = args.at(-1);
2501
+ const items = options?.mode === 'quickInput' ? searchValue === '' && options?.customItemsId ? get(options.customItemsId) : await invoke('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue) : options?.customItemsId ? get(options.customItemsId) : args[1] || [];
2321
2502
  const mapped = items.map(toProtoVisibleItem$1);
2322
2503
  return mapped;
2323
2504
  };
@@ -2325,11 +2506,11 @@ const getPicks$a = async (searchValue, args) => {
2325
2506
  const emptyMatches = [];
2326
2507
 
2327
2508
  const getWorkspacePath = async () => {
2328
- return invoke('Workspace.getPath');
2509
+ return invoke$1('Workspace.getPath');
2329
2510
  };
2330
2511
 
2331
2512
  const searchFile$1 = async (path, value, prepare, assetDir) => {
2332
- const result = await invoke$1('FileSearch.searchFile', path, value, prepare, assetDir);
2513
+ const result = await invoke$2('FileSearch.searchFile', path, value, prepare, assetDir);
2333
2514
  return result;
2334
2515
  };
2335
2516
 
@@ -2529,6 +2710,9 @@ const parseGotoline = value => {
2529
2710
  if (Number.isNaN(wantedLine)) {
2530
2711
  return -1;
2531
2712
  }
2713
+ if (wantedLine < 1) {
2714
+ return -1;
2715
+ }
2532
2716
  return wantedLine;
2533
2717
  };
2534
2718
 
@@ -2614,8 +2798,12 @@ const getPicks$7 = async () => {
2614
2798
  }];
2615
2799
  };
2616
2800
 
2617
- const getRecentlyOpened = () => {
2618
- return invoke(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2801
+ const uniq = array => {
2802
+ return [...new Set(array)];
2803
+ };
2804
+ const getRecentlyOpened = async () => {
2805
+ const recentlyOpened = await invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2806
+ return uniq(recentlyOpened);
2619
2807
  };
2620
2808
 
2621
2809
  const getPath = uri => {
@@ -2694,7 +2882,7 @@ const shouldHide = item => {
2694
2882
  const selectPickBuiltin = async item => {
2695
2883
  const args = item.args || [];
2696
2884
  // TODO ids should be all numbers for efficiency -> also directly can call command
2697
- await invoke(item.id, ...args);
2885
+ await invoke$1(item.id, ...args);
2698
2886
  if (shouldHide(item)) {
2699
2887
  return {
2700
2888
  command: Hide
@@ -2707,13 +2895,16 @@ const selectPickBuiltin = async item => {
2707
2895
  const selectPickExtension = async item => {
2708
2896
  const id = item.id.slice(4); // TODO lots of string allocation with 'ext.' find a better way to separate builtin commands from extension commands
2709
2897
  try {
2710
- await invoke('ExtensionHost.executeCommand', id);
2898
+ await invoke$1('ExtensionHost.executeCommand', id);
2711
2899
  } catch (error) {
2712
2900
  await handleError(error, false);
2713
2901
  await showErrorDialog(error);
2902
+ return {
2903
+ command: Hide
2904
+ };
2714
2905
  }
2715
2906
  return {
2716
- command: Hide
2907
+ command: KeepOpen
2717
2908
  };
2718
2909
  };
2719
2910
  const selectPick$8 = async item => {
@@ -2727,16 +2918,31 @@ const selectPick$8 = async item => {
2727
2918
  return selectPickBuiltin(item);
2728
2919
  };
2729
2920
 
2730
- const state = {
2731
- args: []
2921
+ const getOptions = args => {
2922
+ const last = args.at(-1);
2923
+ if (!last || typeof last !== 'object') {
2924
+ return {};
2925
+ }
2926
+ return last;
2732
2927
  };
2733
-
2734
- const selectPick$7 = async pick => {
2928
+ const selectPick$7 = async (_pick, value) => {
2735
2929
  const {
2736
2930
  args
2737
2931
  } = state;
2932
+ const options = getOptions(args);
2738
2933
  const resolveId = args[2];
2739
- await invoke(`QuickPick.executeCallback`, resolveId, pick);
2934
+ const result = options.mode === 'quickPick' ? _pick.value : {
2935
+ canceled: false,
2936
+ inputValue: value
2937
+ };
2938
+ if (options.callbackOwner === 'quickPickWorker') {
2939
+ if (typeof resolveId !== 'number') {
2940
+ throw new TypeError('expected resolve id to be a number');
2941
+ }
2942
+ executeCallback(resolveId, result);
2943
+ } else {
2944
+ await invoke$1('QuickPick.executeCallback', resolveId, result);
2945
+ }
2740
2946
  return {
2741
2947
  command: Hide
2742
2948
  };
@@ -2760,12 +2966,12 @@ const selectPick$6 = async pick => {
2760
2966
  };
2761
2967
 
2762
2968
  const setCursor = async (rowIndex, columnIndex) => {
2763
- await invoke('Editor.cursorSet', rowIndex, columnIndex);
2969
+ await invoke$1('Editor.cursorSet', rowIndex, columnIndex);
2764
2970
  };
2765
2971
 
2766
2972
  const goToPositionAndFocus = async (rowIndex, columnIndex) => {
2767
2973
  await setCursor(rowIndex, columnIndex);
2768
- await invoke('Editor.handleFocus');
2974
+ await invoke$1('Editor.handleFocus');
2769
2975
  };
2770
2976
 
2771
2977
  const selectPickGoToColumn = async (item, value) => {
@@ -2808,7 +3014,7 @@ const selectPick$4 = async item => {
2808
3014
  };
2809
3015
 
2810
3016
  const openWorkspaceFolder = uri => {
2811
- return invoke(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
3017
+ return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
2812
3018
  };
2813
3019
 
2814
3020
  // TODO selectPick should be independent of show/hide
@@ -2890,6 +3096,11 @@ const getQuickPickSubProviderId = (id, prefix) => {
2890
3096
  }
2891
3097
  };
2892
3098
 
3099
+ const isQuickInput = args => {
3100
+ const options = args.at(-1);
3101
+ return options?.mode === 'quickInput';
3102
+ };
3103
+
2893
3104
  // TODO when user types letters -> no need to query provider again -> just filter existing results
2894
3105
  const setValue = async (state, newValue) => {
2895
3106
  const {
@@ -2913,7 +3124,7 @@ const setValue = async (state, newValue) => {
2913
3124
  assetDir,
2914
3125
  platform
2915
3126
  });
2916
- const filterValue = getFilterValue(providerId, subId, newValue);
3127
+ const filterValue = isQuickInput(args) ? '' : getFilterValue(providerId, subId, newValue);
2917
3128
  const items = filterQuickPickItems(newPicks, filterValue);
2918
3129
  const focusedIndex = items.length === 0 ? -1 : 0;
2919
3130
  const sliced = items.slice(minLineY, maxLineY);
@@ -2921,7 +3132,7 @@ const setValue = async (state, newValue) => {
2921
3132
  icons,
2922
3133
  newFileIconCache
2923
3134
  } = await getQuickPickFileIcons(sliced, fileIconCache);
2924
- const listHeight = getListHeight(items.length, itemHeight, height);
3135
+ const listHeight = getListHeight$1(items.length, itemHeight, height);
2925
3136
  const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
2926
3137
  return {
2927
3138
  ...state,
@@ -2967,7 +3178,27 @@ const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd)
2967
3178
  return handleInput(state, newValue, cursorOffset, User);
2968
3179
  };
2969
3180
 
3181
+ const getCancelResult = args => {
3182
+ const last = args.at(-1);
3183
+ if (last && typeof last === 'object' &&
3184
+ // @ts-ignore
3185
+ last.mode === 'quickPick') {
3186
+ return undefined;
3187
+ }
3188
+ return {
3189
+ canceled: true,
3190
+ inputValue: ''
3191
+ };
3192
+ };
2970
3193
  const handleBlur = async state => {
3194
+ const {
3195
+ args,
3196
+ providerId
3197
+ } = state;
3198
+ if (providerId === Custom$1) {
3199
+ const resolveId = args[2];
3200
+ await invoke$1('QuickPick.executeCallback', resolveId, getCancelResult(args));
3201
+ }
2971
3202
  await closeWidget(state.uid);
2972
3203
  return state;
2973
3204
  };
@@ -2992,6 +3223,17 @@ const getPick = (items, index) => {
2992
3223
  return undefined;
2993
3224
  };
2994
3225
 
3226
+ const createCustomPick = value => {
3227
+ return {
3228
+ description: '',
3229
+ direntType: 0,
3230
+ fileIcon: '',
3231
+ icon: '',
3232
+ label: value,
3233
+ matches: [],
3234
+ uri: ''
3235
+ };
3236
+ };
2995
3237
  const selectIndex = async (state, index, button = /* left */0) => {
2996
3238
  const {
2997
3239
  items,
@@ -3000,12 +3242,12 @@ const selectIndex = async (state, index, button = /* left */0) => {
3000
3242
  value
3001
3243
  } = state;
3002
3244
  const actualIndex = index + minLineY;
3003
- const pick = getPick(items, actualIndex);
3245
+ const prefix = getQuickPickPrefix(value);
3246
+ const subId = getQuickPickSubProviderId(providerId, prefix);
3247
+ const pick = getPick(items, actualIndex) || (subId === Custom$1 ? createCustomPick(value) : undefined);
3004
3248
  if (!pick) {
3005
3249
  return state;
3006
3250
  }
3007
- const prefix = getQuickPickPrefix(value);
3008
- const subId = getQuickPickSubProviderId(providerId, prefix);
3009
3251
  const fn = getSelect(subId);
3010
3252
  const selectPickResult = await fn(pick, value);
3011
3253
  object(selectPickResult);
@@ -3052,11 +3294,12 @@ const handleFocus = async state => {
3052
3294
  const commandMapRef = {};
3053
3295
 
3054
3296
  const handleMessagePort = async port => {
3055
- await create$7({
3297
+ const rpc = await create$8({
3056
3298
  commandMap: commandMapRef,
3057
3299
  isMessagePortOpen: true,
3058
3300
  messagePort: port
3059
3301
  });
3302
+ set(rpc);
3060
3303
  };
3061
3304
 
3062
3305
  const initialize = async () => {
@@ -3104,25 +3347,45 @@ const getQuickPickProviderId = prefix => {
3104
3347
  }
3105
3348
  };
3106
3349
 
3350
+ const callbacks = [];
3351
+ const waitUntilVisible = () => {
3352
+ const {
3353
+ promise,
3354
+ resolve
3355
+ } = Promise.withResolvers();
3356
+ callbacks.push(resolve);
3357
+ return promise;
3358
+ };
3359
+ const notifyVisible = () => {
3360
+ const pendingCallbacks = callbacks.splice(0);
3361
+ for (const callback of pendingCallbacks) {
3362
+ callback();
3363
+ }
3364
+ };
3365
+
3107
3366
  const parseArgs = (subId, args) => {
3108
3367
  if (subId !== Custom$1) {
3109
3368
  return {
3110
3369
  ignoreFocusOut: false,
3111
- initialValue: ''
3370
+ initialValue: '',
3371
+ placeholder: ''
3112
3372
  };
3113
3373
  }
3114
3374
  const last = args.at(-1);
3115
3375
  if (!last || typeof last !== 'object') {
3116
3376
  return {
3117
3377
  ignoreFocusOut: false,
3118
- initialValue: ''
3378
+ initialValue: '',
3379
+ placeholder: ''
3119
3380
  };
3120
3381
  }
3121
3382
  return {
3122
3383
  // @ts-ignore
3123
3384
  ignoreFocusOut: Boolean(last.ignoreFocusOut),
3124
3385
  // @ts-ignore
3125
- initialValue: String(last.initialValue)
3386
+ initialValue: last.initialValue ? String(last.initialValue) : '',
3387
+ // @ts-ignore
3388
+ placeholder: last.placeholder ? String(last.placeholder) : ''
3126
3389
  };
3127
3390
  };
3128
3391
  const loadContent = async state => {
@@ -3154,10 +3417,11 @@ const loadContent = async state => {
3154
3417
  icons,
3155
3418
  newFileIconCache
3156
3419
  } = await getQuickPickFileIcons(sliced, fileIconCache);
3157
- const listHeight = getListHeight(items.length, itemHeight, height);
3420
+ const listHeight = getListHeight$1(items.length, itemHeight, height);
3158
3421
  const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, items.length);
3159
3422
  const parsedArgs = parseArgs(subId, args);
3160
3423
  const finalValue = parsedArgs.initialValue || value;
3424
+ notifyVisible();
3161
3425
  return {
3162
3426
  ...state,
3163
3427
  args,
@@ -3173,20 +3437,13 @@ const loadContent = async state => {
3173
3437
  maxLineY,
3174
3438
  minLineY,
3175
3439
  picks: newPicks,
3176
- placeholder: '',
3440
+ placeholder: parsedArgs.placeholder,
3177
3441
  providerId: id,
3178
3442
  state: Finished,
3179
3443
  value: finalValue
3180
3444
  };
3181
3445
  };
3182
3446
 
3183
- const callbacks = Object.create(null);
3184
- const executeCallback = id => {
3185
- const fn = callbacks[id];
3186
- delete callbacks[id];
3187
- fn();
3188
- };
3189
-
3190
3447
  const SetCursorOffset = 'setCursorOffset';
3191
3448
  const SetFocusedIndex = 'setFocusedIndex';
3192
3449
  const SetItemsHeight = 'setItemsHeight';
@@ -3535,13 +3792,6 @@ const getVisible$1 = (items, minLineY, maxLineY, icons) => {
3535
3792
  return protoVisibleItems;
3536
3793
  };
3537
3794
 
3538
- const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
3539
- if (size >= contentSize) {
3540
- return 0;
3541
- }
3542
- return Math.max(Math.round(size ** 2 / contentSize), minimumSliderSize);
3543
- };
3544
-
3545
3795
  const emptyHighlightSections = [];
3546
3796
 
3547
3797
  const getHighlightSections = (highlights, label) => {
@@ -3578,13 +3828,14 @@ const getHighlightSections = (highlights, label) => {
3578
3828
  };
3579
3829
 
3580
3830
  const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
3831
+ const visibleFocusedIndex = focusedIndex - minLineY;
3581
3832
  const visibleItems = protoVisibleItems.map((visibleItem, i) => {
3582
3833
  const highlights = visibleItem.matches.slice(1);
3583
3834
  const sections = getHighlightSections(highlights, visibleItem.label);
3584
3835
  return {
3585
3836
  ...visibleItem,
3586
3837
  highlights: sections,
3587
- isActive: i === focusedIndex,
3838
+ isActive: i === visibleFocusedIndex,
3588
3839
  posInSet: minLineY + i + 1,
3589
3840
  setSize
3590
3841
  };
@@ -3592,15 +3843,6 @@ const getVisible = (setSize, protoVisibleItems, minLineY, focusedIndex) => {
3592
3843
  return visibleItems;
3593
3844
  };
3594
3845
 
3595
- const getScrollBarOffset = (delta, finalDelta, size, scrollBarSize) => {
3596
- if (finalDelta <= 0) {
3597
- return 0;
3598
- }
3599
- const scrollBarOffset = delta / finalDelta * (size - scrollBarSize);
3600
- return scrollBarOffset;
3601
- };
3602
- const getScrollBarY = getScrollBarOffset;
3603
-
3604
3846
  const createQuickPickViewModel = (oldState, newState) => {
3605
3847
  const {
3606
3848
  cursorOffset,
@@ -3624,7 +3866,7 @@ const createQuickPickViewModel = (oldState, newState) => {
3624
3866
  const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
3625
3867
  const newFocusedIndex = focusedIndex - minLineY;
3626
3868
  const itemCount = items.length;
3627
- const listHeight = getListHeight(itemCount, itemHeight, height);
3869
+ const listHeight = getListHeight$1(itemCount, itemHeight, height);
3628
3870
  const contentHeight = itemCount * itemHeight;
3629
3871
  const scrollBarHeight = getScrollBarSize(listHeight, contentHeight, minimumSliderSize);
3630
3872
  const scrollBarY = getScrollBarY(deltaY, finalDeltaY, height - headerHeight, scrollBarHeight);
@@ -3655,7 +3897,7 @@ const Label = 'Label';
3655
3897
  const List = 'List';
3656
3898
  const ListItems = 'ListItems';
3657
3899
  const MaskIcon = 'MaskIcon';
3658
- const QuickPick$1 = 'QuickPick';
3900
+ const QuickPick$2 = 'QuickPick';
3659
3901
  const QuickPickHeader = 'QuickPickHeader';
3660
3902
  const QuickPickHighlight = 'QuickPickHighlight';
3661
3903
  const QuickPickItem = 'QuickPickItem';
@@ -3679,11 +3921,11 @@ const HandleScrollbarPointerDown = 'handleScrollbarPointerDown';
3679
3921
  const HandleScrollbarPointerMove = 'handleScrollbarPointerMove';
3680
3922
  const HandleScrollbarPointerUp = 'handleScrollbarPointerUp';
3681
3923
 
3682
- const QuickPick = 'QuickPick';
3924
+ const QuickPick$1 = 'QuickPick';
3683
3925
  const QuickPickItems = 'QuickPickItems';
3684
3926
  const QuickPickItemActive = 'QuickPickItemActive';
3685
3927
 
3686
- const getQuickPickInputVirtualDom = () => {
3928
+ const getQuickPickInputVirtualDom = (placeholder = '') => {
3687
3929
  const ariaLabel = typeNameofCommandToRun();
3688
3930
  return {
3689
3931
  ariaAutoComplete: 'list',
@@ -3699,18 +3941,19 @@ const getQuickPickInputVirtualDom = () => {
3699
3941
  onBlur: HandleBlur,
3700
3942
  onFocus: HandleFocus,
3701
3943
  onInput: HandleInput,
3944
+ placeholder,
3702
3945
  role: ComboBox,
3703
3946
  spellcheck: false,
3704
3947
  type: Input
3705
3948
  };
3706
3949
  };
3707
3950
 
3708
- const getQuickPickHeaderVirtualDom = () => {
3951
+ const getQuickPickHeaderVirtualDom = (placeholder = '') => {
3709
3952
  return [{
3710
3953
  childCount: 1,
3711
3954
  className: QuickPickHeader,
3712
3955
  type: Div
3713
- }, getQuickPickInputVirtualDom()];
3956
+ }, getQuickPickInputVirtualDom(placeholder)];
3714
3957
  };
3715
3958
 
3716
3959
  const getFileIconVirtualDom = icon => {
@@ -3832,6 +4075,7 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
3832
4075
  return [{
3833
4076
  childCount: 1,
3834
4077
  className: mergeClassNames(ScrollBar, ScrollBarSmall),
4078
+ onPointerDown: HandleScrollbarPointerDown,
3835
4079
  type: Div
3836
4080
  }, {
3837
4081
  childCount: 0,
@@ -3859,7 +4103,7 @@ const getRootNodeCount = nodes => {
3859
4103
  }
3860
4104
  return count;
3861
4105
  };
3862
- const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) => {
4106
+ const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop, placeholder = '') => {
3863
4107
  const quickOpen$1 = quickOpen();
3864
4108
  const shouldShowScrollbar = scrollBarHeight > 0;
3865
4109
  const quickPickItemsDom = getQuickPickItemsVirtualDom(visibleItems);
@@ -3867,10 +4111,10 @@ const getQuickPickVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) =>
3867
4111
  return [{
3868
4112
  ariaLabel: quickOpen$1,
3869
4113
  childCount: 2,
3870
- className: mergeClassNames(Viewlet, QuickPick$1),
3871
- id: QuickPick,
4114
+ className: mergeClassNames(Viewlet, QuickPick$2),
4115
+ id: QuickPick$1,
3872
4116
  type: Div
3873
- }, ...getQuickPickHeaderVirtualDom(), {
4117
+ }, ...getQuickPickHeaderVirtualDom(placeholder), {
3874
4118
  ariaActivedescendant: QuickPickItemActive,
3875
4119
  childCount: shouldShowScrollbar ? 2 : 1,
3876
4120
  className: mergeClassNames(List, ContainContent),
@@ -3896,7 +4140,7 @@ const renderItemsDom = state => {
3896
4140
  scrollBarTop,
3897
4141
  visibleItems
3898
4142
  } = viewModel;
3899
- return getQuickPickVirtualDom(visibleItems, scrollBarHeight, scrollBarTop);
4143
+ return getQuickPickVirtualDom(visibleItems, scrollBarHeight, scrollBarTop, state.placeholder);
3900
4144
  };
3901
4145
  const renderItems = (_oldState, newState) => {
3902
4146
  const dom = renderItemsDom(newState);
@@ -3954,11 +4198,11 @@ const render2 = (uid, diffResult) => {
3954
4198
  const {
3955
4199
  newState,
3956
4200
  oldState
3957
- } = get(uid);
4201
+ } = get$1(uid);
3958
4202
  if (oldState === newState) {
3959
4203
  return [];
3960
4204
  }
3961
- set(uid, newState, newState);
4205
+ set$1(uid, newState, newState);
3962
4206
  const commands = applyRender(oldState, newState, diffResult);
3963
4207
  return commands;
3964
4208
  };
@@ -4025,26 +4269,62 @@ const selectItem = async (state, label) => {
4025
4269
  };
4026
4270
 
4027
4271
  const showQuickInput = async ({
4272
+ id,
4028
4273
  ignoreFocusOut,
4274
+ initialItems = [],
4029
4275
  initialValue,
4030
4276
  waitUntil
4031
4277
  }) => {
4032
- // TODO ask renderer worker to create quickpick instance, with given options
4278
+ const customItemsId = add(initialItems);
4033
4279
  const picks = [];
4034
- // const id=QuickPickCallbacks.registerCallback()
4035
- await invoke('QuickPick.showCustom', picks, {
4036
- ignoreFocusOut,
4037
- initialValue,
4038
- waitUntil
4039
- });
4040
- return {
4041
- canceled: false,
4042
- inputValue: ''
4043
- };
4280
+ try {
4281
+ const result = await invoke$1('QuickPick.showCustom', picks, {
4282
+ customItemsId,
4283
+ ignoreFocusOut,
4284
+ initialValue,
4285
+ mode: 'quickInput',
4286
+ quickInputId: id,
4287
+ waitUntil
4288
+ });
4289
+ return result ?? {
4290
+ canceled: true,
4291
+ inputValue: ''
4292
+ };
4293
+ } finally {
4294
+ remove(customItemsId);
4295
+ }
4296
+ };
4297
+
4298
+ const QuickPick = 'QuickPick';
4299
+
4300
+ const showQuickPick = async ({
4301
+ items,
4302
+ placeholder = '',
4303
+ waitUntil = 'selected'
4304
+ }) => {
4305
+ const customItemsId = add(items);
4306
+ const {
4307
+ id,
4308
+ promise
4309
+ } = registerCallback();
4310
+ try {
4311
+ await invoke$1('Viewlet.openWidget', QuickPick, 'custom', [], id, {
4312
+ callbackOwner: 'quickPickWorker',
4313
+ customItemsId,
4314
+ mode: 'quickPick',
4315
+ placeholder
4316
+ });
4317
+ if (waitUntil === 'visible') {
4318
+ return undefined;
4319
+ }
4320
+ return await promise;
4321
+ } finally {
4322
+ remove(customItemsId);
4323
+ }
4044
4324
  };
4045
4325
 
4046
4326
  const commandMap = {
4047
- 'QuickPick.addMenuEntries': add,
4327
+ 'QuickPick.addMenuEntries': add$1,
4048
4328
  'QuickPick.close': close,
4049
4329
  'QuickPick.create2': create,
4050
4330
  'QuickPick.diff2': diff2,
@@ -4063,6 +4343,9 @@ const commandMap = {
4063
4343
  'QuickPick.handleFocus': wrapCommand(handleFocus),
4064
4344
  'QuickPick.handleInput': wrapCommand(handleInput),
4065
4345
  'QuickPick.handleMessagePort': handleMessagePort,
4346
+ 'QuickPick.handleScrollBarPointerDown': wrapCommand(handleScrollBarPointerDown),
4347
+ 'QuickPick.handleScrollBarPointerMove': wrapCommand(handleScrollBarPointerMove),
4348
+ 'QuickPick.handleScrollBarPointerUp': wrapCommand(handleScrollBarPointerUp),
4066
4349
  'QuickPick.handleWheel': wrapCommand(handleWheel),
4067
4350
  'QuickPick.initialize': initialize,
4068
4351
  'QuickPick.loadContent': wrapCommand(loadContent),
@@ -4073,34 +4356,36 @@ const commandMap = {
4073
4356
  'QuickPick.selectItem': wrapCommand(selectItem),
4074
4357
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
4075
4358
  'QuickPick.setValue': wrapCommand(setValue),
4076
- 'QuickPick.showQuickInput': showQuickInput
4359
+ 'QuickPick.showQuickInput': showQuickInput,
4360
+ 'QuickPick.showQuickPick': showQuickPick,
4361
+ 'QuickPick.waitUntilVisible': waitUntilVisible
4077
4362
  };
4078
4363
 
4079
4364
  const initializeEditorWorker = async () => {
4080
- const rpc = await create$5({
4365
+ const rpc = await create$6({
4081
4366
  commandMap: {},
4082
4367
  async send(port) {
4083
4368
  await sendMessagePortToEditorWorker(port, 0);
4084
4369
  }
4085
4370
  });
4086
- set$3(rpc);
4371
+ set$4(rpc);
4087
4372
  };
4088
4373
 
4089
4374
  const initializeFileSearchWorker = async () => {
4090
- const rpc = await create$5({
4375
+ const rpc = await create$6({
4091
4376
  commandMap: {},
4092
4377
  async send(port) {
4093
4378
  await sendMessagePortToFileSearchWorker2(port, 0);
4094
4379
  }
4095
4380
  });
4096
- set$2(rpc);
4381
+ set$3(rpc);
4097
4382
  };
4098
4383
 
4099
4384
  const initializeRendererWorker = async () => {
4100
- const rpc = await create$4({
4385
+ const rpc = await create$5({
4101
4386
  commandMap: commandMap
4102
4387
  });
4103
- set$1(rpc);
4388
+ set$2(rpc);
4104
4389
  };
4105
4390
 
4106
4391
  const listen = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/quick-pick-worker",
3
- "version": "3.3.0",
3
+ "version": "4.1.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/lvce-editor/quick-pick-worker.git"