@lvce-editor/file-search-worker 4.6.0 → 5.0.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.
@@ -445,7 +445,7 @@ const callbacks = Object.create(null);
445
445
  const set$2 = (id, fn) => {
446
446
  callbacks[id] = fn;
447
447
  };
448
- const get$2 = id => {
448
+ const get$3 = id => {
449
449
  return callbacks[id];
450
450
  };
451
451
  const remove$1 = id => {
@@ -618,7 +618,7 @@ const warn$1 = (...args) => {
618
618
  console.warn(...args);
619
619
  };
620
620
  const resolve = (id, response) => {
621
- const fn = get$2(id);
621
+ const fn = get$3(id);
622
622
  if (!fn) {
623
623
  console.log(response);
624
624
  warn$1(`callback ${id} may already be disposed`);
@@ -864,12 +864,12 @@ const rpcs = Object.create(null);
864
864
  const set$1 = (id, rpc) => {
865
865
  rpcs[id] = rpc;
866
866
  };
867
- const get$1 = id => {
867
+ const get$2 = id => {
868
868
  return rpcs[id];
869
869
  };
870
870
 
871
871
  const invoke$1 = (method, ...params) => {
872
- const rpc = get$1(RendererWorker);
872
+ const rpc = get$2(RendererWorker);
873
873
  // @ts-ignore
874
874
  return rpc.invoke(method, ...params);
875
875
  };
@@ -934,14 +934,14 @@ const warn = (...args) => {
934
934
  console.warn(...args);
935
935
  };
936
936
 
937
- const state$9 = {
937
+ const state$8 = {
938
938
  menuEntries: []
939
939
  };
940
940
  const getAll = () => {
941
- return state$9.menuEntries;
941
+ return state$8.menuEntries;
942
942
  };
943
943
  const add = menuEntries => {
944
- state$9.menuEntries = [...state$9.menuEntries, ...menuEntries];
944
+ state$8.menuEntries = [...state$8.menuEntries, ...menuEntries];
945
945
  };
946
946
 
947
947
  const Hide = 'hide';
@@ -1009,14 +1009,14 @@ const quickOpen = () => {
1009
1009
  return i18nString(QuickOpen);
1010
1010
  };
1011
1011
 
1012
- const name$b = 'command';
1013
- const getPlaceholder$b = () => {
1012
+ const name$a = 'command';
1013
+ const getPlaceholder$a = () => {
1014
1014
  return typeNameofCommandToRun();
1015
1015
  };
1016
1016
  const getLabel$5 = () => {
1017
1017
  return '';
1018
1018
  };
1019
- const getNoResults$b = () => {
1019
+ const getNoResults$a = () => {
1020
1020
  return {
1021
1021
  label: noMatchingResults()
1022
1022
  };
@@ -1057,12 +1057,25 @@ const getExtensionPicks = async () => {
1057
1057
 
1058
1058
  // TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
1059
1059
 
1060
- const getPicks$b = async () => {
1060
+ const getPicks$a = async () => {
1061
1061
  const builtinPicks = await getBuiltinPicks();
1062
1062
  const extensionPicks = await getExtensionPicks();
1063
1063
  const allPicks = [...builtinPicks, ...extensionPicks];
1064
1064
  return allPicks;
1065
1065
  };
1066
+ const getVisibleItems$a = async (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
1067
+ const visibleItems = picks.map((pick, index) => ({
1068
+ description: pick.description || '',
1069
+ fileIcon: '',
1070
+ icon: getPickIcon$7(),
1071
+ isActive: index + minLineY === focusedIndex,
1072
+ label: getPickLabel$7(pick),
1073
+ matches: [],
1074
+ posInSet: index + minLineY + 1,
1075
+ setSize
1076
+ }));
1077
+ return visibleItems;
1078
+ };
1066
1079
  const shouldHide = item => {
1067
1080
  if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
1068
1081
  return false;
@@ -1094,37 +1107,38 @@ const selectPickExtension = async item => {
1094
1107
  command: Hide
1095
1108
  };
1096
1109
  };
1097
- const selectPick$b = async item => {
1110
+ const selectPick$a = async item => {
1098
1111
  if (item.id.startsWith('ext.')) {
1099
1112
  return selectPickExtension(item);
1100
1113
  }
1101
1114
  return selectPickBuiltin(item);
1102
1115
  };
1103
- const getFilterValue$b = value => {
1116
+ const getFilterValue$a = value => {
1104
1117
  return value.trim();
1105
1118
  };
1106
- const getPickFilterValue$9 = pick => {
1119
+ const getPickFilterValue$8 = pick => {
1107
1120
  return pick.label;
1108
1121
  };
1109
- const getPickLabel$8 = pick => {
1122
+ const getPickLabel$7 = pick => {
1110
1123
  return pick.label;
1111
1124
  };
1112
- const getPickIcon$8 = () => {
1125
+ const getPickIcon$7 = () => {
1113
1126
  return '';
1114
1127
  };
1115
1128
 
1116
1129
  const QuickPickEntriesCommand = {
1117
1130
  __proto__: null,
1118
- getFilterValue: getFilterValue$b,
1131
+ getFilterValue: getFilterValue$a,
1119
1132
  getLabel: getLabel$5,
1120
- getNoResults: getNoResults$b,
1121
- getPickFilterValue: getPickFilterValue$9,
1122
- getPickIcon: getPickIcon$8,
1123
- getPickLabel: getPickLabel$8,
1124
- getPicks: getPicks$b,
1125
- getPlaceholder: getPlaceholder$b,
1126
- name: name$b,
1127
- selectPick: selectPick$b
1133
+ getNoResults: getNoResults$a,
1134
+ getPickFilterValue: getPickFilterValue$8,
1135
+ getPickIcon: getPickIcon$7,
1136
+ getPickLabel: getPickLabel$7,
1137
+ getPicks: getPicks$a,
1138
+ getPlaceholder: getPlaceholder$a,
1139
+ getVisibleItems: getVisibleItems$a,
1140
+ name: name$a,
1141
+ selectPick: selectPick$a
1128
1142
  };
1129
1143
 
1130
1144
  const Directory = 3;
@@ -1139,16 +1153,20 @@ const getProtocol = uri => {
1139
1153
  return '';
1140
1154
  };
1141
1155
 
1156
+ const getWorkspacePath = async () => {
1157
+ return invoke$1('Workspace.getPath');
1158
+ };
1159
+
1142
1160
  const openUri = async uri => {
1143
1161
  await invoke$1(/* Main.openUri */'Main.openUri', /* uri */uri);
1144
1162
  };
1145
1163
 
1146
- const state$8 = Object.create(null);
1164
+ const state$7 = Object.create(null);
1147
1165
  const register$1 = modules => {
1148
- Object.assign(state$8, modules);
1166
+ Object.assign(state$7, modules);
1149
1167
  };
1150
1168
  const getModule = protocol => {
1151
- return state$8[protocol];
1169
+ return state$7[protocol];
1152
1170
  };
1153
1171
 
1154
1172
  const searchFile$5 = async (path, value, prepare, assetDir) => {
@@ -1180,63 +1198,62 @@ const searchFile$4 = async (path, value) => {
1180
1198
  const files = await searchFile$5(/* path */path, /* searchTerm */value, prepare);
1181
1199
  return files;
1182
1200
  };
1183
- const name$a = 'file';
1184
- const getPlaceholder$a = () => {
1201
+ const name$9 = 'file';
1202
+ const getPlaceholder$9 = () => {
1185
1203
  return '';
1186
1204
  };
1187
1205
  const getLabel$4 = () => {
1188
1206
  return files();
1189
1207
  };
1190
- const getNoResults$a = () => {
1208
+ const getNoResults$9 = () => {
1191
1209
  return {
1192
1210
  label: noMatchingResults()
1193
1211
  };
1194
1212
  };
1195
- const getPicks$a = async searchValue => {
1213
+ const getPicks$9 = async searchValue => {
1196
1214
  // TODO cache workspace path
1197
- const workspace = await invoke$1('Workspace.getPath');
1215
+ const workspace = await getWorkspacePath();
1198
1216
  if (!workspace) {
1199
1217
  return [];
1200
1218
  }
1201
1219
  const files = await searchFile$4(workspace, searchValue);
1202
- // const picks = files.map(toPick)
1203
1220
  return files;
1204
1221
  };
1205
- const selectPick$a = async pick => {
1222
+ const selectPick$9 = async pick => {
1206
1223
  if (typeof pick === 'object') {
1207
1224
  pick = pick.pick;
1208
1225
  }
1209
- const workspace = await invoke$1('Workspace.getPath');
1226
+ const workspace = await getWorkspacePath();
1210
1227
  const absolutePath = `${workspace}/${pick}`;
1211
1228
  await openUri(absolutePath);
1212
1229
  return {
1213
1230
  command: Hide
1214
1231
  };
1215
1232
  };
1216
- const getFilterValue$a = value => {
1233
+ const getFilterValue$9 = value => {
1217
1234
  return value;
1218
1235
  };
1219
- const getPickFilterValue$8 = pick => {
1236
+ const getPickFilterValue$7 = pick => {
1220
1237
  if (typeof pick === 'object') {
1221
1238
  pick = pick.pick;
1222
1239
  }
1223
1240
  return pick;
1224
1241
  };
1225
- const getPickLabel$7 = pick => {
1242
+ const getPickLabel$6 = pick => {
1226
1243
  if (typeof pick === 'object') {
1227
1244
  pick = pick.pick;
1228
1245
  }
1229
1246
  const baseName = pathBaseName(pick);
1230
1247
  return baseName;
1231
1248
  };
1232
- const getPickDescription$8 = pick => {
1249
+ const getPickDescription$6 = pick => {
1233
1250
  if (typeof pick === 'object') {
1234
1251
  pick = pick.pick;
1235
1252
  }
1236
1253
  const dirName = pathDirName(pick);
1237
1254
  return dirName;
1238
1255
  };
1239
- const getPickIcon$7 = () => {
1256
+ const getPickIcon$6 = () => {
1240
1257
  return '';
1241
1258
  };
1242
1259
  const getPickFileIcon$2 = pick => {
@@ -1249,48 +1266,70 @@ const getPickFileIcon$2 = pick => {
1249
1266
  const baseName = pathBaseName(pick);
1250
1267
  return {
1251
1268
  type: File$2,
1252
- name: baseName
1269
+ name: baseName,
1270
+ path: pick
1253
1271
  };
1254
1272
  };
1255
- const isPrepared$7 = () => {
1273
+ const isPrepared$6 = () => {
1256
1274
  const workspace = '';
1257
1275
  // TODO protocol should always be defined. For files it should use file protocol
1258
1276
  const protocol = getProtocol(workspace);
1259
1277
  return !protocol;
1260
1278
  };
1279
+ const getVisibleItems$9 = (files, minLineY, maxLineY, focusedIndex, setSize, icons) => {
1280
+ const visibleItems = files.map((item, i) => {
1281
+ const pick = item.pick;
1282
+ const label = getPickLabel$6(pick);
1283
+ const description = getPickDescription$6(pick);
1284
+ const icon = getPickIcon$6();
1285
+ const fileIcon = icons[i];
1286
+ return {
1287
+ label,
1288
+ description,
1289
+ icon,
1290
+ fileIcon,
1291
+ posInSet: minLineY + i + 1,
1292
+ setSize,
1293
+ isActive: i === focusedIndex,
1294
+ matches: item.matches
1295
+ };
1296
+ });
1297
+ return visibleItems;
1298
+ };
1261
1299
 
1262
1300
  const QuickPickEntriesFile = {
1263
1301
  __proto__: null,
1264
- getFilterValue: getFilterValue$a,
1302
+ getFilterValue: getFilterValue$9,
1265
1303
  getLabel: getLabel$4,
1266
- getNoResults: getNoResults$a,
1267
- getPickDescription: getPickDescription$8,
1304
+ getNoResults: getNoResults$9,
1305
+ getPickDescription: getPickDescription$6,
1268
1306
  getPickFileIcon: getPickFileIcon$2,
1269
- getPickFilterValue: getPickFilterValue$8,
1270
- getPickIcon: getPickIcon$7,
1271
- getPickLabel: getPickLabel$7,
1272
- getPicks: getPicks$a,
1273
- getPlaceholder: getPlaceholder$a,
1274
- isPrepared: isPrepared$7,
1275
- name: name$a,
1276
- selectPick: selectPick$a
1307
+ getPickFilterValue: getPickFilterValue$7,
1308
+ getPickIcon: getPickIcon$6,
1309
+ getPickLabel: getPickLabel$6,
1310
+ getPicks: getPicks$9,
1311
+ getPlaceholder: getPlaceholder$9,
1312
+ getVisibleItems: getVisibleItems$9,
1313
+ isPrepared: isPrepared$6,
1314
+ name: name$9,
1315
+ selectPick: selectPick$9
1277
1316
  };
1278
1317
 
1279
1318
  const execute = async (method, ...params) => {
1280
1319
  // TODO
1281
1320
  };
1282
1321
 
1283
- const name$9 = 'goToLine';
1284
- const getPlaceholder$9 = () => {
1322
+ const name$8 = 'goToLine';
1323
+ const getPlaceholder$8 = () => {
1285
1324
  return '';
1286
1325
  };
1287
1326
  const getHelpEntries$3 = () => {
1288
1327
  return [];
1289
1328
  };
1290
- const getNoResults$9 = () => {
1329
+ const getNoResults$8 = () => {
1291
1330
  return undefined;
1292
1331
  };
1293
- const getPicks$9 = async () => {
1332
+ const getPicks$8 = async () => {
1294
1333
  const picks = [{
1295
1334
  label: '1'
1296
1335
  }, {
@@ -1306,7 +1345,7 @@ const getPicks$9 = async () => {
1306
1345
  }];
1307
1346
  return picks;
1308
1347
  };
1309
- const selectPick$9 = async item => {
1348
+ const selectPick$8 = async item => {
1310
1349
  const rowIndex = Number.parseInt(item.label);
1311
1350
  const position = {
1312
1351
  rowIndex,
@@ -1318,166 +1357,212 @@ const selectPick$9 = async item => {
1318
1357
  command: Hide
1319
1358
  };
1320
1359
  };
1321
- const getFilterValue$9 = value => {
1360
+ const getFilterValue$8 = value => {
1322
1361
  return value;
1323
1362
  };
1363
+ const getVisibleItems$8 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
1364
+ const visibleItems = picks.map((pick, index) => ({
1365
+ description: '',
1366
+ fileIcon: '',
1367
+ icon: '',
1368
+ isActive: index + minLineY === focusedIndex,
1369
+ label: pick.label,
1370
+ matches: [],
1371
+ posInSet: index + minLineY + 1,
1372
+ setSize
1373
+ }));
1374
+ return visibleItems;
1375
+ };
1324
1376
 
1325
1377
  const QuickPickEntriesGoToLine = {
1326
1378
  __proto__: null,
1327
- getFilterValue: getFilterValue$9,
1379
+ getFilterValue: getFilterValue$8,
1328
1380
  getHelpEntries: getHelpEntries$3,
1329
- getNoResults: getNoResults$9,
1330
- getPicks: getPicks$9,
1331
- getPlaceholder: getPlaceholder$9,
1332
- name: name$9,
1333
- selectPick: selectPick$9
1381
+ getNoResults: getNoResults$8,
1382
+ getPicks: getPicks$8,
1383
+ getPlaceholder: getPlaceholder$8,
1384
+ getVisibleItems: getVisibleItems$8,
1385
+ name: name$8,
1386
+ selectPick: selectPick$8
1334
1387
  };
1335
1388
 
1336
- const name$8 = 'symbol';
1337
- const getPlaceholder$8 = () => {
1389
+ const name$7 = 'symbol';
1390
+ const getPlaceholder$7 = () => {
1338
1391
  return '';
1339
1392
  };
1340
- const getNoResults$8 = () => {
1393
+ const getNoResults$7 = () => {
1341
1394
  return {
1342
1395
  label: noSymbolFound()
1343
1396
  };
1344
1397
  };
1345
- const getPicks$8 = async () => {
1398
+ const getPicks$7 = async () => {
1346
1399
  const picks = [];
1347
1400
  return picks;
1348
1401
  };
1349
- const selectPick$8 = async item => {
1402
+ const getVisibleItems$7 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
1403
+ return [];
1404
+ };
1405
+ const selectPick$7 = async item => {
1350
1406
  return {
1351
1407
  command: Hide
1352
1408
  };
1353
1409
  };
1354
- const getFilterValue$8 = value => {
1410
+ const getFilterValue$7 = value => {
1355
1411
  return value;
1356
1412
  };
1357
- const state$7 = {};
1358
- const getPickDescription$7 = value => {
1413
+ const state$6 = {};
1414
+ const getPickDescription$5 = value => {
1359
1415
  return '';
1360
1416
  };
1361
- const isPrepared$6 = () => {
1417
+ const isPrepared$5 = () => {
1362
1418
  return false;
1363
1419
  };
1364
- const getPickFilterValue$7 = value => {
1420
+ const getPickFilterValue$6 = value => {
1365
1421
  return value;
1366
1422
  };
1367
- const getPickLabel$6 = value => {
1423
+ const getPickLabel$5 = value => {
1368
1424
  return value;
1369
1425
  };
1370
- const getPickIcon$6 = value => {
1426
+ const getPickIcon$5 = value => {
1371
1427
  return '';
1372
1428
  };
1373
1429
 
1374
1430
  const QuickPickEntriesSymbol = {
1375
1431
  __proto__: null,
1376
- getFilterValue: getFilterValue$8,
1377
- getNoResults: getNoResults$8,
1378
- getPickDescription: getPickDescription$7,
1379
- getPickFilterValue: getPickFilterValue$7,
1380
- getPickIcon: getPickIcon$6,
1381
- getPickLabel: getPickLabel$6,
1382
- getPicks: getPicks$8,
1383
- getPlaceholder: getPlaceholder$8,
1384
- isPrepared: isPrepared$6,
1385
- name: name$8,
1386
- selectPick: selectPick$8,
1387
- state: state$7
1432
+ getFilterValue: getFilterValue$7,
1433
+ getNoResults: getNoResults$7,
1434
+ getPickDescription: getPickDescription$5,
1435
+ getPickFilterValue: getPickFilterValue$6,
1436
+ getPickIcon: getPickIcon$5,
1437
+ getPickLabel: getPickLabel$5,
1438
+ getPicks: getPicks$7,
1439
+ getPlaceholder: getPlaceholder$7,
1440
+ getVisibleItems: getVisibleItems$7,
1441
+ isPrepared: isPrepared$5,
1442
+ name: name$7,
1443
+ selectPick: selectPick$7,
1444
+ state: state$6
1388
1445
  };
1389
1446
 
1390
1447
  // TODO probably not needed
1391
1448
 
1392
- const getPlaceholder$7 = () => {
1449
+ const getPlaceholder$6 = () => {
1393
1450
  return typeNameofCommandToRun();
1394
1451
  };
1395
1452
  const getHelpEntries$2 = () => {
1396
1453
  return undefined;
1397
1454
  };
1398
- const getPicks$7 = async () => {
1455
+ const getPicks$6 = async () => {
1399
1456
  // const views = ViewService.getViews()
1400
1457
  // const picks = views.map(toPick)
1401
1458
  // return picks
1402
1459
  return [];
1403
1460
  };
1404
- const selectPick$7 = async item => {
1461
+ const selectPick$6 = async item => {
1405
1462
  // Command.execute(/* openView */ 549, /* viewName */ item.label)
1406
1463
  // return {
1407
1464
  // command: QuickPickReturnValue.Hide,
1408
1465
  // }
1409
1466
  };
1410
- const getFilterValue$7 = value => {
1467
+ const getFilterValue$6 = value => {
1411
1468
  return value;
1412
1469
  };
1413
- const getPickFilterValue$6 = value => {
1470
+ const getPickFilterValue$5 = value => {
1414
1471
  return value;
1415
1472
  };
1416
- const getPickLabel$5 = value => {
1473
+ const getPickLabel$4 = value => {
1417
1474
  return value;
1418
1475
  };
1419
- const getPickIcon$5 = value => {
1476
+ const getPickIcon$4 = value => {
1420
1477
  return '';
1421
1478
  };
1422
- const state$6 = {};
1423
- const getNoResults$7 = () => {
1479
+ const state$5 = {};
1480
+ const getNoResults$6 = () => {
1424
1481
  return '';
1425
1482
  };
1426
- const name$7 = '';
1427
- const isPrepared$5 = () => {
1483
+ const name$6 = '';
1484
+ const isPrepared$4 = () => {
1428
1485
  return true;
1429
1486
  };
1430
- const getPickDescription$6 = () => {
1487
+ const getPickDescription$4 = () => {
1431
1488
  return '';
1432
1489
  };
1490
+ const getVisibleItems$6 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
1491
+ const visibleItems = picks.map((pick, index) => ({
1492
+ description: getPickDescription$4(),
1493
+ fileIcon: '',
1494
+ icon: getPickIcon$4(),
1495
+ isActive: index + minLineY === focusedIndex,
1496
+ label: getPickLabel$4(pick),
1497
+ matches: [],
1498
+ posInSet: index + minLineY + 1,
1499
+ setSize
1500
+ }));
1501
+ return visibleItems;
1502
+ };
1433
1503
 
1434
1504
  const QuickPickEntriesView = {
1435
1505
  __proto__: null,
1436
- getFilterValue: getFilterValue$7,
1506
+ getFilterValue: getFilterValue$6,
1437
1507
  getHelpEntries: getHelpEntries$2,
1438
- getNoResults: getNoResults$7,
1439
- getPickDescription: getPickDescription$6,
1440
- getPickFilterValue: getPickFilterValue$6,
1441
- getPickIcon: getPickIcon$5,
1442
- getPickLabel: getPickLabel$5,
1443
- getPicks: getPicks$7,
1444
- getPlaceholder: getPlaceholder$7,
1445
- isPrepared: isPrepared$5,
1446
- name: name$7,
1447
- selectPick: selectPick$7,
1448
- state: state$6
1508
+ getNoResults: getNoResults$6,
1509
+ getPickDescription: getPickDescription$4,
1510
+ getPickFilterValue: getPickFilterValue$5,
1511
+ getPickIcon: getPickIcon$4,
1512
+ getPickLabel: getPickLabel$4,
1513
+ getPicks: getPicks$6,
1514
+ getPlaceholder: getPlaceholder$6,
1515
+ getVisibleItems: getVisibleItems$6,
1516
+ isPrepared: isPrepared$4,
1517
+ name: name$6,
1518
+ selectPick: selectPick$6,
1519
+ state: state$5
1449
1520
  };
1450
1521
 
1451
- const name$6 = 'workspace-symbol';
1452
- const getPlaceholder$6 = () => {
1522
+ const name$5 = 'workspace-symbol';
1523
+ const getPlaceholder$5 = () => {
1453
1524
  return '';
1454
1525
  };
1455
- const getNoResults$6 = () => {
1526
+ const getNoResults$5 = () => {
1456
1527
  return {
1457
1528
  label: noWorkspaceSymbolsFound()
1458
1529
  };
1459
1530
  };
1460
- const getPicks$6 = async () => {
1531
+ const getPicks$5 = async () => {
1461
1532
  const picks = [];
1462
1533
  return picks;
1463
1534
  };
1464
- const selectPick$6 = async item => {
1535
+ const selectPick$5 = async item => {
1465
1536
  return {
1466
1537
  command: Hide
1467
1538
  };
1468
1539
  };
1469
- const getFilterValue$6 = value => {
1540
+ const getFilterValue$5 = value => {
1470
1541
  return value;
1471
1542
  };
1543
+ const getVisibleItems$5 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
1544
+ const visibleItems = picks.map((pick, index) => ({
1545
+ description: '',
1546
+ fileIcon: '',
1547
+ icon: '',
1548
+ isActive: index + minLineY === focusedIndex,
1549
+ label: pick.label || '',
1550
+ matches: [],
1551
+ posInSet: index + minLineY + 1,
1552
+ setSize
1553
+ }));
1554
+ return visibleItems;
1555
+ };
1472
1556
 
1473
1557
  const QuickPickEntriesWorkspaceSymbol = {
1474
1558
  __proto__: null,
1475
- getFilterValue: getFilterValue$6,
1476
- getNoResults: getNoResults$6,
1477
- getPicks: getPicks$6,
1478
- getPlaceholder: getPlaceholder$6,
1479
- name: name$6,
1480
- selectPick: selectPick$6
1559
+ getFilterValue: getFilterValue$5,
1560
+ getNoResults: getNoResults$5,
1561
+ getPicks: getPicks$5,
1562
+ getPlaceholder: getPlaceholder$5,
1563
+ getVisibleItems: getVisibleItems$5,
1564
+ name: name$5,
1565
+ selectPick: selectPick$5
1481
1566
  };
1482
1567
 
1483
1568
  const getQuickPickProvider = prefix => {
@@ -1500,42 +1585,46 @@ const getQuickPickProvider = prefix => {
1500
1585
  }
1501
1586
  };
1502
1587
 
1503
- const name$5 = 'noop';
1504
- const getPlaceholder$5 = () => {
1588
+ const name$4 = 'noop';
1589
+ const getPlaceholder$4 = () => {
1505
1590
  return '';
1506
1591
  };
1507
- const getNoResults$5 = () => {
1592
+ const getNoResults$4 = () => {
1508
1593
  return noResults();
1509
1594
  };
1510
- const getPicks$5 = async value => {
1595
+ const getPicks$4 = async value => {
1511
1596
  return [];
1512
1597
  };
1513
- const selectPick$5 = async item => {
1598
+ const selectPick$4 = async item => {
1514
1599
  return {
1515
1600
  command: Hide
1516
1601
  };
1517
1602
  };
1518
- const getFilterValue$5 = value => {
1603
+ const getFilterValue$4 = value => {
1519
1604
  return value;
1520
1605
  };
1521
- const getPickFilterValue$5 = pick => {
1606
+ const getPickFilterValue$4 = pick => {
1522
1607
  return pick;
1523
1608
  };
1609
+ const getVisibleItems$4 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
1610
+ return [];
1611
+ };
1524
1612
 
1525
1613
  const QuickPickNoop = {
1526
1614
  __proto__: null,
1527
- getFilterValue: getFilterValue$5,
1528
- getNoResults: getNoResults$5,
1529
- getPickFilterValue: getPickFilterValue$5,
1530
- getPicks: getPicks$5,
1531
- getPlaceholder: getPlaceholder$5,
1532
- name: name$5,
1533
- selectPick: selectPick$5
1615
+ getFilterValue: getFilterValue$4,
1616
+ getNoResults: getNoResults$4,
1617
+ getPickFilterValue: getPickFilterValue$4,
1618
+ getPicks: getPicks$4,
1619
+ getPlaceholder: getPlaceholder$4,
1620
+ getVisibleItems: getVisibleItems$4,
1621
+ name: name$4,
1622
+ selectPick: selectPick$4
1534
1623
  };
1535
1624
 
1536
1625
  // TODO avoid global variable
1537
1626
 
1538
- const state$5 = {
1627
+ const state$4 = {
1539
1628
  // providerId: PROVIDER_NOOP,
1540
1629
  provider: QuickPickNoop,
1541
1630
  prefix: 'string-that-should-never-match-another-string'
@@ -1544,33 +1633,33 @@ const state$5 = {
1544
1633
  /**
1545
1634
  * @type {string}
1546
1635
  */
1547
- const name$4 = 'everything';
1548
- const getPlaceholder$4 = () => {
1549
- return state$5.provider.getPlaceholder();
1636
+ const name$3 = 'everything';
1637
+ const getPlaceholder$3 = () => {
1638
+ return state$4.provider.getPlaceholder();
1550
1639
  };
1551
1640
  const getLabel$3 = () => {
1552
1641
  return '';
1553
1642
  };
1554
- const getNoResults$4 = () => {
1555
- return state$5.provider.getNoResults();
1643
+ const getNoResults$3 = () => {
1644
+ return state$4.provider.getNoResults();
1556
1645
  };
1557
- const getPicks$4 = async value => {
1646
+ const getPicks$3 = async value => {
1558
1647
  const prefix = getQuickPickPrefix(value);
1559
1648
 
1560
1649
  // TODO race condition
1561
- if (state$5.prefix !== prefix) {
1562
- state$5.prefix = prefix;
1563
- state$5.provider = await getQuickPickProvider(prefix);
1650
+ if (state$4.prefix !== prefix) {
1651
+ state$4.prefix = prefix;
1652
+ state$4.provider = await getQuickPickProvider(prefix);
1564
1653
  }
1565
1654
  // TODO this line is a bit duplicated with getFilterValue
1566
1655
  const slicedValue = value.slice(prefix.length).trimStart();
1567
- const picks = await state$5.provider.getPicks(slicedValue);
1656
+ const picks = await state$4.provider.getPicks(slicedValue);
1568
1657
  return picks;
1569
1658
  };
1570
- const selectPick$4 = item => {
1659
+ const selectPick$3 = item => {
1571
1660
  const {
1572
1661
  provider
1573
- } = state$5;
1662
+ } = state$4;
1574
1663
  return provider.selectPick(item);
1575
1664
  };
1576
1665
  const openCommandPalette = () => {
@@ -1579,19 +1668,19 @@ const openCommandPalette = () => {
1579
1668
  const openView = () => {
1580
1669
  // show('view ')
1581
1670
  };
1582
- const getFilterValue$4 = value => {
1583
- return value.slice(state$5.prefix.length).trim();
1671
+ const getFilterValue$3 = value => {
1672
+ return value.slice(state$4.prefix.length).trim();
1584
1673
  };
1585
- const getPickFilterValue$4 = pick => {
1674
+ const getPickFilterValue$3 = pick => {
1586
1675
  const {
1587
1676
  provider
1588
- } = state$5;
1677
+ } = state$4;
1589
1678
  return provider.getPickFilterValue(pick);
1590
1679
  };
1591
- const getPickDescription$5 = pick => {
1680
+ const getPickDescription$3 = pick => {
1592
1681
  const {
1593
1682
  provider
1594
- } = state$5;
1683
+ } = state$4;
1595
1684
  // @ts-ignore
1596
1685
  if (provider.getPickDescription) {
1597
1686
  // @ts-ignore
@@ -1599,35 +1688,35 @@ const getPickDescription$5 = pick => {
1599
1688
  }
1600
1689
  return '';
1601
1690
  };
1602
- const getPickLabel$4 = pick => {
1691
+ const getPickLabel$3 = pick => {
1603
1692
  const {
1604
1693
  provider
1605
- } = state$5;
1694
+ } = state$4;
1606
1695
  // @ts-ignore
1607
1696
  return provider.getPickLabel(pick);
1608
1697
  };
1609
- const getPickIcon$4 = pick => {
1698
+ const getPickIcon$3 = pick => {
1610
1699
  const {
1611
1700
  provider
1612
- } = state$5;
1701
+ } = state$4;
1613
1702
  // @ts-ignore
1614
1703
  return provider.getPickIcon(pick);
1615
1704
  };
1616
1705
  const getPickFileIcon$1 = pick => {
1617
1706
  const {
1618
1707
  provider
1619
- } = state$5;
1708
+ } = state$4;
1620
1709
  // @ts-ignore
1621
1710
  if (provider.getPickFileIcon) {
1622
1711
  // @ts-ignore
1623
1712
  return provider.getPickFileIcon(pick);
1624
1713
  }
1625
- return '';
1714
+ return undefined;
1626
1715
  };
1627
- const isPrepared$4 = () => {
1716
+ const isPrepared$3 = () => {
1628
1717
  const {
1629
1718
  provider
1630
- } = state$5;
1719
+ } = state$4;
1631
1720
  // @ts-ignore
1632
1721
  if (provider.isPrepared) {
1633
1722
  // @ts-ignore
@@ -1635,25 +1724,39 @@ const isPrepared$4 = () => {
1635
1724
  }
1636
1725
  return false;
1637
1726
  };
1727
+ const getVisibleItems$3 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
1728
+ const items = picks.map(pick => pick.pick);
1729
+ const visibleItems = state$4.provider.getVisibleItems(items, minLineY, maxLineY, focusedIndex, setSize, icons);
1730
+ return visibleItems;
1731
+ };
1732
+
1733
+ // provider
1734
+ // - create
1735
+ // - loadcontent
1736
+ // - filter
1737
+ // - getVisible
1738
+
1739
+ // matches could be in loadcontent or getVisible
1638
1740
 
1639
1741
  const QuickPickEntriesEverything = {
1640
1742
  __proto__: null,
1641
- getFilterValue: getFilterValue$4,
1743
+ getFilterValue: getFilterValue$3,
1642
1744
  getLabel: getLabel$3,
1643
- getNoResults: getNoResults$4,
1644
- getPickDescription: getPickDescription$5,
1745
+ getNoResults: getNoResults$3,
1746
+ getPickDescription: getPickDescription$3,
1645
1747
  getPickFileIcon: getPickFileIcon$1,
1646
- getPickFilterValue: getPickFilterValue$4,
1647
- getPickIcon: getPickIcon$4,
1648
- getPickLabel: getPickLabel$4,
1649
- getPicks: getPicks$4,
1650
- getPlaceholder: getPlaceholder$4,
1651
- isPrepared: isPrepared$4,
1652
- name: name$4,
1748
+ getPickFilterValue: getPickFilterValue$3,
1749
+ getPickIcon: getPickIcon$3,
1750
+ getPickLabel: getPickLabel$3,
1751
+ getPicks: getPicks$3,
1752
+ getPlaceholder: getPlaceholder$3,
1753
+ getVisibleItems: getVisibleItems$3,
1754
+ isPrepared: isPrepared$3,
1755
+ name: name$3,
1653
1756
  openCommandPalette,
1654
1757
  openView,
1655
- selectPick: selectPick$4,
1656
- state: state$5
1758
+ selectPick: selectPick$3,
1759
+ state: state$4
1657
1760
  };
1658
1761
 
1659
1762
  const Default$1 = 0;
@@ -1678,7 +1781,7 @@ const create$2 = () => {
1678
1781
  };
1679
1782
 
1680
1783
  const {
1681
- get,
1784
+ get: get$1,
1682
1785
  set,
1683
1786
  remove
1684
1787
  } = create$2();
@@ -1752,6 +1855,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
1752
1855
  const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
1753
1856
  const state = {
1754
1857
  uid,
1858
+ icons: [],
1755
1859
  state: Default$1,
1756
1860
  picks: [],
1757
1861
  recentPicks: [],
@@ -1761,7 +1865,6 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) =
1761
1865
  provider: QuickPickEntriesEverything,
1762
1866
  // TODO make this dynamic again
1763
1867
  warned: [],
1764
- visiblePicks: [],
1765
1868
  maxVisibleItems: 10,
1766
1869
  uri,
1767
1870
  cursorOffset: 0,
@@ -1777,7 +1880,8 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) =
1777
1880
  args,
1778
1881
  focused: false,
1779
1882
  platform,
1780
- value: ''
1883
+ value: '',
1884
+ fileIconCache: Object.create(null)
1781
1885
  };
1782
1886
  set(uid, state, state);
1783
1887
  };
@@ -1832,7 +1936,7 @@ const diff2 = uid => {
1832
1936
  const {
1833
1937
  oldState,
1834
1938
  newState
1835
- } = get(uid);
1939
+ } = get$1(uid);
1836
1940
  return diff(oldState, newState);
1837
1941
  };
1838
1942
 
@@ -1840,195 +1944,72 @@ const dispose = uid => {
1840
1944
  remove(uid);
1841
1945
  };
1842
1946
 
1843
- const emptyMatches = [];
1947
+ const getIconsCached = (paths, fileIconCache) => {
1948
+ return paths.map(path => fileIconCache[path]);
1949
+ };
1844
1950
 
1845
- const convertToPick = item => {
1846
- return {
1847
- pick: item,
1848
- matches: emptyMatches
1849
- };
1850
- };
1851
-
1852
- const Diagonal = 1;
1853
- const Left = 2;
1854
-
1855
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1856
-
1857
- const createTable = size => {
1858
- const table = [];
1859
- for (let i = 0; i < size; i++) {
1860
- const row = new Uint8Array(size);
1861
- table.push(row);
1862
- }
1863
- return table;
1864
- };
1865
- const EmptyMatches = [];
1866
- const Dash = '-';
1867
- const Dot = '.';
1868
- const EmptyString = '';
1869
- const Space = ' ';
1870
- const Underline = '_';
1871
- const T = 't';
1872
- const isLowerCase = char => {
1873
- return char === char.toLowerCase();
1874
- };
1875
- const isUpperCase = char => {
1876
- return char === char.toUpperCase();
1877
- };
1878
-
1879
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1880
- const isGap = (columnCharBefore, columnChar) => {
1881
- switch (columnCharBefore) {
1882
- case Dash:
1883
- case Underline:
1884
- case EmptyString:
1885
- case T:
1886
- case Space:
1887
- case Dot:
1888
- return true;
1889
- }
1890
- if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
1891
- return true;
1892
- }
1893
- return false;
1894
- };
1895
-
1896
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1897
- const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
1898
- if (rowCharLow !== columnCharLow) {
1899
- return -1;
1900
- }
1901
- const isMatch = rowChar === columnChar;
1902
- if (isMatch) {
1903
- if (isDiagonalMatch) {
1904
- return 8;
1905
- }
1906
- if (isGap(columnCharBefore, columnChar)) {
1907
- return 8;
1908
- }
1909
- return 5;
1910
- }
1911
- if (isGap(columnCharBefore, columnChar)) {
1912
- return 8;
1913
- }
1914
- return 5;
1915
- };
1916
-
1917
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1918
-
1919
- const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
1920
- while (patternPos < patternLen && wordPos < wordLen) {
1921
- if (patternLow[patternPos] === wordLow[wordPos]) {
1922
- patternPos += 1;
1951
+ const getMissingIconRequests = (dirents, fileIconCache) => {
1952
+ const missingRequests = [];
1953
+ for (const dirent of dirents) {
1954
+ if (!(dirent.path in fileIconCache)) {
1955
+ missingRequests.push({
1956
+ type: File$2,
1957
+ name: dirent.name,
1958
+ path: dirent.path
1959
+ });
1923
1960
  }
1924
- wordPos += 1;
1925
1961
  }
1926
- return patternPos === patternLen; // pattern must be exhausted
1962
+ return missingRequests;
1927
1963
  };
1928
1964
 
1929
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1930
- const traceHighlights = (table, arrows, patternLength, wordLength) => {
1931
- let row = patternLength;
1932
- let column = wordLength;
1933
- const matches = [];
1934
- while (row >= 1 && column >= 1) {
1935
- const arrow = arrows[row][column];
1936
- if (arrow === Left) {
1937
- column--;
1938
- } else if (arrow === Diagonal) {
1939
- row--;
1940
- column--;
1941
- const start = column + 1;
1942
- while (row >= 1 && column >= 1) {
1943
- const arrow = arrows[row][column];
1944
- if (arrow === Left) {
1945
- break;
1946
- }
1947
- if (arrow === Diagonal) {
1948
- row--;
1949
- column--;
1950
- }
1951
- }
1952
- const end = column;
1953
- matches.unshift(end, start);
1965
+ const requestFileIcons = async requests => {
1966
+ const promises = requests.map(request => {
1967
+ if (!request.name) {
1968
+ return '';
1954
1969
  }
1955
- }
1956
- matches.unshift(table[patternLength][wordLength - 1]);
1957
- return matches;
1970
+ return request.type === File$2 ? invoke$1('IconTheme.getFileIcon', {
1971
+ name: request.name
1972
+ }) : invoke$1('IconTheme.getFolderIcon', {
1973
+ name: request.name
1974
+ });
1975
+ });
1976
+ return Promise.all(promises);
1958
1977
  };
1959
1978
 
1960
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1961
- const gridSize = 128;
1962
- const table = createTable(gridSize);
1963
- const arrows = createTable(gridSize);
1964
- const fuzzySearch = (pattern, word) => {
1965
- const patternLength = Math.min(pattern.length, gridSize - 1);
1966
- const wordLength = Math.min(word.length, gridSize - 1);
1967
- const patternLower = pattern.toLowerCase();
1968
- const wordLower = word.toLowerCase();
1969
- if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
1970
- return EmptyMatches;
1979
+ const updateIconCache = (iconCache, missingRequests, newIcons) => {
1980
+ if (missingRequests.length === 0) {
1981
+ return iconCache;
1971
1982
  }
1972
- let strongMatch = false;
1973
- for (let row = 1; row < patternLength + 1; row++) {
1974
- const rowChar = pattern[row - 1];
1975
- const rowCharLow = patternLower[row - 1];
1976
- for (let column = 1; column < wordLength + 1; column++) {
1977
- const columnChar = word[column - 1];
1978
- const columnCharLow = wordLower[column - 1];
1979
- const columnCharBefore = word[column - 2] || '';
1980
- const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
1981
- const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
1982
- if (row === 1 && score > 5) {
1983
- strongMatch = true;
1984
- }
1985
- let diagonalScore = score + table[row - 1][column - 1];
1986
- if (isDiagonalMatch && score !== -1) {
1987
- diagonalScore += 2;
1988
- }
1989
- const leftScore = table[row][column - 1];
1990
- if (leftScore > diagonalScore) {
1991
- table[row][column] = leftScore;
1992
- arrows[row][column] = Left;
1993
- } else {
1994
- table[row][column] = diagonalScore;
1995
- arrows[row][column] = Diagonal;
1996
- }
1997
- }
1998
- }
1999
- if (!strongMatch) {
2000
- return EmptyMatches;
1983
+ const newFileIconCache = {
1984
+ ...iconCache
1985
+ };
1986
+ for (let i = 0; i < missingRequests.length; i++) {
1987
+ const request = missingRequests[i];
1988
+ const icon = newIcons[i];
1989
+ newFileIconCache[request.path] = icon;
2001
1990
  }
2002
- const highlights = traceHighlights(table, arrows, patternLength, wordLength);
2003
- return highlights;
1991
+ return newFileIconCache;
2004
1992
  };
2005
1993
 
2006
- const filterQuickPickItem = (pattern, word) => {
2007
- const matches = fuzzySearch(pattern, word);
2008
- return matches;
1994
+ const emptyDirent = {
1995
+ name: '',
1996
+ path: '',
1997
+ type: 0
2009
1998
  };
2010
-
2011
- const filterQuickPickItems = (items, value, provider) => {
2012
- if (!value) {
2013
- return items.map(convertToPick);
2014
- }
2015
- const results = [];
2016
- for (const item of items) {
2017
- let filterValue = '';
2018
- if (provider) {
2019
- filterValue = provider.getPickLabel(item);
2020
- } else {
2021
- filterValue = pathBaseName(item);
2022
- }
2023
- const matches = filterQuickPickItem(value, filterValue);
2024
- if (matches.length > 0) {
2025
- results.push({
2026
- pick: item,
2027
- matches
2028
- });
2029
- }
2030
- }
2031
- return results;
1999
+ const getQuickPickFileIcons = async (provider, items, fileIconCache) => {
2000
+ const dirents = items.map(item => {
2001
+ const dirent = provider.getPickFileIcon?.(item) || emptyDirent;
2002
+ return dirent;
2003
+ });
2004
+ const missingRequests = getMissingIconRequests(dirents, fileIconCache);
2005
+ const newIcons = await requestFileIcons(missingRequests);
2006
+ const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
2007
+ const paths = dirents.map(file => file.path);
2008
+ const icons = getIconsCached(paths, newFileIconCache);
2009
+ return {
2010
+ icons,
2011
+ newFileIconCache
2012
+ };
2032
2013
  };
2033
2014
 
2034
2015
  const focusIndex = async (state, index) => {
@@ -2037,7 +2018,8 @@ const focusIndex = async (state, index) => {
2037
2018
  maxVisibleItems,
2038
2019
  items,
2039
2020
  minLineY,
2040
- maxLineY
2021
+ maxLineY,
2022
+ fileIconCache
2041
2023
  } = state;
2042
2024
  // TODO get types working
2043
2025
  // @ts-ignore
@@ -2048,28 +2030,50 @@ const focusIndex = async (state, index) => {
2048
2030
  if (index < minLineY + 1) {
2049
2031
  const minLineY = index;
2050
2032
  const maxLineY = Math.min(index + maxVisibleItems, items.length - 1);
2033
+ const sliced = items.slice(minLineY, maxLineY);
2034
+ const {
2035
+ newFileIconCache,
2036
+ icons
2037
+ } = await getQuickPickFileIcons(provider, sliced, fileIconCache);
2038
+
2051
2039
  // TODO need to scroll up
2052
2040
  return {
2053
2041
  ...state,
2054
2042
  minLineY,
2055
2043
  maxLineY,
2056
- focusedIndex: index
2044
+ focusedIndex: index,
2045
+ icons,
2046
+ fileIconCache: newFileIconCache
2057
2047
  };
2058
2048
  }
2059
2049
  if (index >= maxLineY - 1) {
2060
2050
  // TODO need to scroll down
2061
2051
  const maxLineY = index + 1;
2062
2052
  const minLineY = Math.max(maxLineY - maxVisibleItems, 0);
2053
+ const sliced = items.slice(minLineY, maxLineY);
2054
+ const {
2055
+ newFileIconCache,
2056
+ icons
2057
+ } = await getQuickPickFileIcons(provider, sliced, fileIconCache);
2063
2058
  return {
2064
2059
  ...state,
2065
2060
  minLineY,
2066
2061
  maxLineY,
2067
- focusedIndex: index
2062
+ focusedIndex: index,
2063
+ fileIconCache: newFileIconCache,
2064
+ icons
2068
2065
  };
2069
2066
  }
2067
+ const sliced = items.slice(minLineY, maxLineY);
2068
+ const {
2069
+ newFileIconCache,
2070
+ icons
2071
+ } = await getQuickPickFileIcons(provider, sliced, fileIconCache);
2070
2072
  return {
2071
2073
  ...state,
2072
- focusedIndex: index
2074
+ focusedIndex: index,
2075
+ fileIconCache: newFileIconCache,
2076
+ icons
2073
2077
  };
2074
2078
  };
2075
2079
 
@@ -2301,11 +2305,205 @@ const getNewValue = (value, inputType, data, selectionStart, selectionEnd) => {
2301
2305
  return fn(value, selectionStart, selectionEnd, data);
2302
2306
  };
2303
2307
 
2308
+ const emptyMatches = [];
2309
+
2310
+ const convertToPick = item => {
2311
+ return {
2312
+ pick: item,
2313
+ matches: emptyMatches
2314
+ };
2315
+ };
2316
+
2317
+ const Diagonal = 1;
2318
+ const Left = 2;
2319
+
2320
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
2321
+
2322
+ const createTable = size => {
2323
+ const table = [];
2324
+ for (let i = 0; i < size; i++) {
2325
+ const row = new Uint8Array(size);
2326
+ table.push(row);
2327
+ }
2328
+ return table;
2329
+ };
2330
+ const EmptyMatches = [];
2331
+ const Dash = '-';
2332
+ const Dot = '.';
2333
+ const EmptyString = '';
2334
+ const Space = ' ';
2335
+ const Underline = '_';
2336
+ const T = 't';
2337
+ const isLowerCase = char => {
2338
+ return char === char.toLowerCase();
2339
+ };
2340
+ const isUpperCase = char => {
2341
+ return char === char.toUpperCase();
2342
+ };
2343
+
2344
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
2345
+ const isGap = (columnCharBefore, columnChar) => {
2346
+ switch (columnCharBefore) {
2347
+ case Dash:
2348
+ case Underline:
2349
+ case EmptyString:
2350
+ case T:
2351
+ case Space:
2352
+ case Dot:
2353
+ return true;
2354
+ }
2355
+ if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
2356
+ return true;
2357
+ }
2358
+ return false;
2359
+ };
2360
+
2361
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
2362
+ const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
2363
+ if (rowCharLow !== columnCharLow) {
2364
+ return -1;
2365
+ }
2366
+ const isMatch = rowChar === columnChar;
2367
+ if (isMatch) {
2368
+ if (isDiagonalMatch) {
2369
+ return 8;
2370
+ }
2371
+ if (isGap(columnCharBefore, columnChar)) {
2372
+ return 8;
2373
+ }
2374
+ return 5;
2375
+ }
2376
+ if (isGap(columnCharBefore, columnChar)) {
2377
+ return 8;
2378
+ }
2379
+ return 5;
2380
+ };
2381
+
2382
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
2383
+
2384
+ const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
2385
+ while (patternPos < patternLen && wordPos < wordLen) {
2386
+ if (patternLow[patternPos] === wordLow[wordPos]) {
2387
+ patternPos += 1;
2388
+ }
2389
+ wordPos += 1;
2390
+ }
2391
+ return patternPos === patternLen; // pattern must be exhausted
2392
+ };
2393
+
2394
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
2395
+ const traceHighlights = (table, arrows, patternLength, wordLength) => {
2396
+ let row = patternLength;
2397
+ let column = wordLength;
2398
+ const matches = [];
2399
+ while (row >= 1 && column >= 1) {
2400
+ const arrow = arrows[row][column];
2401
+ if (arrow === Left) {
2402
+ column--;
2403
+ } else if (arrow === Diagonal) {
2404
+ row--;
2405
+ column--;
2406
+ const start = column + 1;
2407
+ while (row >= 1 && column >= 1) {
2408
+ const arrow = arrows[row][column];
2409
+ if (arrow === Left) {
2410
+ break;
2411
+ }
2412
+ if (arrow === Diagonal) {
2413
+ row--;
2414
+ column--;
2415
+ }
2416
+ }
2417
+ const end = column;
2418
+ matches.unshift(end, start);
2419
+ }
2420
+ }
2421
+ matches.unshift(table[patternLength][wordLength - 1]);
2422
+ return matches;
2423
+ };
2424
+
2425
+ // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
2426
+ const gridSize = 128;
2427
+ const table = createTable(gridSize);
2428
+ const arrows = createTable(gridSize);
2429
+ const fuzzySearch = (pattern, word) => {
2430
+ const patternLength = Math.min(pattern.length, gridSize - 1);
2431
+ const wordLength = Math.min(word.length, gridSize - 1);
2432
+ const patternLower = pattern.toLowerCase();
2433
+ const wordLower = word.toLowerCase();
2434
+ if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
2435
+ return EmptyMatches;
2436
+ }
2437
+ let strongMatch = false;
2438
+ for (let row = 1; row < patternLength + 1; row++) {
2439
+ const rowChar = pattern[row - 1];
2440
+ const rowCharLow = patternLower[row - 1];
2441
+ for (let column = 1; column < wordLength + 1; column++) {
2442
+ const columnChar = word[column - 1];
2443
+ const columnCharLow = wordLower[column - 1];
2444
+ const columnCharBefore = word[column - 2] || '';
2445
+ const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
2446
+ const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
2447
+ if (row === 1 && score > 5) {
2448
+ strongMatch = true;
2449
+ }
2450
+ let diagonalScore = score + table[row - 1][column - 1];
2451
+ if (isDiagonalMatch && score !== -1) {
2452
+ diagonalScore += 2;
2453
+ }
2454
+ const leftScore = table[row][column - 1];
2455
+ if (leftScore > diagonalScore) {
2456
+ table[row][column] = leftScore;
2457
+ arrows[row][column] = Left;
2458
+ } else {
2459
+ table[row][column] = diagonalScore;
2460
+ arrows[row][column] = Diagonal;
2461
+ }
2462
+ }
2463
+ }
2464
+ if (!strongMatch) {
2465
+ return EmptyMatches;
2466
+ }
2467
+ const highlights = traceHighlights(table, arrows, patternLength, wordLength);
2468
+ return highlights;
2469
+ };
2470
+
2471
+ const filterQuickPickItem = (pattern, word) => {
2472
+ const matches = fuzzySearch(pattern, word);
2473
+ return matches;
2474
+ };
2475
+
2476
+ const filterQuickPickItems = (items, value, provider) => {
2477
+ if (!value) {
2478
+ return items.map(convertToPick);
2479
+ }
2480
+ const results = [];
2481
+ for (const item of items) {
2482
+ let filterValue = '';
2483
+ if (provider) {
2484
+ filterValue = provider.getPickLabel(item);
2485
+ } else {
2486
+ filterValue = pathBaseName(item);
2487
+ }
2488
+ const matches = filterQuickPickItem(value, filterValue);
2489
+ if (matches.length > 0) {
2490
+ results.push({
2491
+ pick: item,
2492
+ matches
2493
+ });
2494
+ }
2495
+ }
2496
+ return results;
2497
+ };
2498
+
2304
2499
  // TODO when user types letters -> no need to query provider again -> just filter existing results
2305
2500
  const setValue = async (state, newValue) => {
2306
2501
  const {
2307
2502
  value,
2308
- provider
2503
+ provider,
2504
+ minLineY,
2505
+ maxLineY,
2506
+ fileIconCache
2309
2507
  } = state;
2310
2508
  if (value === newValue) {
2311
2509
  return state;
@@ -2314,13 +2512,20 @@ const setValue = async (state, newValue) => {
2314
2512
  const filterValue = provider.getFilterValue(newValue);
2315
2513
  const items = filterQuickPickItems(newPicks, filterValue, provider);
2316
2514
  const focusedIndex = items.length === 0 ? -1 : 0;
2515
+ const sliced = newPicks.slice(minLineY, maxLineY);
2516
+ const {
2517
+ newFileIconCache,
2518
+ icons
2519
+ } = await getQuickPickFileIcons(provider, sliced, fileIconCache);
2317
2520
  return {
2318
2521
  ...state,
2319
2522
  picks: newPicks,
2320
2523
  items,
2321
2524
  focusedIndex,
2322
2525
  inputSource: Script,
2323
- value: newValue
2526
+ value: newValue,
2527
+ icons,
2528
+ fileIconCache: newFileIconCache
2324
2529
  };
2325
2530
  };
2326
2531
 
@@ -2378,6 +2583,7 @@ const selectIndex = async (state, index, button = /* left */0) => {
2378
2583
  } = state;
2379
2584
  const actualIndex = index + minLineY;
2380
2585
  const pick = getPick(items, actualIndex);
2586
+ // @ts-ignore
2381
2587
  const selectPickResult = await provider.selectPick(pick, actualIndex, button);
2382
2588
  object(selectPickResult);
2383
2589
  string(selectPickResult.command);
@@ -2419,10 +2625,16 @@ const setFocus = async focusKey => {
2419
2625
  };
2420
2626
 
2421
2627
  const handleFocus = async state => {
2628
+ if (state.focused) {
2629
+ return state;
2630
+ }
2422
2631
  // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2423
2632
  await setFocus(FocusQuickPickInput);
2424
2633
  // await CloseWidget.closeWidget(state.uid)
2425
- return state;
2634
+ return {
2635
+ ...state,
2636
+ focused: true
2637
+ };
2426
2638
  };
2427
2639
 
2428
2640
  const getDefaultValue = uri => {
@@ -2434,12 +2646,12 @@ const getDefaultValue = uri => {
2434
2646
  }
2435
2647
  };
2436
2648
 
2437
- const state$4 = Object.create(null);
2649
+ const state$3 = Object.create(null);
2438
2650
  const register = modules => {
2439
- Object.assign(state$4, modules);
2651
+ Object.assign(state$3, modules);
2440
2652
  };
2441
- const load = moduleId => {
2442
- const module = state$4[moduleId];
2653
+ const get = moduleId => {
2654
+ const module = state$3[moduleId];
2443
2655
  if (!module) {
2444
2656
  throw new Error(`unknown module "${moduleId}"`);
2445
2657
  }
@@ -2449,10 +2661,11 @@ const load = moduleId => {
2449
2661
  const loadContent = async state => {
2450
2662
  const {
2451
2663
  uri,
2452
- args
2664
+ args,
2665
+ fileIconCache
2453
2666
  } = state;
2454
2667
  const value = getDefaultValue(uri);
2455
- const provider = load(uri);
2668
+ const provider = get(uri);
2456
2669
  // @ts-ignore
2457
2670
  if (provider.setArgs) {
2458
2671
  // @ts-ignore
@@ -2462,10 +2675,13 @@ const loadContent = async state => {
2462
2675
  array(newPicks);
2463
2676
  const filterValue = provider.getFilterValue(value);
2464
2677
  const items = filterQuickPickItems(newPicks, filterValue, provider);
2465
- // @ts-ignore
2466
- provider.getLabel();
2467
2678
  const minLineY = 0;
2468
2679
  const maxLineY = Math.min(minLineY + state.maxVisibleItems, newPicks.length);
2680
+ const sliced = newPicks.slice(minLineY, maxLineY);
2681
+ const {
2682
+ newFileIconCache,
2683
+ icons
2684
+ } = await getQuickPickFileIcons(provider, sliced, fileIconCache);
2469
2685
  return {
2470
2686
  ...state,
2471
2687
  picks: newPicks,
@@ -2478,183 +2694,21 @@ const loadContent = async state => {
2478
2694
  cursorOffset: value.length,
2479
2695
  provider,
2480
2696
  inputSource: Script,
2481
- focused: true
2482
- };
2483
- };
2484
-
2485
- const getRecentlyOpened = () => {
2486
- return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2487
- };
2488
- const openWorkspaceFolder = uri => {
2489
- return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
2490
- };
2491
- const getPlaceholder$3 = () => {
2492
- return selectToOpen();
2493
- };
2494
- const getLabel$2 = () => {
2495
- return openRecent();
2496
- };
2497
- const getNoResults$3 = () => {
2498
- return {
2499
- label: noRecentlyOpenedFoldersFound()
2500
- };
2501
- };
2502
-
2503
- // TODO could also change api so that getPicks returns an array of anything
2504
- // and the transformPick gets the label for each pick
2505
- // This would make the code more module since the code for getting the picks
2506
- // would be more independent of the specific data format of the quickpick provider
2507
-
2508
- const getPicks$3 = async () => {
2509
- const recentlyOpened = await getRecentlyOpened();
2510
- return recentlyOpened;
2511
- };
2512
-
2513
- // TODO selectPick should be independent of show/hide
2514
- const selectPick$3 = async pick => {
2515
- const path = pick;
2516
- await openWorkspaceFolder(path);
2517
- return {
2518
- command: Hide
2519
- };
2520
- };
2521
- const getFilterValue$3 = value => {
2522
- return pathBaseName(value);
2523
- };
2524
- const getPickFilterValue$3 = pick => {
2525
- return pathBaseName(pick);
2526
- };
2527
- const getPickLabel$3 = pick => {
2528
- return pathBaseName(pick);
2529
- };
2530
- const getPickDescription$4 = pick => {
2531
- return pathDirName(pick);
2532
- };
2533
- const getPickIcon$3 = () => {
2534
- return '';
2535
- };
2536
- const getPickFileIcon = pick => {
2537
- if (typeof pick === 'object') {
2538
- pick = pick.pick;
2539
- }
2540
- if (typeof pick === 'object') {
2541
- pick = pick.pick;
2542
- }
2543
- return {
2544
- type: Directory,
2545
- name: pick
2697
+ focused: true,
2698
+ fileIconCache: newFileIconCache,
2699
+ icons
2546
2700
  };
2547
2701
  };
2548
- const state$3 = {};
2549
- const isPrepared$3 = () => {
2550
- return false;
2551
- };
2552
- const name$3 = '';
2553
-
2554
- const QuickPickEntriesOpenRecent = {
2555
- __proto__: null,
2556
- getFilterValue: getFilterValue$3,
2557
- getLabel: getLabel$2,
2558
- getNoResults: getNoResults$3,
2559
- getPickDescription: getPickDescription$4,
2560
- getPickFileIcon,
2561
- getPickFilterValue: getPickFilterValue$3,
2562
- getPickIcon: getPickIcon$3,
2563
- getPickLabel: getPickLabel$3,
2564
- getPicks: getPicks$3,
2565
- getPlaceholder: getPlaceholder$3,
2566
- isPrepared: isPrepared$3,
2567
- name: name$3,
2568
- selectPick: selectPick$3,
2569
- state: state$3
2570
- };
2571
-
2572
- const CommandPalette = 'quickPick://commandPalette';
2573
- const Commands = 'quickPick://commands';
2574
- const File$1 = 'quickPick://file';
2575
- const EveryThing = 'quickPick://everything';
2576
- const Number$1 = 'quickPick://number';
2577
- const Recent = 'quickPick://recent';
2578
- const ColorTheme = 'quickPick://color-theme';
2579
- const Symbol = 'quickPick://symbol';
2580
- const View = 'quickPick://view';
2581
- const WorkspaceSymbol = 'quickPick://workspace-symbol';
2582
- const Custom = 'quickPick://custom';
2583
-
2584
- const loadQuickPickEntries = moduleId => {
2585
- switch (moduleId) {
2586
- case Recent:
2587
- return QuickPickEntriesOpenRecent;
2588
- default:
2589
- throw new Error(`unknown module "${moduleId}"`);
2590
- }
2591
- };
2592
-
2593
- const getIconRequests = (items, provider) => {
2594
- const iconRequests = [];
2595
- for (let i = 0; i < items.length; i++) {
2596
- const pick = items[i];
2597
- const iconObject = provider?.getPickFileIcon?.(pick) || {};
2598
- iconRequests.push({
2599
- name: iconObject?.name,
2600
- path: '',
2601
- type: iconObject?.type
2602
- });
2603
- }
2604
- return iconRequests;
2605
- };
2606
-
2607
- const getPickDescription$3 = (provider, pick) => {
2608
- if (provider.getPickDescription) {
2609
- return provider.getPickDescription(pick);
2610
- }
2611
- return '';
2612
- };
2613
-
2614
- const requestFileIcons = async requests => {
2615
- const promises = requests.map(request => {
2616
- if (!request.name) {
2617
- return '';
2618
- }
2619
- return request.type === File$2 ? invoke$1('IconTheme.getFileIcon', {
2620
- name: request.name
2621
- }) : invoke$1('IconTheme.getFolderIcon', {
2622
- name: request.name
2623
- });
2624
- });
2625
- return Promise.all(promises);
2626
- };
2627
2702
 
2628
- const getVisible = async (provider, items, minLineY, maxLineY, focusedIndex) => {
2629
- const visibleItems = [];
2703
+ const getVisible = (provider, items, minLineY, maxLineY, focusedIndex, icons) => {
2630
2704
  const setSize = items.length;
2631
- const max = Math.min(setSize, maxLineY);
2632
- const iconsRequests = getIconRequests(items.slice(minLineY, maxLineY), provider);
2633
- const icons = await requestFileIcons(iconsRequests);
2634
- let iconIndex = 0;
2635
- for (let i = minLineY; i < max; i++) {
2636
- const item = items[i];
2637
- const pick = item.pick;
2638
- const label = provider.getPickLabel(pick);
2639
- const description = getPickDescription$3(provider, pick);
2640
- const icon = provider.getPickIcon(pick);
2641
- const fileIcon = icons[iconIndex++];
2642
- visibleItems.push({
2643
- label,
2644
- description,
2645
- icon,
2646
- fileIcon,
2647
- posInSet: i + 1,
2648
- setSize,
2649
- isActive: i === focusedIndex,
2650
- matches: item.matches
2651
- });
2652
- }
2705
+ const range = items.slice(minLineY, maxLineY);
2706
+ const visibleItems = provider.getVisibleItems(range, minLineY, maxLineY, focusedIndex, setSize, icons);
2653
2707
  return visibleItems;
2654
2708
  };
2655
2709
 
2656
- const createQuickPickViewModel = async (oldState, newState) => {
2657
- const visibleItems = await getVisible(newState.provider, newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex);
2710
+ const createQuickPickViewModel = (oldState, newState) => {
2711
+ const visibleItems = getVisible(newState.provider, newState.items, newState.minLineY, newState.maxLineY, newState.focusedIndex, newState.icons);
2658
2712
  const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
2659
2713
  const newFocusedIndex = newState.focusedIndex - newState.minLineY;
2660
2714
  const maxLineY = Math.min(newState.maxLineY, newState.items.length);
@@ -2701,7 +2755,7 @@ const renderHeight = newState => {
2701
2755
  const ComboBox = 'combobox';
2702
2756
  const ListBox = 'listbox';
2703
2757
  const None$1 = 'none';
2704
- const Option$1 = 'option';
2758
+ const Option = 'option';
2705
2759
 
2706
2760
  const FileIcon = 'FileIcon';
2707
2761
  const InputBox = 'InputBox';
@@ -2727,15 +2781,15 @@ const QuickPick = 'QuickPick';
2727
2781
  const QuickPickItems = 'QuickPickItems';
2728
2782
  const QuickPickItemActive = 'QuickPickItemActive';
2729
2783
 
2730
- const Div$1 = 4;
2731
- const Input$1 = 6;
2732
- const Span$1 = 8;
2733
- const Img$1 = 17;
2784
+ const Div = 4;
2785
+ const Input = 6;
2786
+ const Span = 8;
2787
+ const Img = 17;
2734
2788
 
2735
2789
  const getQuickPickInputVirtualDom = () => {
2736
2790
  const ariaLabel = typeNameofCommandToRun();
2737
2791
  return {
2738
- type: Input$1,
2792
+ type: Input,
2739
2793
  className: InputBox,
2740
2794
  spellcheck: false,
2741
2795
  autocapitalize: 'off',
@@ -2756,140 +2810,17 @@ const getQuickPickInputVirtualDom = () => {
2756
2810
 
2757
2811
  const getQuickPickHeaderVirtualDom = () => {
2758
2812
  return [{
2759
- type: Div$1,
2813
+ type: Div,
2760
2814
  className: QuickPickHeader,
2761
2815
  childCount: 1
2762
2816
  }, getQuickPickInputVirtualDom()];
2763
2817
  };
2764
2818
 
2765
- var __defProp = Object.defineProperty;
2766
- var __export = (target, all) => {
2767
- for (var name in all) __defProp(target, name, {
2768
- get: all[name],
2769
- enumerable: true
2770
- });
2819
+ const mergeClassNames = (...classNames) => {
2820
+ return classNames.filter(Boolean).join(' ');
2771
2821
  };
2772
-
2773
- // src/parts/MergeClassNames/MergeClassNames.ts
2774
- var mergeClassNames = (...classNames) => {
2775
- return classNames.filter(Boolean).join(" ");
2776
- };
2777
-
2778
- // src/parts/VirtualDomElements/VirtualDomElements.ts
2779
- var VirtualDomElements_exports = {};
2780
- __export(VirtualDomElements_exports, {
2781
- A: () => A,
2782
- Abbr: () => Abbr,
2783
- Article: () => Article,
2784
- Aside: () => Aside,
2785
- Audio: () => Audio,
2786
- Br: () => Br,
2787
- Button: () => Button,
2788
- Cite: () => Cite,
2789
- Col: () => Col,
2790
- ColGroup: () => ColGroup,
2791
- Data: () => Data,
2792
- Dd: () => Dd,
2793
- Del: () => Del,
2794
- Div: () => Div,
2795
- Dl: () => Dl,
2796
- Figcaption: () => Figcaption,
2797
- Figure: () => Figure,
2798
- Footer: () => Footer,
2799
- H1: () => H1,
2800
- H2: () => H2,
2801
- H3: () => H3,
2802
- H4: () => H4,
2803
- H5: () => H5,
2804
- H6: () => H6,
2805
- Header: () => Header,
2806
- Hr: () => Hr,
2807
- I: () => I,
2808
- Img: () => Img,
2809
- Input: () => Input,
2810
- Ins: () => Ins,
2811
- Kbd: () => Kbd,
2812
- Li: () => Li,
2813
- Nav: () => Nav,
2814
- Ol: () => Ol,
2815
- Option: () => Option,
2816
- P: () => P,
2817
- Pre: () => Pre,
2818
- Root: () => Root,
2819
- Search: () => Search,
2820
- Section: () => Section,
2821
- Select: () => Select,
2822
- Span: () => Span,
2823
- TBody: () => TBody,
2824
- THead: () => THead,
2825
- Table: () => Table,
2826
- Td: () => Td,
2827
- Text: () => Text,
2828
- TextArea: () => TextArea,
2829
- Tfoot: () => Tfoot,
2830
- Th: () => Th,
2831
- Time: () => Time,
2832
- Tr: () => Tr,
2833
- Ul: () => Ul,
2834
- Video: () => Video
2835
- });
2836
- var Audio = 0;
2837
- var Button = 1;
2838
- var Col = 2;
2839
- var ColGroup = 3;
2840
- var Div = 4;
2841
- var H1 = 5;
2842
- var Input = 6;
2843
- var Kbd = 7;
2844
- var Span = 8;
2845
- var Table = 9;
2846
- var TBody = 10;
2847
- var Td = 11;
2848
- var Text = 12;
2849
- var Th = 13;
2850
- var THead = 14;
2851
- var Tr = 15;
2852
- var I = 16;
2853
- var Img = 17;
2854
- var Root = 0;
2855
- var Ins = 20;
2856
- var Del = 21;
2857
- var H2 = 22;
2858
- var H3 = 23;
2859
- var H4 = 24;
2860
- var H5 = 25;
2861
- var H6 = 26;
2862
- var Article = 27;
2863
- var Aside = 28;
2864
- var Footer = 29;
2865
- var Header = 30;
2866
- var Nav = 40;
2867
- var Section = 41;
2868
- var Search = 42;
2869
- var Dd = 43;
2870
- var Dl = 44;
2871
- var Figcaption = 45;
2872
- var Figure = 46;
2873
- var Hr = 47;
2874
- var Li = 48;
2875
- var Ol = 49;
2876
- var P = 50;
2877
- var Pre = 51;
2878
- var A = 53;
2879
- var Abbr = 54;
2880
- var Br = 55;
2881
- var Cite = 56;
2882
- var Data = 57;
2883
- var Time = 58;
2884
- var Tfoot = 59;
2885
- var Ul = 60;
2886
- var Video = 61;
2887
- var TextArea = 62;
2888
- var Select = 63;
2889
- var Option = 64;
2890
-
2891
- // src/parts/Text/Text.ts
2892
- var text = data => {
2822
+ const Text = 12;
2823
+ const text = data => {
2893
2824
  return {
2894
2825
  type: Text,
2895
2826
  text: data,
@@ -2898,13 +2829,13 @@ var text = data => {
2898
2829
  };
2899
2830
 
2900
2831
  const quickPickHighlight = {
2901
- type: Span$1,
2832
+ type: Span,
2902
2833
  className: QuickPickHighlight,
2903
2834
  childCount: 1
2904
2835
  };
2905
2836
  const addHighlights = (dom, highlights, label) => {
2906
2837
  const labelDom = {
2907
- type: Div$1,
2838
+ type: Div,
2908
2839
  className: QuickPickItemLabel,
2909
2840
  childCount: 0
2910
2841
  };
@@ -2932,7 +2863,7 @@ const addHighlights = (dom, highlights, label) => {
2932
2863
 
2933
2864
  const getFileIconVirtualDom = icon => {
2934
2865
  return {
2935
- type: Img$1,
2866
+ type: Img,
2936
2867
  className: FileIcon,
2937
2868
  src: icon,
2938
2869
  role: None$1,
@@ -2954,9 +2885,9 @@ const getQuickPickItemVirtualDom = visibleItem => {
2954
2885
  const highlights = matches.slice(1);
2955
2886
  const dom = [];
2956
2887
  dom.push({
2957
- type: Div$1,
2888
+ type: Div,
2958
2889
  className: QuickPickItem,
2959
- role: Option$1,
2890
+ role: Option,
2960
2891
  ariaPosInSet: posInSet,
2961
2892
  ariaSetSize: setSize,
2962
2893
  childCount: 1
@@ -2973,7 +2904,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
2973
2904
  } else if (icon) {
2974
2905
  parent.childCount++;
2975
2906
  dom.push({
2976
- type: Div$1,
2907
+ type: Div,
2977
2908
  className: mergeClassNames(`QuickPickMaskIcon`, 'MaskIcon', `MaskIcon${icon}`),
2978
2909
  childCount: 0
2979
2910
  });
@@ -2982,7 +2913,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
2982
2913
  if (description) {
2983
2914
  parent.childCount++;
2984
2915
  dom.push({
2985
- type: Div$1,
2916
+ type: Div,
2986
2917
  className: QuickPickItemDescription,
2987
2918
  childCount: 1
2988
2919
  }, text(description));
@@ -2993,11 +2924,11 @@ const getQuickPickItemVirtualDom = visibleItem => {
2993
2924
  const getQuickPickNoResultsVirtualDom = () => {
2994
2925
  const noResults$1 = noResults();
2995
2926
  return [{
2996
- type: Div$1,
2927
+ type: Div,
2997
2928
  className: 'QuickPickItem QuickPickItemActive QuickPickStatus',
2998
2929
  childCount: 1
2999
2930
  }, {
3000
- type: Div$1,
2931
+ type: Div,
3001
2932
  className: Label,
3002
2933
  childCount: 1
3003
2934
  }, text(noResults$1)];
@@ -3014,13 +2945,13 @@ const getQuickPickItemsVirtualDom = visibleItems => {
3014
2945
  const getQuickPickVirtualDom = visibleItems => {
3015
2946
  const quickOpen$1 = quickOpen();
3016
2947
  return [{
3017
- type: Div$1,
2948
+ type: Div,
3018
2949
  className: mergeClassNames(Viewlet, QuickPick$1),
3019
2950
  childCount: 2,
3020
2951
  id: QuickPick,
3021
2952
  ariaLabel: quickOpen$1
3022
2953
  }, ...getQuickPickHeaderVirtualDom(), {
3023
- type: Div$1,
2954
+ type: Div,
3024
2955
  className: QuickPickItems$1,
3025
2956
  id: QuickPickItems,
3026
2957
  role: ListBox,
@@ -3058,9 +2989,9 @@ const getRenderer = diffType => {
3058
2989
  }
3059
2990
  };
3060
2991
 
3061
- const applyRender = async (oldState, newState, diffResult) => {
2992
+ const applyRender = (oldState, newState, diffResult) => {
3062
2993
  const commands = [];
3063
- const viewModel = await createQuickPickViewModel(oldState, newState);
2994
+ const viewModel = createQuickPickViewModel(oldState, newState);
3064
2995
  for (const item of diffResult) {
3065
2996
  if (item === Height) {
3066
2997
  continue;
@@ -3074,25 +3005,16 @@ const applyRender = async (oldState, newState, diffResult) => {
3074
3005
  return commands;
3075
3006
  };
3076
3007
 
3077
- const render2 = async (uid, diffResult) => {
3008
+ const render2 = (uid, diffResult) => {
3078
3009
  const {
3079
3010
  oldState,
3080
3011
  newState
3081
- } = get(uid);
3082
- set(uid, oldState, newState);
3012
+ } = get$1(uid);
3013
+ set(uid, newState, newState);
3083
3014
  const commands = applyRender(oldState, newState, diffResult);
3084
3015
  return commands;
3085
3016
  };
3086
3017
 
3087
- const doRender = async uid => {
3088
- const {
3089
- oldState,
3090
- newState
3091
- } = get(uid);
3092
- const diffResult = diff(oldState, newState);
3093
- return applyRender(oldState, newState, diffResult);
3094
- };
3095
-
3096
3018
  const renderEventListeners = () => {
3097
3019
  return [{
3098
3020
  name: HandlePointerDown,
@@ -3142,12 +3064,17 @@ const wrapCommand = fn => {
3142
3064
  const wrapped = async (uid, ...args) => {
3143
3065
  const {
3144
3066
  newState
3145
- } = get(uid);
3067
+ } = get$1(uid);
3146
3068
  const newerState = await fn(newState, ...args);
3147
3069
  if (newState === newerState) {
3148
3070
  return;
3149
3071
  }
3150
- set(uid, newState, newerState);
3072
+ const latest = get$1(uid);
3073
+ const merged = {
3074
+ ...latest.newState,
3075
+ ...newerState
3076
+ };
3077
+ set(uid, latest.newState, merged);
3151
3078
  };
3152
3079
  return wrapped;
3153
3080
  };
@@ -3172,19 +3099,14 @@ const commandMap = {
3172
3099
  'QuickPick.handleInput': wrapCommand(handleInput),
3173
3100
  'QuickPick.handleWheel': wrapCommand(handleWheel),
3174
3101
  'QuickPick.loadContent': wrapCommand(loadContent),
3175
- 'QuickPick.loadEntries2': load,
3102
+ 'QuickPick.loadEntries2': get,
3176
3103
  'QuickPick.render2': render2,
3177
3104
  'QuickPick.renderEventListeners': renderEventListeners,
3178
3105
  'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
3179
3106
  'QuickPick.selectIndex': wrapCommand(selectIndex),
3180
3107
  'QuickPick.selectItem': wrapCommand(selectItem),
3181
3108
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
3182
- 'QuickPick.setValue': wrapCommand(setValue),
3183
- // deprecated
3184
- 'QuickPick.render': doRender,
3185
- 'SearchFile.filter': filterQuickPickItems,
3186
- 'SearchFile.searchFile': searchFile$5,
3187
- 'QuickPick.loadEntries': loadQuickPickEntries
3109
+ 'QuickPick.setValue': wrapCommand(setValue)
3188
3110
  };
3189
3111
 
3190
3112
  const getColorThemeNames = async () => {
@@ -3197,13 +3119,26 @@ const setColorTheme = id => {
3197
3119
  const getPlaceholder$2 = () => {
3198
3120
  return selectColorTheme();
3199
3121
  };
3200
- const getLabel$1 = () => {
3122
+ const getLabel$2 = () => {
3201
3123
  return selectColorTheme();
3202
3124
  };
3203
3125
  const getPicks$2 = async searchValue => {
3204
3126
  const colorThemeNames = await getColorThemeNames();
3205
3127
  return colorThemeNames;
3206
3128
  };
3129
+ const getVisibleItems$2 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
3130
+ const visibleItems = picks.map((pick, index) => ({
3131
+ description: getPickDescription$2(),
3132
+ fileIcon: '',
3133
+ icon: getPickIcon$2(),
3134
+ isActive: index + minLineY === focusedIndex,
3135
+ label: getPickLabel$2(pick),
3136
+ matches: [],
3137
+ posInSet: index + minLineY + 1,
3138
+ setSize
3139
+ }));
3140
+ return visibleItems;
3141
+ };
3207
3142
  const selectPick$2 = async pick => {
3208
3143
  await setColorTheme(/* colorThemeId */pick);
3209
3144
  return {
@@ -3247,7 +3182,7 @@ const QuickPickEntriesColorTheme = {
3247
3182
  focusPick,
3248
3183
  getFilterValue: getFilterValue$2,
3249
3184
  getHelpEntries: getHelpEntries$1,
3250
- getLabel: getLabel$1,
3185
+ getLabel: getLabel$2,
3251
3186
  getNoResults: getNoResults$2,
3252
3187
  getPickDescription: getPickDescription$2,
3253
3188
  getPickFilterValue: getPickFilterValue$2,
@@ -3255,6 +3190,7 @@ const QuickPickEntriesColorTheme = {
3255
3190
  getPickLabel: getPickLabel$2,
3256
3191
  getPicks: getPicks$2,
3257
3192
  getPlaceholder: getPlaceholder$2,
3193
+ getVisibleItems: getVisibleItems$2,
3258
3194
  isPrepared: isPrepared$2,
3259
3195
  name: name$2,
3260
3196
  selectPick: selectPick$2,
@@ -3281,7 +3217,7 @@ const setArgs = args => {
3281
3217
  const getPlaceholder$1 = () => {
3282
3218
  return '';
3283
3219
  };
3284
- const getLabel = () => {
3220
+ const getLabel$1 = () => {
3285
3221
  return 'Custom';
3286
3222
  };
3287
3223
 
@@ -3338,12 +3274,25 @@ const getPickIcon$1 = pick => {
3338
3274
  const isPrepared$1 = () => {
3339
3275
  return true;
3340
3276
  };
3277
+ const getVisibleItems$1 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
3278
+ const visibleItems = picks.slice(minLineY, maxLineY + 1).map((pick, index) => ({
3279
+ description: getPickDescription$1(pick),
3280
+ fileIcon: '',
3281
+ icon: getPickIcon$1(pick),
3282
+ isActive: index + minLineY === focusedIndex,
3283
+ label: getPickLabel$1(pick),
3284
+ matches: [],
3285
+ posInSet: index + minLineY + 1,
3286
+ setSize
3287
+ }));
3288
+ return visibleItems;
3289
+ };
3341
3290
 
3342
3291
  const QuickPickEntriesCustom = {
3343
3292
  __proto__: null,
3344
3293
  getFilterValue: getFilterValue$1,
3345
3294
  getHelpEntries,
3346
- getLabel,
3295
+ getLabel: getLabel$1,
3347
3296
  getNoResults: getNoResults$1,
3348
3297
  getPickDescription: getPickDescription$1,
3349
3298
  getPickFilterValue: getPickFilterValue$1,
@@ -3351,6 +3300,7 @@ const QuickPickEntriesCustom = {
3351
3300
  getPickLabel: getPickLabel$1,
3352
3301
  getPicks: getPicks$1,
3353
3302
  getPlaceholder: getPlaceholder$1,
3303
+ getVisibleItems: getVisibleItems$1,
3354
3304
  isPrepared: isPrepared$1,
3355
3305
  name: name$1,
3356
3306
  selectPick: selectPick$1,
@@ -3358,87 +3308,126 @@ const QuickPickEntriesCustom = {
3358
3308
  state: state$1
3359
3309
  };
3360
3310
 
3361
- const name = 'number';
3311
+ const getRecentlyOpened = () => {
3312
+ return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
3313
+ };
3314
+
3315
+ const openWorkspaceFolder = uri => {
3316
+ return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
3317
+ };
3318
+
3362
3319
  const getPlaceholder = () => {
3363
- return '';
3320
+ return selectToOpen();
3321
+ };
3322
+ const getLabel = () => {
3323
+ return openRecent();
3364
3324
  };
3365
3325
  const getNoResults = () => {
3366
3326
  return {
3367
- label: noMatchingResults()
3327
+ label: noRecentlyOpenedFoldersFound()
3368
3328
  };
3369
3329
  };
3330
+
3331
+ // TODO could also change api so that getPicks returns an array of anything
3332
+ // and the transformPick gets the label for each pick
3333
+ // This would make the code more module since the code for getting the picks
3334
+ // would be more independent of the specific data format of the quickpick provider
3335
+
3370
3336
  const getPicks = async () => {
3371
- const picks = [{
3372
- label: '1'
3373
- }, {
3374
- label: '2'
3375
- }, {
3376
- label: '3'
3377
- }, {
3378
- label: '4'
3379
- }, {
3380
- label: '5'
3381
- }, {
3382
- label: '6'
3383
- }, {
3384
- label: '7'
3385
- }, {
3386
- label: '8'
3387
- }, {
3388
- label: '9'
3389
- }, {
3390
- label: '10'
3391
- }];
3392
- return picks;
3337
+ const recentlyOpened = await getRecentlyOpened();
3338
+ return recentlyOpened;
3393
3339
  };
3394
- const selectPick = async item => {
3340
+ const getVisibleItems = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
3341
+ const visibleItems = picks.map((pick, index) => ({
3342
+ description: getPickDescription(pick),
3343
+ fileIcon: getPickFileIcon(pick),
3344
+ icon: getPickIcon(),
3345
+ isActive: index + minLineY === focusedIndex,
3346
+ label: getPickLabel(pick),
3347
+ matches: [],
3348
+ posInSet: index + minLineY + 1,
3349
+ setSize
3350
+ }));
3351
+ return visibleItems;
3352
+ };
3353
+
3354
+ // TODO selectPick should be independent of show/hide
3355
+ const selectPick = async pick => {
3356
+ const path = pick;
3357
+ await openWorkspaceFolder(path);
3395
3358
  return {
3396
3359
  command: Hide
3397
3360
  };
3398
3361
  };
3399
- const state = {};
3400
- const getPickFilterValue = value => {
3401
- return value;
3402
- };
3403
3362
  const getFilterValue = value => {
3404
- return value;
3363
+ return pathBaseName(value);
3405
3364
  };
3406
- const getPickDescription = value => {
3407
- return '';
3365
+ const getPickFilterValue = pick => {
3366
+ return pathBaseName(pick);
3408
3367
  };
3409
- const getPickLabel = value => {
3410
- return value;
3368
+ const getPickLabel = pick => {
3369
+ return pathBaseName(pick);
3370
+ };
3371
+ const getPickDescription = pick => {
3372
+ return pathDirName(pick);
3411
3373
  };
3412
- const getPickIcon = value => {
3374
+ const getPickIcon = () => {
3413
3375
  return '';
3414
3376
  };
3377
+ const getPickFileIcon = pick => {
3378
+ if (typeof pick === 'object') {
3379
+ pick = pick.pick;
3380
+ }
3381
+ if (typeof pick === 'object') {
3382
+ pick = pick.pick;
3383
+ }
3384
+ return {
3385
+ type: Directory,
3386
+ name: pick
3387
+ };
3388
+ };
3389
+ const state = {};
3415
3390
  const isPrepared = () => {
3416
3391
  return false;
3417
3392
  };
3393
+ const name = '';
3418
3394
 
3419
- const QuickPickEntriesNumber = {
3395
+ const QuickPickEntriesOpenRecent = {
3420
3396
  __proto__: null,
3421
3397
  getFilterValue,
3398
+ getLabel,
3422
3399
  getNoResults,
3423
3400
  getPickDescription,
3401
+ getPickFileIcon,
3424
3402
  getPickFilterValue,
3425
3403
  getPickIcon,
3426
3404
  getPickLabel,
3427
3405
  getPicks,
3428
3406
  getPlaceholder,
3407
+ getVisibleItems,
3429
3408
  isPrepared,
3430
3409
  name,
3431
3410
  selectPick,
3432
3411
  state
3433
3412
  };
3434
3413
 
3414
+ const CommandPalette = 'quickPick://commandPalette';
3415
+ const Commands = 'quickPick://commands';
3416
+ const File$1 = 'quickPick://file';
3417
+ const EveryThing = 'quickPick://everything';
3418
+ const Recent = 'quickPick://recent';
3419
+ const ColorTheme = 'quickPick://color-theme';
3420
+ const Symbol = 'quickPick://symbol';
3421
+ const View = 'quickPick://view';
3422
+ const WorkspaceSymbol = 'quickPick://workspace-symbol';
3423
+ const Custom = 'quickPick://custom';
3424
+
3435
3425
  const quickPickEntriesModules = {
3436
3426
  [CommandPalette]: QuickPickEntriesEverything,
3437
3427
  [Commands]: QuickPickEntriesEverything,
3438
3428
  [File$1]: QuickPickEntriesEverything,
3439
3429
  [EveryThing]: QuickPickEntriesEverything,
3440
3430
  [WorkspaceSymbol]: QuickPickEntriesEverything,
3441
- [Number$1]: QuickPickEntriesNumber,
3442
3431
  [Recent]: QuickPickEntriesOpenRecent,
3443
3432
  [ColorTheme]: QuickPickEntriesColorTheme,
3444
3433
  [Symbol]: QuickPickEntriesSymbol,