@lvce-editor/file-search-worker 4.5.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
  };
@@ -888,6 +888,32 @@ const Script = 2;
888
888
 
889
889
  const minimumSliderSize = 20;
890
890
 
891
+ const Command = '>';
892
+ const Symbol$1 = '@';
893
+ const WorkspaceSymbol$1 = '#';
894
+ const GoToLine = ':';
895
+ const View$1 = 'view ';
896
+ const None$2 = '';
897
+
898
+ const getQuickPickPrefix = value => {
899
+ if (value.startsWith(Command)) {
900
+ return Command;
901
+ }
902
+ if (value.startsWith(Symbol$1)) {
903
+ return Symbol$1;
904
+ }
905
+ if (value.startsWith(WorkspaceSymbol$1)) {
906
+ return WorkspaceSymbol$1;
907
+ }
908
+ if (value.startsWith(GoToLine)) {
909
+ return GoToLine;
910
+ }
911
+ if (value.startsWith(View$1)) {
912
+ return View$1;
913
+ }
914
+ return None$2;
915
+ };
916
+
891
917
  const handleError = async (error, notify = true, prefix = '') => {
892
918
  console.error(error);
893
919
  };
@@ -908,14 +934,14 @@ const warn = (...args) => {
908
934
  console.warn(...args);
909
935
  };
910
936
 
