@lvce-editor/file-search-worker 4.4.0 → 4.6.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.
@@ -858,11 +858,6 @@ const WebWorkerRpcClient = {
858
858
  create: create$3
859
859
  };
860
860
 
861
- const User = 1;
862
- const Script = 2;
863
-
864
- const minimumSliderSize = 20;
865
-
866
861
  const RendererWorker = 1;
867
862
 
868
863
  const rpcs = Object.create(null);
@@ -879,6 +874,46 @@ const invoke$1 = (method, ...params) => {
879
874
  return rpc.invoke(method, ...params);
880
875
  };
881
876
 
877
+ const closeWidget = async id => {
878
+ await invoke$1('Viewlet.closeWidget', id);
879
+ };
880
+
881
+ const close = async state => {
882
+ await closeWidget(state.uid);
883
+ return state;
884
+ };
885
+
886
+ const User = 1;
887
+ const Script = 2;
888
+
889
+ const minimumSliderSize = 20;
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
+
882
917
  const handleError = async (error, notify = true, prefix = '') => {
883
918
  console.error(error);
884
919
  };
@@ -925,7 +960,6 @@ const i18nString = (key, placeholders = emptyObject) => {
925
960
  };
926
961
 
927
962
  const Files = 'Files';
928
- const GoToFile = 'Go to file';
929
963
  const NoMatchingColorThemesFound = 'No matching color themes found';
930
964
  const NoMatchingResults = 'No matching results';
931
965
  const NoRecentlyOpenedFoldersFound = 'No recently opened folders found';
@@ -935,7 +969,6 @@ const NoWorkspaceSymbolsFound = 'no workspace symbols found';
935
969
  const OpenRecent = 'Open Recent';
936
970
  const SelectColorTheme = 'Select Color Theme';
937
971
  const SelectToOpen = 'Select to open';
938
- const ShowAndRunCommands = 'Show And Run Commands';
939
972
  const TypeNameOfCommandToRun = 'Type the name of a command to run.';
940
973
  const QuickOpen = 'Quick open';
941
974
 