911
- const state$9 = {
937
+ const state$8 = {
912
938
  menuEntries: []
913
939
  };
914
940
  const getAll = () => {
915
- return state$9.menuEntries;
941
+ return state$8.menuEntries;
916
942
  };
917
943
  const add = menuEntries => {
918
- state$9.menuEntries = [...state$9.menuEntries, ...menuEntries];
944
+ state$8.menuEntries = [...state$8.menuEntries, ...menuEntries];
919
945
  };
920
946
 
921
947
  const Hide = 'hide';
@@ -934,7 +960,6 @@ const i18nString = (key, placeholders = emptyObject) => {
934
960
  };
935
961
 
936
962
  const Files = 'Files';
937
- const GoToFile = 'Go to file';
938
963
  const NoMatchingColorThemesFound = 'No matching color themes found';
939
964
  const NoMatchingResults = 'No matching results';
940
965
  const NoRecentlyOpenedFoldersFound = 'No recently opened folders found';
@@ -944,7 +969,6 @@ const NoWorkspaceSymbolsFound = 'no workspace symbols found';
944
969
  const OpenRecent = 'Open Recent';
945
970
  const SelectColorTheme = 'Select Color Theme';
946
971
  const SelectToOpen = 'Select to open';
947
- const ShowAndRunCommands = 'Show And Run Commands';
948
972
  const TypeNameOfCommandToRun = 'Type the name of a command to run.';
949
973
  const QuickOpen = 'Quick open';
950
974
 
@@ -957,18 +981,12 @@ const selectColorTheme = () => {
957
981
  const typeNameofCommandToRun = () => {
958
982
  return i18nString(TypeNameOfCommandToRun);
959
983
  };
960
- const showAndRunCommands = () => {
961
- return i18nString(ShowAndRunCommands);
962
- };
963
984
  const noMatchingResults = () => {
964
985
  return i18nString(NoMatchingResults);
965
986
  };
966
987
  const files = () => {
967
988
  return i18nString(Files);
968
989
  };
969
- const goToFile = () => {
970
- return i18nString(GoToFile);
971
- };
972
990
  const noResults = () => {
973
991
  return i18nString(NoResults);
974
992
  };
@@ -991,20 +1009,14 @@ const quickOpen = () => {
991
1009
  return i18nString(QuickOpen);
992
1010
  };
993
1011
 
994
- const name$b = 'command';
995
- const getPlaceholder$b = () => {
1012
+ const name$a = 'command';
1013
+ const getPlaceholder$a = () => {
996
1014
  return typeNameofCommandToRun();
997
1015
  };
998
- const helpEntries = () => {
999
- return [{
1000
- description: showAndRunCommands(),
1001
- category: 'global commands'
1002
- }];
1003
- };
1004
1016
  const getLabel$5 = () => {
1005
1017
  return '';
1006
1018
  };
1007
- const getNoResults$b = () => {
1019
+ const getNoResults$a = () => {
1008
1020
  return {
1009
1021
  label: noMatchingResults()
1010
1022
  };
@@ -1045,10 +1057,24 @@ const getExtensionPicks = async () => {
1045
1057
 
1046
1058
  // TODO send strings to renderer process only once for next occurrence send uint16array of ids of strings
1047
1059
 
1048
- const getPicks$b = async () => {
1060
+ const getPicks$a = async () => {
1049
1061
  const builtinPicks = await getBuiltinPicks();
1050
1062
  const extensionPicks = await getExtensionPicks();
1051
- return [...builtinPicks, ...extensionPicks];
1063
+ const allPicks = [...builtinPicks, ...extensionPicks];
1064
+ return allPicks;
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;
1052
1078
  };
1053
1079
  const shouldHide = item => {
1054
1080
  if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
@@ -1081,38 +1107,38 @@ const selectPickExtension = async item => {
1081
1107
  command: Hide
1082
1108
  };
1083
1109
  };
1084
- const selectPick$b = async item => {
1110
+ const selectPick$a = async item => {
1085
1111
  if (item.id.startsWith('ext.')) {
1086
1112
  return selectPickExtension(item);
1087
1113
  }
1088
1114
  return selectPickBuiltin(item);
1089
1115
  };
1090
- const getFilterValue$b = value => {
1091
- return value;
1116
+ const getFilterValue$a = value => {
1117
+ return value.trim();
1092
1118
  };
1093
- const getPickFilterValue$9 = pick => {
1119
+ const getPickFilterValue$8 = pick => {
1094
1120
  return pick.label;
1095
1121
  };
1096
- const getPickLabel$8 = pick => {
1122
+ const getPickLabel$7 = pick => {
1097
1123
  return pick.label;
1098
1124
  };
1099
- const getPickIcon$8 = () => {
1125
+ const getPickIcon$7 = () => {
1100
1126
  return '';
1101
1127
  };
1102
1128
 
1103
1129
  const QuickPickEntriesCommand = {
1104
1130
  __proto__: null,
1105
- getFilterValue: getFilterValue$b,
1131
+ getFilterValue: getFilterValue$a,
1106
1132
  getLabel: getLabel$5,
1107
- getNoResults: getNoResults$b,
1108
- getPickFilterValue: getPickFilterValue$9,
1109
- getPickIcon: getPickIcon$8,
1110
- getPickLabel: getPickLabel$8,
1111
- getPicks: getPicks$b,
1112
- getPlaceholder: getPlaceholder$b,
1113
- helpEntries,
1114
- name: name$b,
1115
- 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
1116
1142
  };
1117
1143
 
1118
1144
  const Directory = 3;
@@ -1127,16 +1153,20 @@ const getProtocol = uri => {
1127
1153
  return '';
1128
1154
  };
1129
1155
 
1156
+ const getWorkspacePath = async () => {
1157
+ return invoke$1('Workspace.getPath');
1158
+ };
1159
+
1130
1160
  const openUri = async uri => {
1131
1161
  await invoke$1(/* Main.openUri */'Main.openUri', /* uri */uri);
1132
1162
  };
1133
1163
 
1134
- const state$8 = Object.create(null);
1164
+ const state$7 = Object.create(null);
1135
1165
  const register$1 = modules => {
1136
- Object.assign(state$8, modules);
1166
+ Object.assign(state$7, modules);
1137
1167
  };
1138
1168
  const getModule = protocol => {
1139
- return state$8[protocol];
1169
+ return state$7[protocol];
1140
1170
  };
1141
1171
 
1142
1172
  const searchFile$5 = async (path, value, prepare, assetDir) => {
@@ -1168,71 +1198,62 @@ const searchFile$4 = async (path, value) => {
1168
1198
  const files = await searchFile$5(/* path */path, /* searchTerm */value, prepare);
1169
1199
  return files;
1170
1200
  };
1171
- const name$a = 'file';
1172
- const getPlaceholder$a = () => {
1201
+ const name$9 = 'file';
1202
+ const getPlaceholder$9 = () => {
1173
1203
  return '';
1174
1204
  };
1175
1205
  const getLabel$4 = () => {
1176
1206
  return files();
1177
1207
  };
1178
-
1179
- // TODO help entries should not be here
1180
- const getHelpEntries$a = () => {
1181
- return [{
1182
- description: goToFile(),
1183
- category: 'global commands'
1184
- }];
1185
- };
1186
- const getNoResults$a = () => {
1208
+ const getNoResults$9 = () => {
1187
1209
  return {
1188
1210
  label: noMatchingResults()
1189
1211
  };
1190
1212
  };
1191
- const getPicks$a = async searchValue => {
1213
+ const getPicks$9 = async searchValue => {
1192
1214
  // TODO cache workspace path
1193
- const workspace = await invoke$1('Workspace.getPath');
1215
+ const workspace = await getWorkspacePath();
1194
1216
  if (!workspace) {
1195
1217
  return [];
1196
1218
  }
1197
1219
  const files = await searchFile$4(workspace, searchValue);
1198
- // const picks = files.map(toPick)
1199
1220
  return files;
1200
1221
  };
1201
- const selectPick$a = async pick => {
1222
+ const selectPick$9 = async pick => {
1202
1223
  if (typeof pick === 'object') {
1203
1224
  pick = pick.pick;
1204
1225
  }
1205
- const workspace = await invoke$1('Workspace.getPath');
1226
+ const workspace = await getWorkspacePath();
1206
1227
  const absolutePath = `${workspace}/${pick}`;
1207
1228
  await openUri(absolutePath);
1208
1229
  return {
1209
1230
  command: Hide
1210
1231
  };
1211
1232
  };
1212
- const getFilterValue$a = value => {
1233
+ const getFilterValue$9 = value => {
1213
1234
  return value;
1214
1235
  };
1215
- const getPickFilterValue$8 = pick => {
1236
+ const getPickFilterValue$7 = pick => {
1216
1237
  if (typeof pick === 'object') {
1217
1238
  pick = pick.pick;
1218
1239
  }
1219
1240
  return pick;
1220
1241
  };
1221
- const getPickLabel$7 = pick => {
1242
+ const getPickLabel$6 = pick => {
1222
1243
  if (typeof pick === 'object') {
1223
1244
  pick = pick.pick;
1224
1245
  }
1225
1246
  const baseName = pathBaseName(pick);
1226
1247
  return baseName;
1227
1248
  };
1228
- const getPickDescription$8 = pick => {
1249
+ const getPickDescription$6 = pick => {
1229
1250
  if (typeof pick === 'object') {
1230
1251
  pick = pick.pick;
1231
1252
  }
1232
1253
  const dirName = pathDirName(pick);
1233
1254
  return dirName;
1234
1255
  };
1235
- const getPickIcon$7 = () => {
1256
+ const getPickIcon$6 = () => {
1236
1257
  return '';
1237
1258
  };
1238
1259
  const getPickFileIcon$2 = pick => {
@@ -1245,49 +1266,70 @@ const getPickFileIcon$2 = pick => {
1245
1266
  const baseName = pathBaseName(pick);
1246
1267
  return {
1247
1268
  type: File$2,
1248
- name: baseName
1269
+ name: baseName,
1270
+ path: pick
1249
1271
  };
1250
1272
  };
1251
- const isPrepared$7 = () => {
1273
+ const isPrepared$6 = () => {
1252
1274
  const workspace = '';
1253
1275
  // TODO protocol should always be defined. For files it should use file protocol
1254
1276
  const protocol = getProtocol(workspace);
1255
1277
  return !protocol;
1256
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
+ };
1257
1299
 
1258
1300
  const QuickPickEntriesFile = {
1259
1301
  __proto__: null,
1260
- getFilterValue: getFilterValue$a,
1261
- getHelpEntries: getHelpEntries$a,
1302
+ getFilterValue: getFilterValue$9,
1262
1303
  getLabel: getLabel$4,
1263
- getNoResults: getNoResults$a,
1264
- getPickDescription: getPickDescription$8,
1304
+ getNoResults: getNoResults$9,
1305
+ getPickDescription: getPickDescription$6,
1265
1306
  getPickFileIcon: getPickFileIcon$2,
1266
- getPickFilterValue: getPickFilterValue$8,
1267
- getPickIcon: getPickIcon$7,
1268
- getPickLabel: getPickLabel$7,
1269
- getPicks: getPicks$a,
1270
- getPlaceholder: getPlaceholder$a,
1271
- isPrepared: isPrepared$7,
1272
- name: name$a,
1273
- 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
1274
1316
  };
1275
1317
 
1276
1318
  const execute = async (method, ...params) => {
1277
1319
  // TODO
1278
1320
  };
1279
1321
 
1280
- const name$9 = 'goToLine';
1281
- const getPlaceholder$9 = () => {
1322
+ const name$8 = 'goToLine';
1323
+ const getPlaceholder$8 = () => {
1282
1324
  return '';
1283
1325
  };
1284
- const getHelpEntries$9 = () => {
1326
+ const getHelpEntries$3 = () => {
1285
1327
  return [];
1286
1328
  };
1287
- const getNoResults$9 = () => {
1329
+ const getNoResults$8 = () => {
1288
1330
  return undefined;
1289
1331
  };
1290
- const getPicks$9 = async () => {
1332
+ const getPicks$8 = async () => {
1291
1333
  const picks = [{
1292
1334
  label: '1'
1293
1335
  }, {
@@ -1303,7 +1345,7 @@ const getPicks$9 = async () => {
1303
1345
  }];
1304
1346
  return picks;
1305
1347
  };
1306
- const selectPick$9 = async item => {
1348
+ const selectPick$8 = async item => {
1307
1349
  const rowIndex = Number.parseInt(item.label);
1308
1350
  const position = {
1309
1351
  rowIndex,
@@ -1315,54 +1357,31 @@ const selectPick$9 = async item => {
1315
1357
  command: Hide
1316
1358
  };
1317
1359
  };
1318
- const getFilterValue$9 = value => {
1319
- return value;
1320
- };
1321
-
1322
- const QuickPickEntriesGoToLine = {
1323
- __proto__: null,
1324
- getFilterValue: getFilterValue$9,
1325
- getHelpEntries: getHelpEntries$9,
1326
- getNoResults: getNoResults$9,
1327
- getPicks: getPicks$9,
1328
- getPlaceholder: getPlaceholder$9,
1329
- name: name$9,
1330
- selectPick: selectPick$9
1331
- };
1332
-
1333
- const name$8 = 'noop';
1334
- const getPlaceholder$8 = () => {
1335
- return '';
1336
- };
1337
- const getHelpEntries$8 = () => {
1338
- return [];
1339
- };
1340
- const getNoResults$8 = () => {
1341
- return noResults();
1342
- };
1343
- const getPicks$8 = async value => {
1344
- return [];
1345
- };
1346
- const selectPick$8 = async item => {
1347
- return {
1348
- command: Hide
1349
- };
1350
- };
1351
1360
  const getFilterValue$8 = value => {
1352
1361
  return value;
1353
1362
  };
1354
- const getPickFilterValue$7 = pick => {
1355
- return pick;
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;
1356
1375
  };
1357
1376
 
1358
- const QuickPickNoop = {
1377
+ const QuickPickEntriesGoToLine = {
1359
1378
  __proto__: null,
1360
1379
  getFilterValue: getFilterValue$8,
1361
- getHelpEntries: getHelpEntries$8,
1380
+ getHelpEntries: getHelpEntries$3,
1362
1381
  getNoResults: getNoResults$8,
1363
- getPickFilterValue: getPickFilterValue$7,
1364
1382
  getPicks: getPicks$8,
1365
1383
  getPlaceholder: getPlaceholder$8,
1384
+ getVisibleItems: getVisibleItems$8,
1366
1385
  name: name$8,
1367
1386
  selectPick: selectPick$8
1368
1387
  };
@@ -1371,9 +1390,6 @@ const name$7 = 'symbol';
1371
1390
  const getPlaceholder$7 = () => {
1372
1391
  return '';
1373
1392
  };
1374
- const getHelpEntries$7 = () => {
1375
- return [];
1376
- };
1377
1393
  const getNoResults$7 = () => {
1378
1394
  return {
1379
1395
  label: noSymbolFound()
@@ -1383,6 +1399,9 @@ const getPicks$7 = async () => {
1383
1399
  const picks = [];
1384
1400
  return picks;
1385
1401
  };
1402
+ const getVisibleItems$7 = (picks, minLineY, maxLineY, focusedIndex, setSize) => {
1403
+ return [];
1404
+ };
1386
1405
  const selectPick$7 = async item => {
1387
1406
  return {
1388
1407
  command: Hide
@@ -1391,38 +1410,38 @@ const selectPick$7 = async item => {
1391
1410
  const getFilterValue$7 = value => {
1392
1411
  return value;
1393
1412
  };
1394
- const state$7 = {};
1395
- const getPickDescription$7 = value => {
1413
+ const state$6 = {};
1414
+ const getPickDescription$5 = value => {
1396
1415
  return '';
1397
1416
  };
1398
- const isPrepared$6 = () => {
1417
+ const isPrepared$5 = () => {
1399
1418
  return false;
1400
1419
  };
1401
1420
  const getPickFilterValue$6 = value => {
1402
1421
  return value;
1403
1422
  };
1404
- const getPickLabel$6 = value => {
1423
+ const getPickLabel$5 = value => {
1405
1424
  return value;
1406
1425
  };
1407
- const getPickIcon$6 = value => {
1426
+ const getPickIcon$5 = value => {
1408
1427
  return '';
1409
1428
  };
1410
1429
 
1411
1430
  const QuickPickEntriesSymbol = {
1412
1431
  __proto__: null,
1413
1432
  getFilterValue: getFilterValue$7,
1414
- getHelpEntries: getHelpEntries$7,
1415
1433
  getNoResults: getNoResults$7,
1416
- getPickDescription: getPickDescription$7,
1434
+ getPickDescription: getPickDescription$5,
1417
1435
  getPickFilterValue: getPickFilterValue$6,
1418
- getPickIcon: getPickIcon$6,
1419
- getPickLabel: getPickLabel$6,
1436
+ getPickIcon: getPickIcon$5,
1437
+ getPickLabel: getPickLabel$5,
1420
1438
  getPicks: getPicks$7,
1421
1439
  getPlaceholder: getPlaceholder$7,
1422
- isPrepared: isPrepared$6,
1440
+ getVisibleItems: getVisibleItems$7,
1441
+ isPrepared: isPrepared$5,
1423
1442
  name: name$7,
1424
1443
  selectPick: selectPick$7,
1425
- state: state$7
1444
+ state: state$6
1426
1445
  };
1427
1446
 
1428
1447
  // TODO probably not needed
@@ -1430,7 +1449,7 @@ const QuickPickEntriesSymbol = {
1430
1449
  const getPlaceholder$6 = () => {
1431
1450
  return typeNameofCommandToRun();
1432
1451
  };
1433
- const getHelpEntries$6 = () => {
1452
+ const getHelpEntries$2 = () => {
1434
1453
  return undefined;
1435
1454
  };
1436
1455
  const getPicks$6 = async () => {
@@ -1451,48 +1470,59 @@ const getFilterValue$6 = value => {
1451
1470
  const getPickFilterValue$5 = value => {
1452
1471
  return value;
1453
1472
  };
1454
- const getPickLabel$5 = value => {
1473
+ const getPickLabel$4 = value => {
1455
1474
  return value;
1456
1475
  };
1457
- const getPickIcon$5 = value => {
1476
+ const getPickIcon$4 = value => {
1458
1477
  return '';
1459
1478
  };
1460
- const state$6 = {};
1479
+ const state$5 = {};
1461
1480
  const getNoResults$6 = () => {
1462
1481
  return '';
1463
1482
  };
1464
1483
  const name$6 = '';
1465
- const isPrepared$5 = () => {
1484
+ const isPrepared$4 = () => {
1466
1485
  return true;
1467
1486
  };
1468
- const getPickDescription$6 = () => {
1487
+ const getPickDescription$4 = () => {
1469
1488
  return '';
1470
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
+ };
1471
1503
 
1472
1504
  const QuickPickEntriesView = {
1473
1505
  __proto__: null,
1474
1506
  getFilterValue: getFilterValue$6,
1475
- getHelpEntries: getHelpEntries$6,
1507
+ getHelpEntries: getHelpEntries$2,
1476
1508
  getNoResults: getNoResults$6,
1477
- getPickDescription: getPickDescription$6,
1509
+ getPickDescription: getPickDescription$4,
1478
1510
  getPickFilterValue: getPickFilterValue$5,
1479
- getPickIcon: getPickIcon$5,
1480
- getPickLabel: getPickLabel$5,
1511
+ getPickIcon: getPickIcon$4,
1512
+ getPickLabel: getPickLabel$4,
1481
1513
  getPicks: getPicks$6,
1482
1514
  getPlaceholder: getPlaceholder$6,
1483
- isPrepared: isPrepared$5,
1515
+ getVisibleItems: getVisibleItems$6,
1516
+ isPrepared: isPrepared$4,
1484
1517
  name: name$6,
1485
1518
  selectPick: selectPick$6,
1486
- state: state$6
1519
+ state: state$5
1487
1520
  };
1488
1521
 
1489
1522
  const name$5 = 'workspace-symbol';
1490
1523
  const getPlaceholder$5 = () => {
1491
1524
  return '';
1492
1525
  };
1493
- const getHelpEntries$5 = () => {
1494
- return [];
1495
- };
1496
1526
  const getNoResults$5 = () => {
1497
1527
  return {
1498
1528
  label: noWorkspaceSymbolsFound()
@@ -1510,67 +1540,31 @@ const selectPick$5 = async item => {
1510
1540
  const getFilterValue$5 = value => {
1511
1541
  return value;
1512
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
+ };
1513
1556
 
1514
1557
  const QuickPickEntriesWorkspaceSymbol = {
1515
1558
  __proto__: null,
1516
1559
  getFilterValue: getFilterValue$5,
1517
- getHelpEntries: getHelpEntries$5,
1518
1560
  getNoResults: getNoResults$5,
1519
1561
  getPicks: getPicks$5,
1520
1562
  getPlaceholder: getPlaceholder$5,
1563
+ getVisibleItems: getVisibleItems$5,
1521
1564
  name: name$5,
1522
1565
  selectPick: selectPick$5
1523
1566
  };
1524
1567
 
1525
- const Command = '>';
1526
- const Symbol$1 = '@';
1527
- const WorkspaceSymbol$1 = '#';
1528
- const GoToLine = ':';
1529
- const View$1 = 'view ';
1530
- const None$2 = '';
1531
-
1532
- // TODO avoid global variable
1533
-
1534
- const state$5 = {
1535
- // providerId: PROVIDER_NOOP,
1536
- provider: QuickPickNoop,
1537
- prefix: 'string-that-should-never-match-another-string'
1538
- };
1539
-
1540
- /**
1541
- * @type {string}
1542
- */
1543
- const name$4 = 'everything';
1544
- const getPlaceholder$4 = () => {
1545
- return state$5.provider.getPlaceholder();
1546
- };
1547
- const getLabel$3 = () => {
1548
- return '';
1549
- };
1550
- const getHelpEntries$4 = () => {
1551
- return state$5.provider.getHelpEntries();
1552
- };
1553
- const getNoResults$4 = () => {
1554
- return state$5.provider.getNoResults();
1555
- };
1556
- const getPrefix = value => {
1557
- if (value.startsWith(Command)) {
1558
- return Command;
1559
- }
1560
- if (value.startsWith(Symbol$1)) {
1561
- return Symbol$1;
1562
- }
1563
- if (value.startsWith(WorkspaceSymbol$1)) {
1564
- return WorkspaceSymbol$1;
1565
- }
1566
- if (value.startsWith(GoToLine)) {
1567
- return GoToLine;
1568
- }
1569
- if (value.startsWith(View$1)) {
1570
- return View$1;
1571
- }
1572
- return None$2;
1573
- };
1574
1568
  const getQuickPickProvider = prefix => {
1575
1569
  // TODO could use enum for prefix
1576
1570
  // TODO could use regex to extract prefix
@@ -1590,81 +1584,139 @@ const getQuickPickProvider = prefix => {
1590
1584
  return QuickPickEntriesFile;
1591
1585
  }
1592
1586
  };
1593
- const getPicks$4 = async value => {
1594
- const prefix = getPrefix(value);
1595
1587
 
1596
- // TODO race condition
1597
- if (state$5.prefix !== prefix) {
1598
- state$5.prefix = prefix;
1599
- // @ts-ignore
1600
- state$5.provider = await getQuickPickProvider(prefix);
1601
- }
1602
- // TODO this line is a bit duplicated with getFilterValue
1603
- const slicedValue = value.slice(prefix.length).trimStart();
1604
- const picks = await state$5.provider.getPicks(slicedValue);
1605
- return picks;
1588
+ const name$4 = 'noop';
1589
+ const getPlaceholder$4 = () => {
1590
+ return '';
1606
1591
  };
1607
- const selectPick$4 = item => {
1608
- const {
1609
- provider
1610
- } = state$5;
1611
- return provider.selectPick(item);
1592
+ const getNoResults$4 = () => {
1593
+ return noResults();
1612
1594
  };
1613
- const openCommandPalette = () => {
1614
- // show('>')
1595
+ const getPicks$4 = async value => {
1596
+ return [];
1615
1597
  };
1616
- const openView = () => {
1617
- // show('view ')
1598
+ const selectPick$4 = async item => {
1599
+ return {
1600
+ command: Hide
1601
+ };
1618
1602
  };
1619
1603
  const getFilterValue$4 = value => {
1620
- return value.slice(state$5.prefix.length);
1604
+ return value;
1621
1605
  };
1622
1606
  const getPickFilterValue$4 = pick => {
1623
- const {
1624
- provider
1625
- } = state$5;
1626
- return provider.getPickFilterValue(pick);
1607
+ return pick;
1627
1608
  };
1628
- const getPickDescription$5 = pick => {
1629
- const {
1630
- provider
1631
- } = state$5;
1632
- // @ts-ignore
1633
- if (provider.getPickDescription) {
1609
+ const getVisibleItems$4 = (picks, minLineY, maxLineY, focusedIndex, setSize, icons) => {
1610
+ return [];
1611
+ };
1612
+
1613
+ const QuickPickNoop = {
1614
+ __proto__: null,
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
1623
+ };
1624
+
1625
+ // TODO avoid global variable
1626
+
1627
+ const state$4 = {
1628
+ // providerId: PROVIDER_NOOP,
1629
+ provider: QuickPickNoop,
1630
+ prefix: 'string-that-should-never-match-another-string'
1631
+ };
1632
+
1633
+ /**
1634
+ * @type {string}
1635
+ */
1636
+ const name$3 = 'everything';
1637
+ const getPlaceholder$3 = () => {
1638
+ return state$4.provider.getPlaceholder();
1639
+ };
1640
+ const getLabel$3 = () => {
1641
+ return '';
1642
+ };
1643
+ const getNoResults$3 = () => {
1644
+ return state$4.provider.getNoResults();
1645
+ };
1646
+ const getPicks$3 = async value => {
1647
+ const prefix = getQuickPickPrefix(value);
1648
+
1649
+ // TODO race condition
1650
+ if (state$4.prefix !== prefix) {
1651
+ state$4.prefix = prefix;
1652
+ state$4.provider = await getQuickPickProvider(prefix);
1653
+ }
1654
+ // TODO this line is a bit duplicated with getFilterValue
1655
+ const slicedValue = value.slice(prefix.length).trimStart();
1656
+ const picks = await state$4.provider.getPicks(slicedValue);
1657
+ return picks;
1658
+ };
1659
+ const selectPick$3 = item => {
1660
+ const {
1661
+ provider
1662
+ } = state$4;
1663
+ return provider.selectPick(item);
1664
+ };
1665
+ const openCommandPalette = () => {
1666
+ // show('>')
1667
+ };
1668
+ const openView = () => {
1669
+ // show('view ')
1670
+ };
1671
+ const getFilterValue$3 = value => {
1672
+ return value.slice(state$4.prefix.length).trim();
1673
+ };
1674
+ const getPickFilterValue$3 = pick => {
1675
+ const {
1676
+ provider
1677
+ } = state$4;
1678
+ return provider.getPickFilterValue(pick);
1679
+ };
1680
+ const getPickDescription$3 = pick => {
1681
+ const {
1682
+ provider
1683
+ } = state$4;
1684
+ // @ts-ignore
1685
+ if (provider.getPickDescription) {
1634
1686
  // @ts-ignore
1635
1687
  return provider.getPickDescription(pick);
1636
1688
  }
1637
1689
  return '';
1638
1690
  };
1639
- const getPickLabel$4 = pick => {
1691
+ const getPickLabel$3 = pick => {
1640
1692
  const {
1641
1693
  provider
1642
- } = state$5;
1694
+ } = state$4;
1643
1695
  // @ts-ignore
1644
1696
  return provider.getPickLabel(pick);
1645
1697
  };
1646
- const getPickIcon$4 = pick => {
1698
+ const getPickIcon$3 = pick => {
1647
1699
  const {
1648
1700
  provider
1649
- } = state$5;
1701
+ } = state$4;
1650
1702
  // @ts-ignore
1651
1703
  return provider.getPickIcon(pick);
1652
1704
  };
1653
1705
  const getPickFileIcon$1 = pick => {
1654
1706
  const {
1655
1707
  provider
1656
- } = state$5;
1708
+ } = state$4;
1657
1709
  // @ts-ignore
1658
1710
  if (provider.getPickFileIcon) {
1659
1711
  // @ts-ignore
1660
1712
  return provider.getPickFileIcon(pick);
1661
1713
  }
1662
- return '';
1714
+ return undefined;
1663
1715
  };
1664
- const isPrepared$4 = () => {
1716
+ const isPrepared$3 = () => {
1665
1717
  const {
1666
1718
  provider
1667
- } = state$5;
1719
+ } = state$4;
1668
1720
  // @ts-ignore
1669
1721
  if (provider.isPrepared) {
1670
1722
  // @ts-ignore
@@ -1672,26 +1724,39 @@ const isPrepared$4 = () => {
1672
1724
  }
1673
1725
  return false;
1674
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
1675
1740
 
1676
1741
  const QuickPickEntriesEverything = {
1677
1742
  __proto__: null,
1678
- getFilterValue: getFilterValue$4,
1679
- getHelpEntries: getHelpEntries$4,
1743
+ getFilterValue: getFilterValue$3,
1680
1744
  getLabel: getLabel$3,
1681
- getNoResults: getNoResults$4,
1682
- getPickDescription: getPickDescription$5,
1745
+ getNoResults: getNoResults$3,
1746
+ getPickDescription: getPickDescription$3,
1683
1747
  getPickFileIcon: getPickFileIcon$1,
1684
- getPickFilterValue: getPickFilterValue$4,
1685
- getPickIcon: getPickIcon$4,
1686
- getPickLabel: getPickLabel$4,
1687
- getPicks: getPicks$4,
1688
- getPlaceholder: getPlaceholder$4,
1689
- isPrepared: isPrepared$4,
1690
- 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,
1691
1756
  openCommandPalette,
1692
1757
  openView,
1693
- selectPick: selectPick$4,
1694
- state: state$5
1758
+ selectPick: selectPick$3,
1759
+ state: state$4
1695
1760
  };
1696
1761
 
1697
1762
  const Default$1 = 0;
@@ -1716,7 +1781,7 @@ const create$2 = () => {
1716
1781
  };
1717
1782
 
1718
1783
  const {
1719
- get,
1784
+ get: get$1,
1720
1785
  set,
1721
1786
  remove
1722
1787
  } = create$2();
@@ -1790,6 +1855,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
1790
1855
  const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) => {
1791
1856
  const state = {
1792
1857
  uid,
1858
+ icons: [],
1793
1859
  state: Default$1,
1794
1860
  picks: [],
1795
1861
  recentPicks: [],
@@ -1799,7 +1865,6 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) =
1799
1865
  provider: QuickPickEntriesEverything,
1800
1866
  // TODO make this dynamic again
1801
1867
  warned: [],
1802
- visiblePicks: [],
1803
1868
  maxVisibleItems: 10,
1804
1869
  uri,
1805
1870
  cursorOffset: 0,
@@ -1815,204 +1880,136 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) =
1815
1880
  args,
1816
1881
  focused: false,
1817
1882
  platform,
1818
- value: ''
1883
+ value: '',
1884
+ fileIconCache: Object.create(null)
1819
1885
  };
1820
1886
  set(uid, state, state);
1821
1887
  };
1822
1888
 
1823
- const dispose = uid => {
1824
- remove(uid);
1889
+ const RenderItems = 1;
1890
+ const RenderFocus = 2;
1891
+ const RenderValue = 3;
1892
+ const RenderCursorOffset = 7;
1893
+ const RenderFocusedIndex = 8;
1894
+ const Height = 9;
1895
+
1896
+ const diffType$4 = RenderFocus;
1897
+ const isEqual$4 = (oldState, newState) => {
1898
+ return oldState.focused === newState.focused;
1825
1899
  };
1826
1900
 
1827
- const emptyMatches = [];
1901
+ const diffType$3 = RenderFocusedIndex;
1902
+ const isEqual$3 = (oldState, newState) => {
1903
+ return oldState.focusedIndex === newState.focusedIndex;
1904
+ };
1828
1905
 
1829
- const convertToPick = item => {
1830
- return {
1831
- pick: item,
1832
- matches: emptyMatches
1833
- };
1906
+ const diffType$2 = Height;
1907
+ const isEqual$2 = (oldState, newState) => {
1908
+ return oldState.items.length === newState.items.length;
1834
1909
  };
1835
1910
 
1836
- const Diagonal = 1;
1837
- const Left = 2;
1911
+ const diffType$1 = RenderItems;
1912
+ const isEqual$1 = (oldState, newState) => {
1913
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
1914
+ };
1838
1915
 
1839
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1916
+ const diffType = RenderValue;
1917
+ const isEqual = (oldState, newState) => {
1918
+ return newState.inputSource === User || oldState.value === newState.value;
1919
+ };
1840
1920
 
1841
- const createTable = size => {
1842
- const table = [];
1843
- for (let i = 0; i < size; i++) {
1844
- const row = new Uint8Array(size);
1845
- table.push(row);
1921
+ const modules = [isEqual$2, isEqual$1, isEqual, isEqual$3, isEqual$4];
1922
+ const numbers = [diffType$2, diffType$1, diffType, diffType$3, diffType$4];
1923
+
1924
+ const diff = (oldState, newState) => {
1925
+ const diffResult = [];
1926
+ for (let i = 0; i < modules.length; i++) {
1927
+ const fn = modules[i];
1928
+ if (!fn(oldState, newState)) {
1929
+ diffResult.push(numbers[i]);
1930
+ }
1846
1931
  }
1847
- return table;
1932
+ return diffResult;
1848
1933
  };
1849
- const EmptyMatches = [];
1850
- const Dash = '-';
1851
- const Dot = '.';
1852
- const EmptyString = '';
1853
- const Space = ' ';
1854
- const Underline = '_';
1855
- const T = 't';
1856
- const isLowerCase = char => {
1857
- return char === char.toLowerCase();
1934
+
1935
+ const diff2 = uid => {
1936
+ const {
1937
+ oldState,
1938
+ newState
1939
+ } = get$1(uid);
1940
+ return diff(oldState, newState);
1858
1941
  };
1859
- const isUpperCase = char => {
1860
- return char === char.toUpperCase();
1942
+
1943
+ const dispose = uid => {
1944
+ remove(uid);
1861
1945
  };
1862
1946
 
1863
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1864
- const isGap = (columnCharBefore, columnChar) => {
1865
- switch (columnCharBefore) {
1866
- case Dash:
1867
- case Underline:
1868
- case EmptyString:
1869
- case T:
1870
- case Space:
1871
- case Dot:
1872
- return true;
1873
- }
1874
- if (isLowerCase(columnCharBefore) && isUpperCase(columnChar)) {
1875
- return true;
1876
- }
1877
- return false;
1947
+ const getIconsCached = (paths, fileIconCache) => {
1948
+ return paths.map(path => fileIconCache[path]);
1878
1949
  };
1879
1950
 
1880
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1881
- const getScore = (rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch) => {
1882
- if (rowCharLow !== columnCharLow) {
1883
- return -1;
1884
- }
1885
- const isMatch = rowChar === columnChar;
1886
- if (isMatch) {
1887
- if (isDiagonalMatch) {
1888
- return 8;
1889
- }
1890
- if (isGap(columnCharBefore, columnChar)) {
1891
- return 8;
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
+ });
1892
1960
  }
1893
- return 5;
1894
1961
  }
1895
- if (isGap(columnCharBefore, columnChar)) {
1896
- return 8;
1897
- }
1898
- return 5;
1962
+ return missingRequests;
1899
1963
  };
1900
1964
 
1901
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1902
-
1903
- const isPatternInWord = (patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) => {
1904
- while (patternPos < patternLen && wordPos < wordLen) {
1905
- if (patternLow[patternPos] === wordLow[wordPos]) {
1906
- patternPos += 1;
1965
+ const requestFileIcons = async requests => {
1966
+ const promises = requests.map(request => {
1967
+ if (!request.name) {
1968
+ return '';
1907
1969
  }
1908
- wordPos += 1;
1909
- }
1910
- return patternPos === patternLen; // pattern must be exhausted
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);
1911
1977
  };
1912
1978
 
1913
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1914
- const traceHighlights = (table, arrows, patternLength, wordLength) => {
1915
- let row = patternLength;
1916
- let column = wordLength;
1917
- const matches = [];
1918
- while (row >= 1 && column >= 1) {
1919
- const arrow = arrows[row][column];
1920
- if (arrow === Left) {
1921
- column--;
1922
- } else if (arrow === Diagonal) {
1923
- row--;
1924
- column--;
1925
- const start = column + 1;
1926
- while (row >= 1 && column >= 1) {
1927
- const arrow = arrows[row][column];
1928
- if (arrow === Left) {
1929
- break;
1930
- }
1931
- if (arrow === Diagonal) {
1932
- row--;
1933
- column--;
1934
- }
1935
- }
1936
- const end = column;
1937
- matches.unshift(end, start);
1938
- }
1979
+ const updateIconCache = (iconCache, missingRequests, newIcons) => {
1980
+ if (missingRequests.length === 0) {
1981
+ return iconCache;
1939
1982
  }
1940
- matches.unshift(table[patternLength][wordLength - 1]);
1941
- return matches;
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;
1990
+ }
1991
+ return newFileIconCache;
1942
1992
  };
1943
1993
 
1944
- // based on https://github.com/microsoft/vscode/blob/3059063b805ed0ac10a6d9539e213386bfcfb852/src/vs/base/common/filters.ts by Microsoft (License MIT)
1945
- const gridSize = 128;
1946
- const table = createTable(gridSize);
1947
- const arrows = createTable(gridSize);
1948
- const fuzzySearch = (pattern, word) => {
1949
- const patternLength = Math.min(pattern.length, gridSize - 1);
1950
- const wordLength = Math.min(word.length, gridSize - 1);
1951
- const patternLower = pattern.toLowerCase();
1952
- const wordLower = word.toLowerCase();
1953
- if (!isPatternInWord(patternLower, 0, patternLength, wordLower, 0, wordLength)) {
1954
- return EmptyMatches;
1955
- }
1956
- let strongMatch = false;
1957
- for (let row = 1; row < patternLength + 1; row++) {
1958
- const rowChar = pattern[row - 1];
1959
- const rowCharLow = patternLower[row - 1];
1960
- for (let column = 1; column < wordLength + 1; column++) {
1961
- const columnChar = word[column - 1];
1962
- const columnCharLow = wordLower[column - 1];
1963
- const columnCharBefore = word[column - 2] || '';
1964
- const isDiagonalMatch = arrows[row - 1][column - 1] === Diagonal;
1965
- const score = getScore(rowCharLow, rowChar, columnCharBefore, columnCharLow, columnChar, isDiagonalMatch);
1966
- if (row === 1 && score > 5) {
1967
- strongMatch = true;
1968
- }
1969
- let diagonalScore = score + table[row - 1][column - 1];
1970
- if (isDiagonalMatch && score !== -1) {
1971
- diagonalScore += 2;
1972
- }
1973
- const leftScore = table[row][column - 1];
1974
- if (leftScore > diagonalScore) {
1975
- table[row][column] = leftScore;
1976
- arrows[row][column] = Left;
1977
- } else {
1978
- table[row][column] = diagonalScore;
1979
- arrows[row][column] = Diagonal;
1980
- }
1981
- }
1982
- }
1983
- if (!strongMatch) {
1984
- return EmptyMatches;
1985
- }
1986
- const highlights = traceHighlights(table, arrows, patternLength, wordLength);
1987
- return highlights;
1994
+ const emptyDirent = {
1995
+ name: '',
1996
+ path: '',
1997
+ type: 0
1988
1998
  };
1989
-
1990
- const filterQuickPickItem = (pattern, word) => {
1991
- const matches = fuzzySearch(pattern, word);
1992
- return matches;
1993
- };
1994
-
1995
- const filterQuickPickItems = (items, value, provider) => {
1996
- if (!value) {
1997
- return items.map(convertToPick);
1998
- }
1999
- const results = [];
2000
- for (const item of items) {
2001
- let filterValue = '';
2002
- if (provider) {
2003
- filterValue = provider.getPickLabel(item);
2004
- } else {
2005
- filterValue = pathBaseName(item);
2006
- }
2007
- const matches = filterQuickPickItem(value, filterValue);
2008
- if (matches.length > 0) {
2009
- results.push({
2010
- pick: item,
2011
- matches
2012
- });
2013
- }
2014
- }
2015
- 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
+ };
2016
2013
  };
2017
2014
 
2018
2015
  const focusIndex = async (state, index) => {
@@ -2021,7 +2018,8 @@ const focusIndex = async (state, index) => {
2021
2018
  maxVisibleItems,
2022
2019
  items,
2023
2020
  minLineY,
2024
- maxLineY
2021
+ maxLineY,
2022
+ fileIconCache
2025
2023
  } = state;
2026
2024
  // TODO get types working
2027
2025
  // @ts-ignore
@@ -2032,28 +2030,50 @@ const focusIndex = async (state, index) => {
2032
2030
  if (index < minLineY + 1) {
2033
2031
  const minLineY = index;
2034
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
+
2035
2039
  // TODO need to scroll up
2036
2040
  return {
2037
2041
  ...state,
2038
2042
  minLineY,
2039
2043
  maxLineY,
2040
- focusedIndex: index
2044
+ focusedIndex: index,
2045
+ icons,
2046
+ fileIconCache: newFileIconCache
2041
2047
  };
2042
2048
  }
2043
2049
  if (index >= maxLineY - 1) {
2044
2050
  // TODO need to scroll down
2045
2051
  const maxLineY = index + 1;
2046
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);
2047
2058
  return {
2048
2059
  ...state,
2049
2060
  minLineY,
2050
2061
  maxLineY,
2051
- focusedIndex: index
2062
+ focusedIndex: index,
2063
+ fileIconCache: newFileIconCache,
2064
+ icons
2052
2065
  };
2053
2066
  }
2067
+ const sliced = items.slice(minLineY, maxLineY);
2068
+ const {
2069
+ newFileIconCache,
2070
+ icons
2071
+ } = await getQuickPickFileIcons(provider, sliced, fileIconCache);
2054
2072
  return {
2055
2073
  ...state,
2056
- focusedIndex: index
2074
+ focusedIndex: index,
2075
+ fileIconCache: newFileIconCache,
2076
+ icons
2057
2077
  };
2058
2078
  };
2059
2079
 
@@ -2099,7 +2119,7 @@ const focusPrevious = state => {
2099
2119
  return focusIndex(state, previousIndex);
2100
2120
  };
2101
2121
 
2102
- const commandIds = ['close', 'dispose', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'handleFocus', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2122
+ const commandIds = ['close', 'dispose', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'diff2', 'handleFocus', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2103
2123
 
2104
2124
  const getCommandIds = () => {
2105
2125
  return commandIds;
@@ -2285,22 +2305,227 @@ const getNewValue = (value, inputType, data, selectionStart, selectionEnd) => {
2285
2305
  return fn(value, selectionStart, selectionEnd, data);
2286
2306
  };
2287
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
+
2288
2499
  // TODO when user types letters -> no need to query provider again -> just filter existing results
2289
2500
  const setValue = async (state, newValue) => {
2290
- if (state.value === newValue) {
2501
+ const {
2502
+ value,
2503
+ provider,
2504
+ minLineY,
2505
+ maxLineY,
2506
+ fileIconCache
2507
+ } = state;
2508
+ if (value === newValue) {
2291
2509
  return state;
2292
2510
  }
2293
- const newPicks = await state.provider.getPicks(newValue);
2294
- const filterValue = state.provider.getFilterValue(newValue);
2295
- const items = filterQuickPickItems(newPicks, filterValue, state.provider);
2511
+ const newPicks = await provider.getPicks(newValue);
2512
+ const filterValue = provider.getFilterValue(newValue);
2513
+ const items = filterQuickPickItems(newPicks, filterValue, provider);
2296
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);
2297
2520
  return {
2298
2521
  ...state,
2299
2522
  picks: newPicks,
2300
2523
  items,
2301
2524
  focusedIndex,
2302
2525
  inputSource: Script,
2303
- value: newValue
2526
+ value: newValue,
2527
+ icons,
2528
+ fileIconCache: newFileIconCache
2304
2529
  };
2305
2530
  };
2306
2531
 
@@ -2331,7 +2556,7 @@ const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd)
2331
2556
  return handleInput(state, newValue, cursorOffset, User);
2332
2557
  };
2333
2558
 
2334
- const handleBlur$1 = async state => {
2559
+ const handleBlur = async state => {
2335
2560
  // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2336
2561
  // await CloseWidget.closeWidget(state.uid)
2337
2562
  return state;
@@ -2358,6 +2583,7 @@ const selectIndex = async (state, index, button = /* left */0) => {
2358
2583
  } = state;
2359
2584
  const actualIndex = index + minLineY;
2360
2585
  const pick = getPick(items, actualIndex);
2586
+ // @ts-ignore
2361
2587
  const selectPickResult = await provider.selectPick(pick, actualIndex, button);
2362
2588
  object(selectPickResult);
2363
2589
  string(selectPickResult.command);
@@ -2386,260 +2612,103 @@ const selectIndex = async (state, index, button = /* left */0) => {
2386
2612
  const handleClickAt = (state, x, y) => {
2387
2613
  const {
2388
2614
  top,
2389
- headerHeight,
2390
- itemHeight
2391
- } = state;
2392
- const relativeY = y - top - headerHeight;
2393
- const index = Math.floor(relativeY / itemHeight);
2394
- return selectIndex(state, index);
2395
- };
2396
-
2397
- const setFocus = async focusKey => {
2398
- await invoke$1('Focus.setFocus', focusKey);
2399
- };
2400
-
2401
- const handleBlur = async state => {
2402
- // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2403
- await setFocus(FocusQuickPickInput);
2404
- // await CloseWidget.closeWidget(state.uid)
2405
- return state;
2406
- };
2407
-
2408
- const getDefaultValue = uri => {
2409
- switch (uri) {
2410
- case 'quickPick://everything':
2411
- return '>';
2412
- default:
2413
- return '';
2414
- }
2415
- };
2416
-
2417
- const state$4 = Object.create(null);
2418
- const register = modules => {
2419
- Object.assign(state$4, modules);
2420
- };
2421
- const load = moduleId => {
2422
- const module = state$4[moduleId];
2423
- if (!module) {
2424
- throw new Error(`unknown module "${moduleId}"`);
2425
- }
2426
- return module;
2427
- };
2428
-
2429
- const loadContent = async state => {
2430
- const {
2431
- uri,
2432
- args
2433
- } = state;
2434
- const value = getDefaultValue(uri);
2435
- const provider = load(uri);
2436
- // @ts-ignore
2437
- if (provider.setArgs) {
2438
- // @ts-ignore
2439
- provider.setArgs(args);
2440
- }
2441
- const newPicks = await provider.getPicks(value);
2442
- array(newPicks);
2443
- // @ts-ignore
2444
- const filterValue = provider.getFilterValue(value);
2445
- const items = filterQuickPickItems(newPicks, filterValue, provider);
2446
- // @ts-ignore
2447
- provider.getLabel();
2448
- const minLineY = 0;
2449
- const maxLineY = Math.min(minLineY + state.maxVisibleItems, newPicks.length);
2450
- return {
2451
- ...state,
2452
- picks: newPicks,
2453
- items,
2454
- focusedIndex: 0,
2455
- state: Finished,
2456
- minLineY,
2457
- maxLineY,
2458
- value,
2459
- cursorOffset: value.length,
2460
- provider,
2461
- inputSource: Script,
2462
- focused: true
2463
- };
2464
- };
2465
-
2466
- const getRecentlyOpened = () => {
2467
- return invoke$1(/* RecentlyOpened.getRecentlyOpened */'RecentlyOpened.getRecentlyOpened');
2468
- };
2469
- const openWorkspaceFolder = uri => {
2470
- return invoke$1(/* Workspace.setPath */'Workspace.setPath', /* path */uri);
2471
- };
2472
- const getPlaceholder$3 = () => {
2473
- return selectToOpen();
2474
- };
2475
- const getLabel$2 = () => {
2476
- return openRecent();
2477
- };
2478
- const getHelpEntries$3 = () => {
2479
- return [];
2480
- };
2481
- const getNoResults$3 = () => {
2482
- return {
2483
- label: noRecentlyOpenedFoldersFound()
2484
- };
2485
- };
2486
-
2487
- // TODO could also change api so that getPicks returns an array of anything
2488
- // and the transformPick gets the label for each pick
2489
- // This would make the code more module since the code for getting the picks
2490
- // would be more independent of the specific data format of the quickpick provider
2491
-
2492
- const getPicks$3 = async () => {
2493
- const recentlyOpened = await getRecentlyOpened();
2494
- return recentlyOpened;
2495
- };
2496
-
2497
- // TODO selectPick should be independent of show/hide
2498
- const selectPick$3 = async pick => {
2499
- const path = pick;
2500
- await openWorkspaceFolder(path);
2501
- return {
2502
- command: Hide
2503
- };
2504
- };
2505
- const getFilterValue$3 = value => {
2506
- return pathBaseName(value);
2507
- };
2508
- const getPickFilterValue$3 = pick => {
2509
- return pathBaseName(pick);
2510
- };
2511
- const getPickLabel$3 = pick => {
2512
- return pathBaseName(pick);
2513
- };
2514
- const getPickDescription$4 = pick => {
2515
- return pathDirName(pick);
2516
- };
2517
- const getPickIcon$3 = () => {
2518
- return '';
2519
- };
2520
- const getPickFileIcon = pick => {
2521
- if (typeof pick === 'object') {
2522
- pick = pick.pick;
2523
- }
2524
- if (typeof pick === 'object') {
2525
- pick = pick.pick;
2526
- }
2527
- return {
2528
- type: Directory,
2529
- name: pick
2530
- };
2531
- };
2532
- const state$3 = {};
2533
- const isPrepared$3 = () => {
2534
- return false;
2535
- };
2536
- const name$3 = '';
2537
-
2538
- const QuickPickEntriesOpenRecent = {
2539
- __proto__: null,
2540
- getFilterValue: getFilterValue$3,
2541
- getHelpEntries: getHelpEntries$3,
2542
- getLabel: getLabel$2,
2543
- getNoResults: getNoResults$3,
2544
- getPickDescription: getPickDescription$4,
2545
- getPickFileIcon,
2546
- getPickFilterValue: getPickFilterValue$3,
2547
- getPickIcon: getPickIcon$3,
2548
- getPickLabel: getPickLabel$3,
2549
- getPicks: getPicks$3,
2550
- getPlaceholder: getPlaceholder$3,
2551
- isPrepared: isPrepared$3,
2552
- name: name$3,
2553
- selectPick: selectPick$3,
2554
- state: state$3
2615
+ headerHeight,
2616
+ itemHeight
2617
+ } = state;
2618
+ const relativeY = y - top - headerHeight;
2619
+ const index = Math.floor(relativeY / itemHeight);
2620
+ return selectIndex(state, index);
2555
2621
  };
2556
2622
 
2557
- const CommandPalette = 'quickPick://commandPalette';
2558
- const Commands = 'quickPick://commands';
2559
- const File$1 = 'quickPick://file';
2560
- const EveryThing = 'quickPick://everything';
2561
- const Number$1 = 'quickPick://number';
2562
- const Recent = 'quickPick://recent';
2563
- const ColorTheme = 'quickPick://color-theme';
2564
- const Symbol = 'quickPick://symbol';
2565
- const View = 'quickPick://view';
2566
- const WorkspaceSymbol = 'quickPick://workspace-symbol';
2567
- const Custom = 'quickPick://custom';
2623
+ const setFocus = async focusKey => {
2624
+ await invoke$1('Focus.setFocus', focusKey);
2625
+ };
2568
2626
 
2569
- const loadQuickPickEntries = moduleId => {
2570
- switch (moduleId) {
2571
- case Recent:
2572
- return QuickPickEntriesOpenRecent;
2573
- default:
2574
- throw new Error(`unknown module "${moduleId}"`);
2627
+ const handleFocus = async state => {
2628
+ if (state.focused) {
2629
+ return state;
2575
2630
  }
2631
+ // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2632
+ await setFocus(FocusQuickPickInput);
2633
+ // await CloseWidget.closeWidget(state.uid)
2634
+ return {
2635
+ ...state,
2636
+ focused: true
2637
+ };
2576
2638
  };
2577
2639
 
2578
- const getIconRequests = (items, provider) => {
2579
- const iconRequests = [];
2580
- for (let i = 0; i < items.length; i++) {
2581
- const pick = items[i];
2582
- const iconObject = provider?.getPickFileIcon?.(pick) || {};
2583
- iconRequests.push({
2584
- name: iconObject?.name,
2585
- path: '',
2586
- type: iconObject?.type
2587
- });
2640
+ const getDefaultValue = uri => {
2641
+ switch (uri) {
2642
+ case 'quickPick://everything':
2643
+ return '>';
2644
+ default:
2645
+ return '';
2588
2646
  }
2589
- return iconRequests;
2590
2647
  };
2591
2648
 
2592
- const getPickDescription$3 = (provider, pick) => {
2593
- if (provider.getPickDescription) {
2594
- return provider.getPickDescription(pick);
2649
+ const state$3 = Object.create(null);
2650
+ const register = modules => {
2651
+ Object.assign(state$3, modules);
2652
+ };
2653
+ const get = moduleId => {
2654
+ const module = state$3[moduleId];
2655
+ if (!module) {
2656
+ throw new Error(`unknown module "${moduleId}"`);
2595
2657
  }
2596
- return '';
2658
+ return module;
2597
2659
  };
2598
2660
 
2599
- const requestFileIcons = async requests => {
2600
- const promises = requests.map(request => {
2601
- if (!request.name) {
2602
- return '';
2603
- }
2604
- return request.type === File$2 ? invoke$1('IconTheme.getFileIcon', {
2605
- name: request.name
2606
- }) : invoke$1('IconTheme.getFolderIcon', {
2607
- name: request.name
2608
- });
2609
- });
2610
- return Promise.all(promises);
2661
+ const loadContent = async state => {
2662
+ const {
2663
+ uri,
2664
+ args,
2665
+ fileIconCache
2666
+ } = state;
2667
+ const value = getDefaultValue(uri);
2668
+ const provider = get(uri);
2669
+ // @ts-ignore
2670
+ if (provider.setArgs) {
2671
+ // @ts-ignore
2672
+ provider.setArgs(args);
2673
+ }
2674
+ const newPicks = await provider.getPicks(value);
2675
+ array(newPicks);
2676
+ const filterValue = provider.getFilterValue(value);
2677
+ const items = filterQuickPickItems(newPicks, filterValue, provider);
2678
+ const minLineY = 0;
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);
2685
+ return {
2686
+ ...state,
2687
+ picks: newPicks,
2688
+ items,
2689
+ focusedIndex: 0,
2690
+ state: Finished,
2691
+ minLineY,
2692
+ maxLineY,
2693
+ value,
2694
+ cursorOffset: value.length,
2695
+ provider,
2696
+ inputSource: Script,
2697
+ focused: true,
2698
+ fileIconCache: newFileIconCache,
2699
+ icons
2700
+ };
2611
2701
  };
2612
2702
 
2613
- const getVisible = async (provider, items, minLineY, maxLineY, focusedIndex) => {
2614
- const visibleItems = [];
2703
+ const getVisible = (provider, items, minLineY, maxLineY, focusedIndex, icons) => {
2615
2704
  const setSize = items.length;
2616
- const max = Math.min(setSize, maxLineY);
2617
- const iconsRequests = getIconRequests(items.slice(minLineY, maxLineY), provider);
2618
- const icons = await requestFileIcons(iconsRequests);
2619
- let iconIndex = 0;
2620
- for (let i = minLineY; i < max; i++) {
2621
- const item = items[i];
2622
- const pick = item.pick;
2623
- const label = provider.getPickLabel(pick);
2624
- const description = getPickDescription$3(provider, pick);
2625
- const icon = provider.getPickIcon(pick);
2626
- const fileIcon = icons[iconIndex++];
2627
- visibleItems.push({
2628
- label,
2629
- description,
2630
- icon,
2631
- fileIcon,
2632
- posInSet: i + 1,
2633
- setSize,
2634
- isActive: i === focusedIndex,
2635
- matches: item.matches
2636
- });
2637
- }
2705
+ const range = items.slice(minLineY, maxLineY);
2706
+ const visibleItems = provider.getVisibleItems(range, minLineY, maxLineY, focusedIndex, setSize, icons);
2638
2707
  return visibleItems;
2639
2708
  };
2640
2709
 
2641
- const createQuickPickViewModel = async (oldState, newState) => {
2642
- 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);
2643
2712
  const oldFocusedIndex = oldState.focusedIndex - oldState.minLineY;
2644
2713
  const newFocusedIndex = newState.focusedIndex - newState.minLineY;
2645
2714
  const maxLineY = Math.min(newState.maxLineY, newState.items.length);
@@ -2657,13 +2726,6 @@ const createQuickPickViewModel = async (oldState, newState) => {
2657
2726
  };
2658
2727
  };
2659
2728
 
2660
- const RenderItems = 1;
2661
- const RenderFocus = 2;
2662
- const RenderValue = 3;
2663
- const RenderCursorOffset = 7;
2664
- const RenderFocusedIndex = 8;
2665
- const Height = 9;
2666
-
2667
2729
  const SetCursorOffset = 'setCursorOffset';
2668
2730
  const SetFocusedIndex = 'setFocusedIndex';
2669
2731
  const SetItemsHeight = 'setItemsHeight';
@@ -2693,7 +2755,7 @@ const renderHeight = newState => {
2693
2755
  const ComboBox = 'combobox';
2694
2756
  const ListBox = 'listbox';
2695
2757
  const None$1 = 'none';
2696
- const Option$1 = 'option';
2758
+ const Option = 'option';
2697
2759
 
2698
2760
  const FileIcon = 'FileIcon';
2699
2761
  const InputBox = 'InputBox';
@@ -2719,15 +2781,15 @@ const QuickPick = 'QuickPick';
2719
2781
  const QuickPickItems = 'QuickPickItems';
2720
2782
  const QuickPickItemActive = 'QuickPickItemActive';
2721
2783
 
2722
- const Div$1 = 4;
2723
- const Input$1 = 6;
2724
- const Span$1 = 8;
2725
- const Img$1 = 17;
2784
+ const Div = 4;
2785
+ const Input = 6;
2786
+ const Span = 8;
2787
+ const Img = 17;
2726
2788
 
2727
2789
  const getQuickPickInputVirtualDom = () => {
2728
2790
  const ariaLabel = typeNameofCommandToRun();
2729
2791
  return {
2730
- type: Input$1,
2792
+ type: Input,
2731
2793
  className: InputBox,
2732
2794
  spellcheck: false,
2733
2795
  autocapitalize: 'off',
@@ -2748,140 +2810,17 @@ const getQuickPickInputVirtualDom = () => {
2748
2810
 
2749
2811
  const getQuickPickHeaderVirtualDom = () => {
2750
2812
  return [{
2751
- type: Div$1,
2813
+ type: Div,
2752
2814
  className: QuickPickHeader,
2753
2815
  childCount: 1
2754
2816
  }, getQuickPickInputVirtualDom()];
2755
2817
  };
2756
2818
 
2757
- var __defProp = Object.defineProperty;
2758
- var __export = (target, all) => {
2759
- for (var name in all) __defProp(target, name, {
2760
- get: all[name],
2761
- enumerable: true
2762
- });
2819
+ const mergeClassNames = (...classNames) => {
2820
+ return classNames.filter(Boolean).join(' ');
2763
2821
  };
2764
-
2765
- // src/parts/MergeClassNames/MergeClassNames.ts
2766
- var mergeClassNames = (...classNames) => {
2767
- return classNames.filter(Boolean).join(" ");
2768
- };
2769
-
2770
- // src/parts/VirtualDomElements/VirtualDomElements.ts
2771
- var VirtualDomElements_exports = {};
2772
- __export(VirtualDomElements_exports, {
2773
- A: () => A,
2774
- Abbr: () => Abbr,
2775
- Article: () => Article,
2776
- Aside: () => Aside,
2777
- Audio: () => Audio,
2778
- Br: () => Br,
2779
- Button: () => Button,
2780
- Cite: () => Cite,
2781
- Col: () => Col,
2782
- ColGroup: () => ColGroup,
2783
- Data: () => Data,
2784
- Dd: () => Dd,
2785
- Del: () => Del,
2786
- Div: () => Div,
2787
- Dl: () => Dl,
2788
- Figcaption: () => Figcaption,
2789
- Figure: () => Figure,
2790
- Footer: () => Footer,
2791
- H1: () => H1,
2792
- H2: () => H2,
2793
- H3: () => H3,
2794
- H4: () => H4,
2795
- H5: () => H5,
2796
- H6: () => H6,
2797
- Header: () => Header,
2798
- Hr: () => Hr,
2799
- I: () => I,
2800
- Img: () => Img,
2801
- Input: () => Input,
2802
- Ins: () => Ins,
2803
- Kbd: () => Kbd,
2804
- Li: () => Li,
2805
- Nav: () => Nav,
2806
- Ol: () => Ol,
2807
- Option: () => Option,
2808
- P: () => P,
2809
- Pre: () => Pre,
2810
- Root: () => Root,
2811
- Search: () => Search,
2812
- Section: () => Section,
2813
- Select: () => Select,
2814
- Span: () => Span,
2815
- TBody: () => TBody,
2816
- THead: () => THead,
2817
- Table: () => Table,
2818
- Td: () => Td,
2819
- Text: () => Text,
2820
- TextArea: () => TextArea,
2821
- Tfoot: () => Tfoot,
2822
- Th: () => Th,
2823
- Time: () => Time,
2824
- Tr: () => Tr,
2825
- Ul: () => Ul,
2826
- Video: () => Video
2827
- });
2828
- var Audio = 0;
2829
- var Button = 1;
2830
- var Col = 2;
2831
- var ColGroup = 3;
2832
- var Div = 4;
2833
- var H1 = 5;
2834
- var Input = 6;
2835
- var Kbd = 7;
2836
- var Span = 8;
2837
- var Table = 9;
2838
- var TBody = 10;
2839
- var Td = 11;
2840
- var Text = 12;
2841
- var Th = 13;
2842
- var THead = 14;
2843
- var Tr = 15;
2844
- var I = 16;
2845
- var Img = 17;
2846
- var Root = 0;
2847
- var Ins = 20;
2848
- var Del = 21;
2849
- var H2 = 22;
2850
- var H3 = 23;
2851
- var H4 = 24;
2852
- var H5 = 25;
2853
- var H6 = 26;
2854
- var Article = 27;
2855
- var Aside = 28;
2856
- var Footer = 29;
2857
- var Header = 30;
2858
- var Nav = 40;
2859
- var Section = 41;
2860
- var Search = 42;
2861
- var Dd = 43;
2862
- var Dl = 44;
2863
- var Figcaption = 45;
2864
- var Figure = 46;
2865
- var Hr = 47;
2866
- var Li = 48;
2867
- var Ol = 49;
2868
- var P = 50;
2869
- var Pre = 51;
2870
- var A = 53;
2871
- var Abbr = 54;
2872
- var Br = 55;
2873
- var Cite = 56;
2874
- var Data = 57;
2875
- var Time = 58;
2876
- var Tfoot = 59;
2877
- var Ul = 60;
2878
- var Video = 61;
2879
- var TextArea = 62;
2880
- var Select = 63;
2881
- var Option = 64;
2882
-
2883
- // src/parts/Text/Text.ts
2884
- var text = data => {
2822
+ const Text = 12;
2823
+ const text = data => {
2885
2824
  return {
2886
2825
  type: Text,
2887
2826
  text: data,
@@ -2890,13 +2829,13 @@ var text = data => {
2890
2829
  };
2891
2830
 
2892
2831
  const quickPickHighlight = {
2893
- type: Span$1,
2832
+ type: Span,
2894
2833
  className: QuickPickHighlight,
2895
2834
  childCount: 1
2896
2835
  };
2897
2836
  const addHighlights = (dom, highlights, label) => {
2898
2837
  const labelDom = {
2899
- type: Div$1,
2838
+ type: Div,
2900
2839
  className: QuickPickItemLabel,
2901
2840
  childCount: 0
2902
2841
  };
@@ -2924,7 +2863,7 @@ const addHighlights = (dom, highlights, label) => {
2924
2863
 
2925
2864
  const getFileIconVirtualDom = icon => {
2926
2865
  return {
2927
- type: Img$1,
2866
+ type: Img,
2928
2867
  className: FileIcon,
2929
2868
  src: icon,
2930
2869
  role: None$1,
@@ -2946,9 +2885,9 @@ const getQuickPickItemVirtualDom = visibleItem => {
2946
2885
  const highlights = matches.slice(1);
2947
2886
  const dom = [];
2948
2887
  dom.push({
2949
- type: Div$1,
2888
+ type: Div,
2950
2889
  className: QuickPickItem,
2951
- role: Option$1,
2890
+ role: Option,
2952
2891
  ariaPosInSet: posInSet,
2953
2892
  ariaSetSize: setSize,
2954
2893
  childCount: 1
@@ -2965,7 +2904,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
2965
2904
  } else if (icon) {
2966
2905
  parent.childCount++;
2967
2906
  dom.push({
2968
- type: Div$1,
2907
+ type: Div,
2969
2908
  className: mergeClassNames(`QuickPickMaskIcon`, 'MaskIcon', `MaskIcon${icon}`),
2970
2909
  childCount: 0
2971
2910
  });
@@ -2974,7 +2913,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
2974
2913
  if (description) {
2975
2914
  parent.childCount++;
2976
2915
  dom.push({
2977
- type: Div$1,
2916
+ type: Div,
2978
2917
  className: QuickPickItemDescription,
2979
2918
  childCount: 1
2980
2919
  }, text(description));
@@ -2985,11 +2924,11 @@ const getQuickPickItemVirtualDom = visibleItem => {
2985
2924
  const getQuickPickNoResultsVirtualDom = () => {
2986
2925
  const noResults$1 = noResults();
2987
2926
  return [{
2988
- type: Div$1,
2927
+ type: Div,
2989
2928
  className: 'QuickPickItem QuickPickItemActive QuickPickStatus',
2990
2929
  childCount: 1
2991
2930
  }, {
2992
- type: Div$1,
2931
+ type: Div,
2993
2932
  className: Label,
2994
2933
  childCount: 1
2995
2934
  }, text(noResults$1)];
@@ -3006,13 +2945,13 @@ const getQuickPickItemsVirtualDom = visibleItems => {
3006
2945
  const getQuickPickVirtualDom = visibleItems => {
3007
2946
  const quickOpen$1 = quickOpen();
3008
2947
  return [{
3009
- type: Div$1,
2948
+ type: Div,
3010
2949
  className: mergeClassNames(Viewlet, QuickPick$1),
3011
2950
  childCount: 2,
3012
2951
  id: QuickPick,
3013
2952
  ariaLabel: quickOpen$1
3014
2953
  }, ...getQuickPickHeaderVirtualDom(), {
3015
- type: Div$1,
2954
+ type: Div,
3016
2955
  className: QuickPickItems$1,
3017
2956
  id: QuickPickItems,
3018
2957
  role: ListBox,
@@ -3050,9 +2989,9 @@ const getRenderer = diffType => {
3050
2989
  }
3051
2990
  };
3052
2991
 
3053
- const applyRender = async (oldState, newState, diffResult) => {
2992
+ const applyRender = (oldState, newState, diffResult) => {
3054
2993
  const commands = [];
3055
- const viewModel = await createQuickPickViewModel(oldState, newState);
2994
+ const viewModel = createQuickPickViewModel(oldState, newState);
3056
2995
  for (const item of diffResult) {
3057
2996
  if (item === Height) {
3058
2997
  continue;
@@ -3066,52 +3005,14 @@ const applyRender = async (oldState, newState, diffResult) => {
3066
3005
  return commands;
3067
3006
  };
3068
3007
 
3069
- const diffType$4 = RenderFocus;
3070
- const isEqual$4 = (oldState, newState) => {
3071
- return oldState.focused === newState.focused;
3072
- };
3073
-
3074
- const diffType$3 = RenderFocusedIndex;
3075
- const isEqual$3 = (oldState, newState) => {
3076
- return oldState.focusedIndex === newState.focusedIndex;
3077
- };
3078
-
3079
- const diffType$2 = Height;
3080
- const isEqual$2 = (oldState, newState) => {
3081
- return oldState.items.length === newState.items.length;
3082
- };
3083
-
3084
- const diffType$1 = RenderItems;
3085
- const isEqual$1 = (oldState, newState) => {
3086
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
3087
- };
3088
-
3089
- const diffType = RenderValue;
3090
- const isEqual = (oldState, newState) => {
3091
- return newState.inputSource === User || oldState.value === newState.value;
3092
- };
3093
-
3094
- const modules = [isEqual$2, isEqual$1, isEqual, isEqual$3, isEqual$4];
3095
- const numbers = [diffType$2, diffType$1, diffType, diffType$3, diffType$4];
3096
-
3097
- const diff = (oldState, newState) => {
3098
- const diffResult = [];
3099
- for (let i = 0; i < modules.length; i++) {
3100
- const fn = modules[i];
3101
- if (!fn(oldState, newState)) {
3102
- diffResult.push(numbers[i]);
3103
- }
3104
- }
3105
- return diffResult;
3106
- };
3107
-
3108
- const doRender = async uid => {
3008
+ const render2 = (uid, diffResult) => {
3109
3009
  const {
3110
3010
  oldState,
3111
3011
  newState
3112
- } = get(uid);
3113
- const diffResult = diff(oldState, newState);
3114
- return applyRender(oldState, newState, diffResult);
3012
+ } = get$1(uid);
3013
+ set(uid, newState, newState);
3014
+ const commands = applyRender(oldState, newState, diffResult);
3015
+ return commands;
3115
3016
  };
3116
3017
 
3117
3018
  const renderEventListeners = () => {
@@ -3163,9 +3064,17 @@ const wrapCommand = fn => {
3163
3064
  const wrapped = async (uid, ...args) => {
3164
3065
  const {
3165
3066
  newState
3166
- } = get(uid);
3067
+ } = get$1(uid);
3167
3068
  const newerState = await fn(newState, ...args);
3168
- set(uid, newState, newerState);
3069
+ if (newState === newerState) {
3070
+ return;
3071
+ }
3072
+ const latest = get$1(uid);
3073
+ const merged = {
3074
+ ...latest.newState,
3075
+ ...newerState
3076
+ };
3077
+ set(uid, latest.newState, merged);
3169
3078
  };
3170
3079
  return wrapped;
3171
3080
  };
@@ -3174,6 +3083,7 @@ const commandMap = {
3174
3083
  'QuickPick.addMenuEntries': add,
3175
3084
  'QuickPick.close': close,
3176
3085
  'QuickPick.create2': create,
3086
+ 'QuickPick.diff2': diff2,
3177
3087
  'QuickPick.dispose': dispose,
3178
3088
  'QuickPick.focusFirst': wrapCommand(focusFirst),
3179
3089
  'QuickPick.focusIndex': wrapCommand(focusIndex),
@@ -3183,24 +3093,20 @@ const commandMap = {
3183
3093
  'QuickPick.getCommandIds': getCommandIds,
3184
3094
  'QuickPick.getKeyBindings': getKeyBindings,
3185
3095
  'QuickPick.handleBeforeInput': wrapCommand(handleBeforeInput),
3186
- 'QuickPick.handleBlur': wrapCommand(handleBlur$1),
3096
+ 'QuickPick.handleBlur': wrapCommand(handleBlur),
3187
3097
  'QuickPick.handleClickAt': wrapCommand(handleClickAt),
3188
- 'QuickPick.handleFocus': wrapCommand(handleBlur),
3098
+ 'QuickPick.handleFocus': wrapCommand(handleFocus),
3189
3099
  'QuickPick.handleInput': wrapCommand(handleInput),
3190
3100
  'QuickPick.handleWheel': wrapCommand(handleWheel),
3191
3101
  'QuickPick.loadContent': wrapCommand(loadContent),
3192
- 'QuickPick.loadEntries2': load,
3193
- 'QuickPick.render': doRender,
3102
+ 'QuickPick.loadEntries2': get,
3103
+ 'QuickPick.render2': render2,
3194
3104
  'QuickPick.renderEventListeners': renderEventListeners,
3195
3105
  'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
3196
3106
  'QuickPick.selectIndex': wrapCommand(selectIndex),
3197
3107
  'QuickPick.selectItem': wrapCommand(selectItem),
3198
3108
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
3199
- 'QuickPick.setValue': wrapCommand(setValue),
3200
- // deprecated
3201
- 'SearchFile.filter': filterQuickPickItems,
3202
- 'SearchFile.searchFile': searchFile$5,
3203
- 'QuickPick.loadEntries': loadQuickPickEntries
3109
+ 'QuickPick.setValue': wrapCommand(setValue)
3204
3110
  };
3205
3111
 
3206
3112
  const getColorThemeNames = async () => {
@@ -3213,13 +3119,26 @@ const setColorTheme = id => {
3213
3119
  const getPlaceholder$2 = () => {
3214
3120
  return selectColorTheme();
3215
3121
  };
3216
- const getLabel$1 = () => {
3122
+ const getLabel$2 = () => {
3217
3123
  return selectColorTheme();
3218
3124
  };
3219
3125
  const getPicks$2 = async searchValue => {
3220
3126
  const colorThemeNames = await getColorThemeNames();
3221
3127
  return colorThemeNames;
3222
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
+ };
3223
3142
  const selectPick$2 = async pick => {
3224
3143
  await setColorTheme(/* colorThemeId */pick);
3225
3144
  return {
@@ -3254,7 +3173,7 @@ const isPrepared$2 = () => {
3254
3173
  return false;
3255
3174
  };
3256
3175
  const name$2 = '';
3257
- const getHelpEntries$2 = () => {
3176
+ const getHelpEntries$1 = () => {
3258
3177
  return [];
3259
3178
  };
3260
3179
 
@@ -3262,8 +3181,8 @@ const QuickPickEntriesColorTheme = {
3262
3181
  __proto__: null,
3263
3182
  focusPick,
3264
3183
  getFilterValue: getFilterValue$2,
3265
- getHelpEntries: getHelpEntries$2,
3266
- getLabel: getLabel$1,
3184
+ getHelpEntries: getHelpEntries$1,
3185
+ getLabel: getLabel$2,
3267
3186
  getNoResults: getNoResults$2,
3268
3187
  getPickDescription: getPickDescription$2,
3269
3188
  getPickFilterValue: getPickFilterValue$2,
@@ -3271,6 +3190,7 @@ const QuickPickEntriesColorTheme = {
3271
3190
  getPickLabel: getPickLabel$2,
3272
3191
  getPicks: getPicks$2,
3273
3192
  getPlaceholder: getPlaceholder$2,
3193
+ getVisibleItems: getVisibleItems$2,
3274
3194
  isPrepared: isPrepared$2,
3275
3195
  name: name$2,
3276
3196
  selectPick: selectPick$2,
@@ -3297,12 +3217,12 @@ const setArgs = args => {
3297
3217
  const getPlaceholder$1 = () => {
3298
3218
  return '';
3299
3219
  };
3300
- const getLabel = () => {
3220
+ const getLabel$1 = () => {
3301
3221
  return 'Custom';
3302
3222
  };
3303
3223
 
3304
3224
  // TODO help entries should not be here
3305
- const getHelpEntries$1 = () => {
3225
+ const getHelpEntries = () => {
3306
3226
  return [];
3307
3227
  };
3308
3228
  const getNoResults$1 = () => {
@@ -3354,12 +3274,25 @@ const getPickIcon$1 = pick => {
3354
3274
  const isPrepared$1 = () => {
3355
3275
  return true;
3356
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
+ };
3357
3290
 
3358
3291
  const QuickPickEntriesCustom = {
3359
3292
  __proto__: null,
3360
3293
  getFilterValue: getFilterValue$1,
3361
- getHelpEntries: getHelpEntries$1,
3362
- getLabel,
3294
+ getHelpEntries,
3295
+ getLabel: getLabel$1,
3363
3296
  getNoResults: getNoResults$1,
3364
3297
  getPickDescription: getPickDescription$1,
3365
3298
  getPickFilterValue: getPickFilterValue$1,
@@ -3367,6 +3300,7 @@ const QuickPickEntriesCustom = {
3367
3300
  getPickLabel: getPickLabel$1,
3368
3301
  getPicks: getPicks$1,
3369
3302
  getPlaceholder: getPlaceholder$1,
3303
+ getVisibleItems: getVisibleItems$1,
3370
3304
  isPrepared: isPrepared$1,
3371
3305
  name: name$1,
3372
3306
  selectPick: selectPick$1,
@@ -3374,91 +3308,126 @@ const QuickPickEntriesCustom = {
3374
3308
  state: state$1
3375
3309
  };
3376
3310
 
3377
- 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
+
3378
3319
  const getPlaceholder = () => {
3379
- return '';
3320
+ return selectToOpen();
3380
3321
  };
3381
- const getHelpEntries = () => {
3382
- return [];
3322
+ const getLabel = () => {
3323
+ return openRecent();
3383
3324
  };
3384
3325
  const getNoResults = () => {
3385
3326
  return {
3386
- label: noMatchingResults()
3327
+ label: noRecentlyOpenedFoldersFound()
3387
3328
  };
3388
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
+
3389
3336
  const getPicks = async () => {
3390
- const picks = [{
3391
- label: '1'
3392
- }, {
3393
- label: '2'
3394
- }, {
3395
- label: '3'
3396
- }, {
3397
- label: '4'
3398
- }, {
3399
- label: '5'
3400
- }, {
3401
- label: '6'
3402
- }, {
3403
- label: '7'
3404
- }, {
3405
- label: '8'
3406
- }, {
3407
- label: '9'
3408
- }, {
3409
- label: '10'
3410
- }];
3411
- return picks;
3337
+ const recentlyOpened = await getRecentlyOpened();
3338
+ return recentlyOpened;
3339
+ };
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;
3412
3352
  };
3413
- const selectPick = async item => {
3353
+
3354
+ // TODO selectPick should be independent of show/hide
3355
+ const selectPick = async pick => {
3356
+ const path = pick;
3357
+ await openWorkspaceFolder(path);
3414
3358
  return {
3415
3359
  command: Hide
3416
3360
  };
3417
3361
  };
3418
- const state = {};
3419
- const getPickFilterValue = value => {
3420
- return value;
3421
- };
3422
3362
  const getFilterValue = value => {
3423
- return value;
3363
+ return pathBaseName(value);
3424
3364
  };
3425
- const getPickDescription = value => {
3426
- return '';
3365
+ const getPickFilterValue = pick => {
3366
+ return pathBaseName(pick);
3427
3367
  };
3428
- const getPickLabel = value => {
3429
- return value;
3368
+ const getPickLabel = pick => {
3369
+ return pathBaseName(pick);
3370
+ };
3371
+ const getPickDescription = pick => {
3372
+ return pathDirName(pick);
3430
3373
  };
3431
- const getPickIcon = value => {
3374
+ const getPickIcon = () => {
3432
3375
  return '';
3433
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 = {};
3434
3390
  const isPrepared = () => {
3435
3391
  return false;
3436
3392
  };
3393
+ const name = '';
3437
3394
 
3438
- const QuickPickEntriesNumber = {
3395
+ const QuickPickEntriesOpenRecent = {
3439
3396
  __proto__: null,
3440
3397
  getFilterValue,
3441
- getHelpEntries,
3398
+ getLabel,
3442
3399
  getNoResults,
3443
3400
  getPickDescription,
3401
+ getPickFileIcon,
3444
3402
  getPickFilterValue,
3445
3403
  getPickIcon,
3446
3404
  getPickLabel,
3447
3405
  getPicks,
3448
3406
  getPlaceholder,
3407
+ getVisibleItems,
3449
3408
  isPrepared,
3450
3409
  name,
3451
3410
  selectPick,
3452
3411
  state
3453
3412
  };
3454
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
+
3455
3425
  const quickPickEntriesModules = {
3456
3426
  [CommandPalette]: QuickPickEntriesEverything,
3457
3427
  [Commands]: QuickPickEntriesEverything,
3458
3428
  [File$1]: QuickPickEntriesEverything,
3459
3429
  [EveryThing]: QuickPickEntriesEverything,
3460
3430
  [WorkspaceSymbol]: QuickPickEntriesEverything,
3461
- [Number$1]: QuickPickEntriesNumber,
3462
3431
  [Recent]: QuickPickEntriesOpenRecent,
3463
3432
  [ColorTheme]: QuickPickEntriesColorTheme,
3464
3433
  [Symbol]: QuickPickEntriesSymbol,