@@ -948,18 +981,12 @@ const selectColorTheme = () => {
948
981
  const typeNameofCommandToRun = () => {
949
982
  return i18nString(TypeNameOfCommandToRun);
950
983
  };
951
- const showAndRunCommands = () => {
952
- return i18nString(ShowAndRunCommands);
953
- };
954
984
  const noMatchingResults = () => {
955
985
  return i18nString(NoMatchingResults);
956
986
  };
957
987
  const files = () => {
958
988
  return i18nString(Files);
959
989
  };
960
- const goToFile = () => {
961
- return i18nString(GoToFile);
962
- };
963
990
  const noResults = () => {
964
991
  return i18nString(NoResults);
965
992
  };
@@ -986,12 +1013,6 @@ const name$b = 'command';
986
1013
  const getPlaceholder$b = () => {
987
1014
  return typeNameofCommandToRun();
988
1015
  };
989
- const helpEntries = () => {
990
- return [{
991
- description: showAndRunCommands(),
992
- category: 'global commands'
993
- }];
994
- };
995
1016
  const getLabel$5 = () => {
996
1017
  return '';
997
1018
  };
@@ -1039,7 +1060,8 @@ const getExtensionPicks = async () => {
1039
1060
  const getPicks$b = async () => {
1040
1061
  const builtinPicks = await getBuiltinPicks();
1041
1062
  const extensionPicks = await getExtensionPicks();
1042
- return [...builtinPicks, ...extensionPicks];
1063
+ const allPicks = [...builtinPicks, ...extensionPicks];
1064
+ return allPicks;
1043
1065
  };
1044
1066
  const shouldHide = item => {
1045
1067
  if (item.id === 'Viewlet.openWidget' && item.args[0] === 'QuickPick') {
@@ -1079,7 +1101,7 @@ const selectPick$b = async item => {
1079
1101
  return selectPickBuiltin(item);
1080
1102
  };
1081
1103
  const getFilterValue$b = value => {
1082
- return value;
1104
+ return value.trim();
1083
1105
  };
1084
1106
  const getPickFilterValue$9 = pick => {
1085
1107
  return pick.label;
@@ -1101,7 +1123,6 @@ const QuickPickEntriesCommand = {
1101
1123
  getPickLabel: getPickLabel$8,
1102
1124
  getPicks: getPicks$b,
1103
1125
  getPlaceholder: getPlaceholder$b,
1104
- helpEntries,
1105
1126
  name: name$b,
1106
1127
  selectPick: selectPick$b
1107
1128
  };
@@ -1166,14 +1187,6 @@ const getPlaceholder$a = () => {
1166
1187
  const getLabel$4 = () => {
1167
1188
  return files();
1168
1189
  };
1169
-
1170
- // TODO help entries should not be here
1171
- const getHelpEntries$a = () => {
1172
- return [{
1173
- description: goToFile(),
1174
- category: 'global commands'
1175
- }];
1176
- };
1177
1190
  const getNoResults$a = () => {
1178
1191
  return {
1179
1192
  label: noMatchingResults()
@@ -1249,7 +1262,6 @@ const isPrepared$7 = () => {
1249
1262
  const QuickPickEntriesFile = {
1250
1263
  __proto__: null,
1251
1264
  getFilterValue: getFilterValue$a,
1252
- getHelpEntries: getHelpEntries$a,
1253
1265
  getLabel: getLabel$4,
1254
1266
  getNoResults: getNoResults$a,
1255
1267
  getPickDescription: getPickDescription$8,
@@ -1272,7 +1284,7 @@ const name$9 = 'goToLine';
1272
1284
  const getPlaceholder$9 = () => {
1273
1285
  return '';
1274
1286
  };
1275
- const getHelpEntries$9 = () => {
1287
+ const getHelpEntries$3 = () => {
1276
1288
  return [];
1277
1289
  };
1278
1290
  const getNoResults$9 = () => {
@@ -1313,7 +1325,7 @@ const getFilterValue$9 = value => {
1313
1325
  const QuickPickEntriesGoToLine = {
1314
1326
  __proto__: null,
1315
1327
  getFilterValue: getFilterValue$9,
1316
- getHelpEntries: getHelpEntries$9,
1328
+ getHelpEntries: getHelpEntries$3,
1317
1329
  getNoResults: getNoResults$9,
1318
1330
  getPicks: getPicks$9,
1319
1331
  getPlaceholder: getPlaceholder$9,
@@ -1321,65 +1333,25 @@ const QuickPickEntriesGoToLine = {
1321
1333
  selectPick: selectPick$9
1322
1334
  };
1323
1335
 
1324
- const name$8 = 'noop';
1336
+ const name$8 = 'symbol';
1325
1337
  const getPlaceholder$8 = () => {
1326
1338
  return '';
1327
1339
  };
1328
- const getHelpEntries$8 = () => {
1329
- return [];
1330
- };
1331
1340
  const getNoResults$8 = () => {
1332
- return noResults();
1333
- };
1334
- const getPicks$8 = async value => {
1335
- return [];
1336
- };
1337
- const selectPick$8 = async item => {
1338
- return {
1339
- command: Hide
1340
- };
1341
- };
1342
- const getFilterValue$8 = value => {
1343
- return value;
1344
- };
1345
- const getPickFilterValue$7 = pick => {
1346
- return pick;
1347
- };
1348
-
1349
- const QuickPickNoop = {
1350
- __proto__: null,
1351
- getFilterValue: getFilterValue$8,
1352
- getHelpEntries: getHelpEntries$8,
1353
- getNoResults: getNoResults$8,
1354
- getPickFilterValue: getPickFilterValue$7,
1355
- getPicks: getPicks$8,
1356
- getPlaceholder: getPlaceholder$8,
1357
- name: name$8,
1358
- selectPick: selectPick$8
1359
- };
1360
-
1361
- const name$7 = 'symbol';
1362
- const getPlaceholder$7 = () => {
1363
- return '';
1364
- };
1365
- const getHelpEntries$7 = () => {
1366
- return [];
1367
- };
1368
- const getNoResults$7 = () => {
1369
1341
  return {
1370
1342
  label: noSymbolFound()
1371
1343
  };
1372
1344
  };
1373
- const getPicks$7 = async () => {
1345
+ const getPicks$8 = async () => {
1374
1346
  const picks = [];
1375
1347
  return picks;
1376
1348
  };
1377
- const selectPick$7 = async item => {
1349
+ const selectPick$8 = async item => {
1378
1350
  return {
1379
1351
  command: Hide
1380
1352
  };
1381
1353
  };
1382
- const getFilterValue$7 = value => {
1354
+ const getFilterValue$8 = value => {
1383
1355
  return value;
1384
1356
  };
1385
1357
  const state$7 = {};
@@ -1389,7 +1361,7 @@ const getPickDescription$7 = value => {
1389
1361
  const isPrepared$6 = () => {
1390
1362
  return false;
1391
1363
  };
1392
- const getPickFilterValue$6 = value => {
1364
+ const getPickFilterValue$7 = value => {
1393
1365
  return value;
1394
1366
  };
1395
1367
  const getPickLabel$6 = value => {
@@ -1401,45 +1373,44 @@ const getPickIcon$6 = value => {
1401
1373
 
1402
1374
  const QuickPickEntriesSymbol = {
1403
1375
  __proto__: null,
1404
- getFilterValue: getFilterValue$7,
1405
- getHelpEntries: getHelpEntries$7,
1406
- getNoResults: getNoResults$7,
1376
+ getFilterValue: getFilterValue$8,
1377
+ getNoResults: getNoResults$8,
1407
1378
  getPickDescription: getPickDescription$7,
1408
- getPickFilterValue: getPickFilterValue$6,
1379
+ getPickFilterValue: getPickFilterValue$7,
1409
1380
  getPickIcon: getPickIcon$6,
1410
1381
  getPickLabel: getPickLabel$6,
1411
- getPicks: getPicks$7,
1412
- getPlaceholder: getPlaceholder$7,
1382
+ getPicks: getPicks$8,
1383
+ getPlaceholder: getPlaceholder$8,
1413
1384
  isPrepared: isPrepared$6,
1414
- name: name$7,
1415
- selectPick: selectPick$7,
1385
+ name: name$8,
1386
+ selectPick: selectPick$8,
1416
1387
  state: state$7
1417
1388
  };
1418
1389
 
1419
1390
  // TODO probably not needed
1420
1391
 
1421
- const getPlaceholder$6 = () => {
1392
+ const getPlaceholder$7 = () => {
1422
1393
  return typeNameofCommandToRun();
1423
1394
  };
1424
- const getHelpEntries$6 = () => {
1395
+ const getHelpEntries$2 = () => {
1425
1396
  return undefined;
1426
1397
  };
1427
- const getPicks$6 = async () => {
1398
+ const getPicks$7 = async () => {
1428
1399
  // const views = ViewService.getViews()
1429
1400
  // const picks = views.map(toPick)
1430
1401
  // return picks
1431
1402
  return [];
1432
1403
  };
1433
- const selectPick$6 = async item => {
1404
+ const selectPick$7 = async item => {
1434
1405
  // Command.execute(/* openView */ 549, /* viewName */ item.label)
1435
1406
  // return {
1436
1407
  // command: QuickPickReturnValue.Hide,
1437
1408
  // }
1438
1409
  };
1439
- const getFilterValue$6 = value => {
1410
+ const getFilterValue$7 = value => {
1440
1411
  return value;
1441
1412
  };
1442
- const getPickFilterValue$5 = value => {
1413
+ const getPickFilterValue$6 = value => {
1443
1414
  return value;
1444
1415
  };
1445
1416
  const getPickLabel$5 = value => {
@@ -1449,10 +1420,10 @@ const getPickIcon$5 = value => {
1449
1420
  return '';
1450
1421
  };
1451
1422
  const state$6 = {};
1452
- const getNoResults$6 = () => {
1423
+ const getNoResults$7 = () => {
1453
1424
  return '';
1454
1425
  };
1455
- const name$6 = '';
1426
+ const name$7 = '';
1456
1427
  const isPrepared$5 = () => {
1457
1428
  return true;
1458
1429
  };
@@ -1462,37 +1433,83 @@ const getPickDescription$6 = () => {
1462
1433
 
1463
1434
  const QuickPickEntriesView = {
1464
1435
  __proto__: null,
1465
- getFilterValue: getFilterValue$6,
1466
- getHelpEntries: getHelpEntries$6,
1467
- getNoResults: getNoResults$6,
1436
+ getFilterValue: getFilterValue$7,
1437
+ getHelpEntries: getHelpEntries$2,
1438
+ getNoResults: getNoResults$7,
1468
1439
  getPickDescription: getPickDescription$6,
1469
- getPickFilterValue: getPickFilterValue$5,
1440
+ getPickFilterValue: getPickFilterValue$6,
1470
1441
  getPickIcon: getPickIcon$5,
1471
1442
  getPickLabel: getPickLabel$5,
1472
- getPicks: getPicks$6,
1473
- getPlaceholder: getPlaceholder$6,
1443
+ getPicks: getPicks$7,
1444
+ getPlaceholder: getPlaceholder$7,
1474
1445
  isPrepared: isPrepared$5,
1475
- name: name$6,
1476
- selectPick: selectPick$6,
1446
+ name: name$7,
1447
+ selectPick: selectPick$7,
1477
1448
  state: state$6
1478
1449
  };
1479
1450
 
1480
- const name$5 = 'workspace-symbol';
1481
- const getPlaceholder$5 = () => {
1451
+ const name$6 = 'workspace-symbol';
1452
+ const getPlaceholder$6 = () => {
1482
1453
  return '';
1483
1454
  };
1484
- const getHelpEntries$5 = () => {
1485
- return [];
1486
- };
1487
- const getNoResults$5 = () => {
1455
+ const getNoResults$6 = () => {
1488
1456
  return {
1489
1457
  label: noWorkspaceSymbolsFound()
1490
1458
  };
1491
1459
  };
1492
- const getPicks$5 = async () => {
1460
+ const getPicks$6 = async () => {
1493
1461
  const picks = [];
1494
1462
  return picks;
1495
1463
  };
1464
+ const selectPick$6 = async item => {
1465
+ return {
1466
+ command: Hide
1467
+ };
1468
+ };
1469
+ const getFilterValue$6 = value => {
1470
+ return value;
1471
+ };
1472
+
1473
+ const QuickPickEntriesWorkspaceSymbol = {
1474
+ __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
1481
+ };
1482
+
1483
+ const getQuickPickProvider = prefix => {
1484
+ // TODO could use enum for prefix
1485
+ // TODO could use regex to extract prefix
1486
+ // TODO or could check first letter char code (less comparisons)
1487
+ switch (prefix) {
1488
+ case Command:
1489
+ return QuickPickEntriesCommand;
1490
+ case Symbol$1:
1491
+ return QuickPickEntriesSymbol;
1492
+ case WorkspaceSymbol$1:
1493
+ return QuickPickEntriesWorkspaceSymbol;
1494
+ case GoToLine:
1495
+ return QuickPickEntriesGoToLine;
1496
+ case View$1:
1497
+ return QuickPickEntriesView;
1498
+ default:
1499
+ return QuickPickEntriesFile;
1500
+ }
1501
+ };
1502
+
1503
+ const name$5 = 'noop';
1504
+ const getPlaceholder$5 = () => {
1505
+ return '';
1506
+ };
1507
+ const getNoResults$5 = () => {
1508
+ return noResults();
1509
+ };
1510
+ const getPicks$5 = async value => {
1511
+ return [];
1512
+ };
1496
1513
  const selectPick$5 = async item => {
1497
1514
  return {
1498
1515
  command: Hide
@@ -1501,25 +1518,21 @@ const selectPick$5 = async item => {
1501
1518
  const getFilterValue$5 = value => {
1502
1519
  return value;
1503
1520
  };
1521
+ const getPickFilterValue$5 = pick => {
1522
+ return pick;
1523
+ };
1504
1524
 
1505
- const QuickPickEntriesWorkspaceSymbol = {
1525
+ const QuickPickNoop = {
1506
1526
  __proto__: null,
1507
1527
  getFilterValue: getFilterValue$5,
1508
- getHelpEntries: getHelpEntries$5,
1509
1528
  getNoResults: getNoResults$5,
1529
+ getPickFilterValue: getPickFilterValue$5,
1510
1530
  getPicks: getPicks$5,
1511
1531
  getPlaceholder: getPlaceholder$5,
1512
1532
  name: name$5,
1513
1533
  selectPick: selectPick$5
1514
1534
  };
1515
1535
 
1516
- const Command = '>';
1517
- const Symbol$1 = '@';
1518
- const WorkspaceSymbol$1 = '#';
1519
- const GoToLine = ':';
1520
- const View$1 = 'view ';
1521
- const None$2 = '';
1522
-
1523
1536
  // TODO avoid global variable
1524
1537
 
1525
1538
  const state$5 = {
@@ -1538,56 +1551,15 @@ const getPlaceholder$4 = () => {
1538
1551
  const getLabel$3 = () => {
1539
1552
  return '';
1540
1553
  };
1541
- const getHelpEntries$4 = () => {
1542
- return state$5.provider.getHelpEntries();
1543
- };
1544
1554
  const getNoResults$4 = () => {
1545
1555
  return state$5.provider.getNoResults();
1546
1556
  };
1547
- const getPrefix = value => {
1548
- if (value.startsWith(Command)) {
1549
- return Command;
1550
- }
1551
- if (value.startsWith(Symbol$1)) {
1552
- return Symbol$1;
1553
- }
1554
- if (value.startsWith(WorkspaceSymbol$1)) {
1555
- return WorkspaceSymbol$1;
1556
- }
1557
- if (value.startsWith(GoToLine)) {
1558
- return GoToLine;
1559
- }
1560
- if (value.startsWith(View$1)) {
1561
- return View$1;
1562
- }
1563
- return None$2;
1564
- };
1565
- const getQuickPickProvider = prefix => {
1566
- // TODO could use enum for prefix
1567
- // TODO could use regex to extract prefix
1568
- // TODO or could check first letter char code (less comparisons)
1569
- switch (prefix) {
1570
- case Command:
1571
- return QuickPickEntriesCommand;
1572
- case Symbol$1:
1573
- return QuickPickEntriesSymbol;
1574
- case WorkspaceSymbol$1:
1575
- return QuickPickEntriesWorkspaceSymbol;
1576
- case GoToLine:
1577
- return QuickPickEntriesGoToLine;
1578
- case View$1:
1579
- return QuickPickEntriesView;
1580
- default:
1581
- return QuickPickEntriesFile;
1582
- }
1583
- };
1584
1557
  const getPicks$4 = async value => {
1585
- const prefix = getPrefix(value);
1558
+ const prefix = getQuickPickPrefix(value);
1586
1559
 
1587
1560
  // TODO race condition
1588
1561
  if (state$5.prefix !== prefix) {
1589
1562
  state$5.prefix = prefix;
1590
- // @ts-ignore
1591
1563
  state$5.provider = await getQuickPickProvider(prefix);
1592
1564
  }
1593
1565
  // TODO this line is a bit duplicated with getFilterValue
@@ -1608,7 +1580,7 @@ const openView = () => {
1608
1580
  // show('view ')
1609
1581
  };
1610
1582
  const getFilterValue$4 = value => {
1611
- return value.slice(state$5.prefix.length);
1583
+ return value.slice(state$5.prefix.length).trim();
1612
1584
  };
1613
1585
  const getPickFilterValue$4 = pick => {
1614
1586
  const {
@@ -1667,7 +1639,6 @@ const isPrepared$4 = () => {
1667
1639
  const QuickPickEntriesEverything = {
1668
1640
  __proto__: null,
1669
1641
  getFilterValue: getFilterValue$4,
1670
- getHelpEntries: getHelpEntries$4,
1671
1642
  getLabel: getLabel$3,
1672
1643
  getNoResults: getNoResults$4,
1673
1644
  getPickDescription: getPickDescription$5,
@@ -1811,6 +1782,60 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args) =
1811
1782
  set(uid, state, state);
1812
1783
  };
1813
1784
 
1785
+ const RenderItems = 1;
1786
+ const RenderFocus = 2;
1787
+ const RenderValue = 3;
1788
+ const RenderCursorOffset = 7;
1789
+ const RenderFocusedIndex = 8;
1790
+ const Height = 9;
1791
+
1792
+ const diffType$4 = RenderFocus;
1793
+ const isEqual$4 = (oldState, newState) => {
1794
+ return oldState.focused === newState.focused;
1795
+ };
1796
+
1797
+ const diffType$3 = RenderFocusedIndex;
1798
+ const isEqual$3 = (oldState, newState) => {
1799
+ return oldState.focusedIndex === newState.focusedIndex;
1800
+ };
1801
+
1802
+ const diffType$2 = Height;
1803
+ const isEqual$2 = (oldState, newState) => {
1804
+ return oldState.items.length === newState.items.length;
1805
+ };
1806
+
1807
+ const diffType$1 = RenderItems;
1808
+ const isEqual$1 = (oldState, newState) => {
1809
+ return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
1810
+ };
1811
+
1812
+ const diffType = RenderValue;
1813
+ const isEqual = (oldState, newState) => {
1814
+ return newState.inputSource === User || oldState.value === newState.value;
1815
+ };
1816
+
1817
+ const modules = [isEqual$2, isEqual$1, isEqual, isEqual$3, isEqual$4];
1818
+ const numbers = [diffType$2, diffType$1, diffType, diffType$3, diffType$4];
1819
+
1820
+ const diff = (oldState, newState) => {
1821
+ const diffResult = [];
1822
+ for (let i = 0; i < modules.length; i++) {
1823
+ const fn = modules[i];
1824
+ if (!fn(oldState, newState)) {
1825
+ diffResult.push(numbers[i]);
1826
+ }
1827
+ }
1828
+ return diffResult;
1829
+ };
1830
+
1831
+ const diff2 = uid => {
1832
+ const {
1833
+ oldState,
1834
+ newState
1835
+ } = get(uid);
1836
+ return diff(oldState, newState);
1837
+ };
1838
+
1814
1839
  const dispose = uid => {
1815
1840
  remove(uid);
1816
1841
  };
@@ -2090,7 +2115,7 @@ const focusPrevious = state => {
2090
2115
  return focusIndex(state, previousIndex);
2091
2116
  };
2092
2117
 
2093
- const commandIds = ['dispose', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'handleFocus', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2118
+ const commandIds = ['close', 'dispose', 'focusFirst', 'focusIndex', 'focusLast', 'focusNext', 'focusPrevious', 'handleBeforeInput', 'handleBlur', 'handleClickAt', 'diff2', 'handleFocus', 'handleInput', 'handleWheel', 'renderEventListeners', 'selectCurrentIndex', 'selectIndex', 'selectItem', 'setValue'];
2094
2119
 
2095
2120
  const getCommandIds = () => {
2096
2121
  return commandIds;
@@ -2278,12 +2303,16 @@ const getNewValue = (value, inputType, data, selectionStart, selectionEnd) => {
2278
2303
 
2279
2304
  // TODO when user types letters -> no need to query provider again -> just filter existing results
2280
2305
  const setValue = async (state, newValue) => {
2281
- if (state.value === newValue) {
2306
+ const {
2307
+ value,
2308
+ provider
2309
+ } = state;
2310
+ if (value === newValue) {
2282
2311
  return state;
2283
2312
  }
2284
- const newPicks = await state.provider.getPicks(newValue);
2285
- const filterValue = state.provider.getFilterValue(newValue);
2286
- const items = filterQuickPickItems(newPicks, filterValue, state.provider);
2313
+ const newPicks = await provider.getPicks(newValue);
2314
+ const filterValue = provider.getFilterValue(newValue);
2315
+ const items = filterQuickPickItems(newPicks, filterValue, provider);
2287
2316
  const focusedIndex = items.length === 0 ? -1 : 0;
2288
2317
  return {
2289
2318
  ...state,
@@ -2322,16 +2351,12 @@ const handleBeforeInput = (state, inputType, data, selectionStart, selectionEnd)
2322
2351
  return handleInput(state, newValue, cursorOffset, User);
2323
2352
  };
2324
2353
 
2325
- const handleBlur$1 = async state => {
2354
+ const handleBlur = async state => {
2326
2355
  // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2327
2356
  // await CloseWidget.closeWidget(state.uid)
2328
2357
  return state;
2329
2358
  };
2330
2359
 
2331
- const closeWidget = async id => {
2332
- await invoke$1('Viewlet.closeWidget', id);
2333
- };
2334
-
2335
2360
  const getPick = (items, index) => {
2336
2361
  array(items);
2337
2362
  number(index);
@@ -2393,7 +2418,7 @@ const setFocus = async focusKey => {
2393
2418
  await invoke$1('Focus.setFocus', focusKey);
2394
2419
  };
2395
2420
 
2396
- const handleBlur = async state => {
2421
+ const handleFocus = async state => {
2397
2422
  // TODO fix virtual dom diffing so that input isn't destroyed and loses focus when rerendering
2398
2423
  await setFocus(FocusQuickPickInput);
2399
2424
  // await CloseWidget.closeWidget(state.uid)
@@ -2435,7 +2460,6 @@ const loadContent = async state => {
2435
2460
  }
2436
2461
  const newPicks = await provider.getPicks(value);
2437
2462
  array(newPicks);
2438
- // @ts-ignore
2439
2463
  const filterValue = provider.getFilterValue(value);
2440
2464
  const items = filterQuickPickItems(newPicks, filterValue, provider);
2441
2465
  // @ts-ignore
@@ -2470,9 +2494,6 @@ const getPlaceholder$3 = () => {
2470
2494
  const getLabel$2 = () => {
2471
2495
  return openRecent();
2472
2496
  };
2473
- const getHelpEntries$3 = () => {
2474
- return [];
2475
- };
2476
2497
  const getNoResults$3 = () => {
2477
2498
  return {
2478
2499
  label: noRecentlyOpenedFoldersFound()
@@ -2533,7 +2554,6 @@ const name$3 = '';
2533
2554
  const QuickPickEntriesOpenRecent = {
2534
2555
  __proto__: null,
2535
2556
  getFilterValue: getFilterValue$3,
2536
- getHelpEntries: getHelpEntries$3,
2537
2557
  getLabel: getLabel$2,
2538
2558
  getNoResults: getNoResults$3,
2539
2559
  getPickDescription: getPickDescription$4,
@@ -2652,13 +2672,6 @@ const createQuickPickViewModel = async (oldState, newState) => {
2652
2672
  };
2653
2673
  };
2654
2674
 
2655
- const RenderItems = 1;
2656
- const RenderFocus = 2;
2657
- const RenderValue = 3;
2658
- const RenderCursorOffset = 7;
2659
- const RenderFocusedIndex = 8;
2660
- const Height = 9;
2661
-
2662
2675
  const SetCursorOffset = 'setCursorOffset';
2663
2676
  const SetFocusedIndex = 'setFocusedIndex';
2664
2677
  const SetItemsHeight = 'setItemsHeight';
@@ -2961,7 +2974,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
2961
2974
  parent.childCount++;
2962
2975
  dom.push({
2963
2976
  type: Div$1,
2964
- className: `QuickPickMaskIcon MaskIcon MaskIcon${icon}`,
2977
+ className: mergeClassNames(`QuickPickMaskIcon`, 'MaskIcon', `MaskIcon${icon}`),
2965
2978
  childCount: 0
2966
2979
  });
2967
2980
  }
@@ -2978,6 +2991,7 @@ const getQuickPickItemVirtualDom = visibleItem => {
2978
2991
  };
2979
2992
 
2980
2993
  const getQuickPickNoResultsVirtualDom = () => {
2994
+ const noResults$1 = noResults();
2981
2995
  return [{
2982
2996
  type: Div$1,
2983
2997
  className: 'QuickPickItem QuickPickItemActive QuickPickStatus',
@@ -2986,7 +3000,7 @@ const getQuickPickNoResultsVirtualDom = () => {
2986
3000
  type: Div$1,
2987
3001
  className: Label,
2988
3002
  childCount: 1
2989
- }, text('No Results')];
3003
+ }, text(noResults$1)];
2990
3004
  };
2991
3005
 
2992
3006
  const getQuickPickItemsVirtualDom = visibleItems => {
@@ -3060,43 +3074,14 @@ const applyRender = async (oldState, newState, diffResult) => {
3060
3074
  return commands;
3061
3075
  };
3062
3076
 
3063
- const diffType$4 = RenderFocus;
3064
- const isEqual$4 = (oldState, newState) => {
3065
- return oldState.focused === newState.focused;
3066
- };
3067
-
3068
- const diffType$3 = RenderFocusedIndex;
3069
- const isEqual$3 = (oldState, newState) => {
3070
- return oldState.focusedIndex === newState.focusedIndex;
3071
- };
3072
-
3073
- const diffType$2 = Height;
3074
- const isEqual$2 = (oldState, newState) => {
3075
- return oldState.items.length === newState.items.length;
3076
- };
3077
-
3078
- const diffType$1 = RenderItems;
3079
- const isEqual$1 = (oldState, newState) => {
3080
- return oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.focusedIndex === newState.focusedIndex;
3081
- };
3082
-
3083
- const diffType = RenderValue;
3084
- const isEqual = (oldState, newState) => {
3085
- return newState.inputSource === User || oldState.value === newState.value;
3086
- };
3087
-
3088
- const modules = [isEqual$2, isEqual$1, isEqual, isEqual$3, isEqual$4];
3089
- const numbers = [diffType$2, diffType$1, diffType, diffType$3, diffType$4];
3090
-
3091
- const diff = (oldState, newState) => {
3092
- const diffResult = [];
3093
- for (let i = 0; i < modules.length; i++) {
3094
- const fn = modules[i];
3095
- if (!fn(oldState, newState)) {
3096
- diffResult.push(numbers[i]);
3097
- }
3098
- }
3099
- return diffResult;
3077
+ const render2 = async (uid, diffResult) => {
3078
+ const {
3079
+ oldState,
3080
+ newState
3081
+ } = get(uid);
3082
+ set(uid, oldState, newState);
3083
+ const commands = applyRender(oldState, newState, diffResult);
3084
+ return commands;
3100
3085
  };
3101
3086
 
3102
3087
  const doRender = async uid => {
@@ -3159,6 +3144,9 @@ const wrapCommand = fn => {
3159
3144
  newState
3160
3145
  } = get(uid);
3161
3146
  const newerState = await fn(newState, ...args);
3147
+ if (newState === newerState) {
3148
+ return;
3149
+ }
3162
3150
  set(uid, newState, newerState);
3163
3151
  };
3164
3152
  return wrapped;
@@ -3166,7 +3154,9 @@ const wrapCommand = fn => {
3166
3154
 
3167
3155
  const commandMap = {
3168
3156
  'QuickPick.addMenuEntries': add,
3157
+ 'QuickPick.close': close,
3169
3158
  'QuickPick.create2': create,
3159
+ 'QuickPick.diff2': diff2,
3170
3160
  'QuickPick.dispose': dispose,
3171
3161
  'QuickPick.focusFirst': wrapCommand(focusFirst),
3172
3162
  'QuickPick.focusIndex': wrapCommand(focusIndex),
@@ -3176,14 +3166,14 @@ const commandMap = {
3176
3166
  'QuickPick.getCommandIds': getCommandIds,
3177
3167
  'QuickPick.getKeyBindings': getKeyBindings,
3178
3168
  'QuickPick.handleBeforeInput': wrapCommand(handleBeforeInput),
3179
- 'QuickPick.handleBlur': wrapCommand(handleBlur$1),
3169
+ 'QuickPick.handleBlur': wrapCommand(handleBlur),
3180
3170
  'QuickPick.handleClickAt': wrapCommand(handleClickAt),
3181
- 'QuickPick.handleFocus': wrapCommand(handleBlur),
3171
+ 'QuickPick.handleFocus': wrapCommand(handleFocus),
3182
3172
  'QuickPick.handleInput': wrapCommand(handleInput),
3183
3173
  'QuickPick.handleWheel': wrapCommand(handleWheel),
3184
3174
  'QuickPick.loadContent': wrapCommand(loadContent),
3185
3175
  'QuickPick.loadEntries2': load,
3186
- 'QuickPick.render': doRender,
3176
+ 'QuickPick.render2': render2,
3187
3177
  'QuickPick.renderEventListeners': renderEventListeners,
3188
3178
  'QuickPick.selectCurrentIndex': wrapCommand(selectCurrentIndex),
3189
3179
  'QuickPick.selectIndex': wrapCommand(selectIndex),
@@ -3191,6 +3181,7 @@ const commandMap = {
3191
3181
  'QuickPick.setDeltaY': wrapCommand(setDeltaY),
3192
3182
  'QuickPick.setValue': wrapCommand(setValue),
3193
3183
  // deprecated
3184
+ 'QuickPick.render': doRender,
3194
3185
  'SearchFile.filter': filterQuickPickItems,
3195
3186
  'SearchFile.searchFile': searchFile$5,
3196
3187
  'QuickPick.loadEntries': loadQuickPickEntries
@@ -3247,7 +3238,7 @@ const isPrepared$2 = () => {
3247
3238
  return false;
3248
3239
  };
3249
3240
  const name$2 = '';
3250
- const getHelpEntries$2 = () => {
3241
+ const getHelpEntries$1 = () => {
3251
3242
  return [];
3252
3243
  };
3253
3244
 
@@ -3255,7 +3246,7 @@ const QuickPickEntriesColorTheme = {
3255
3246
  __proto__: null,
3256
3247
  focusPick,
3257
3248
  getFilterValue: getFilterValue$2,
3258
- getHelpEntries: getHelpEntries$2,
3249
+ getHelpEntries: getHelpEntries$1,
3259
3250
  getLabel: getLabel$1,
3260
3251
  getNoResults: getNoResults$2,
3261
3252
  getPickDescription: getPickDescription$2,
@@ -3295,7 +3286,7 @@ const getLabel = () => {
3295
3286
  };
3296
3287
 
3297
3288
  // TODO help entries should not be here
3298
- const getHelpEntries$1 = () => {
3289
+ const getHelpEntries = () => {
3299
3290
  return [];
3300
3291
  };
3301
3292
  const getNoResults$1 = () => {
@@ -3351,7 +3342,7 @@ const isPrepared$1 = () => {
3351
3342
  const QuickPickEntriesCustom = {
3352
3343
  __proto__: null,
3353
3344
  getFilterValue: getFilterValue$1,
3354
- getHelpEntries: getHelpEntries$1,
3345
+ getHelpEntries,
3355
3346
  getLabel,
3356
3347
  getNoResults: getNoResults$1,
3357
3348
  getPickDescription: getPickDescription$1,
@@ -3371,9 +3362,6 @@ const name = 'number';
3371
3362
  const getPlaceholder = () => {
3372
3363
  return '';
3373
3364
  };
3374
- const getHelpEntries = () => {
3375
- return [];
3376
- };
3377
3365
  const getNoResults = () => {
3378
3366
  return {
3379
3367
  label: noMatchingResults()
@@ -3431,7 +3419,6 @@ const isPrepared = () => {
3431
3419
  const QuickPickEntriesNumber = {
3432
3420
  __proto__: null,
3433
3421
  getFilterValue,
3434
- getHelpEntries,
3435
3422
  getNoResults,
3436
3423
  getPickDescription,
3437
3424
  getPickFilterValue,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/file-search-worker",
3
- "version": "4.4.0",
3
+ "version": "4.6.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "text-search"