@lvce-editor/source-control-worker 1.5.0 → 1.7.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.
- package/dist/sourceControlWorkerMain.js +161 -187
- package/package.json +1 -1
|
@@ -1030,41 +1030,39 @@ const {
|
|
|
1030
1030
|
|
|
1031
1031
|
const create2 = (id, uri, x, y, width, height, workspacePath) => {
|
|
1032
1032
|
const state = {
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
items: [],
|
|
1036
|
-
x,
|
|
1037
|
-
y,
|
|
1038
|
-
width,
|
|
1039
|
-
height,
|
|
1033
|
+
actionsCache: Object.create(null),
|
|
1034
|
+
allGroups: [],
|
|
1040
1035
|
deltaY: 0,
|
|
1041
|
-
|
|
1042
|
-
maxLineY: 0,
|
|
1036
|
+
enabledProviderIds: [],
|
|
1043
1037
|
fileIconCache: Object.create(null),
|
|
1044
|
-
icons: [],
|
|
1045
1038
|
finalDeltaY: 0,
|
|
1039
|
+
gitRoot: '',
|
|
1046
1040
|
handleOffset: 0,
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1041
|
+
headerHeight: 40,
|
|
1042
|
+
// TODO
|
|
1043
|
+
height,
|
|
1044
|
+
id,
|
|
1050
1045
|
index: [],
|
|
1051
|
-
untracked: [],
|
|
1052
|
-
workingTree: [],
|
|
1053
1046
|
inputValue: '',
|
|
1054
|
-
buttonIndex: -1,
|
|
1055
|
-
enabledProviderIds: [],
|
|
1056
1047
|
isExpanded: true,
|
|
1057
|
-
buttons: [],
|
|
1058
|
-
providerId: '',
|
|
1059
|
-
splitButtonEnabled: false,
|
|
1060
|
-
allGroups: [],
|
|
1061
|
-
gitRoot: '',
|
|
1062
1048
|
itemHeight: 20,
|
|
1049
|
+
items: [],
|
|
1050
|
+
maxLineY: 0,
|
|
1051
|
+
merge: [],
|
|
1063
1052
|
minimumSliderSize: 20,
|
|
1053
|
+
minLineY: 0,
|
|
1054
|
+
providerId: '',
|
|
1055
|
+
root: '',
|
|
1056
|
+
scrollBarActive: false,
|
|
1057
|
+
scrollBarHeight: 0,
|
|
1058
|
+
splitButtonEnabled: false,
|
|
1059
|
+
untracked: [],
|
|
1060
|
+
visibleItems: [],
|
|
1061
|
+
width,
|
|
1062
|
+
workingTree: [],
|
|
1064
1063
|
workspacePath,
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
actionsCache: Object.create(null)
|
|
1064
|
+
x,
|
|
1065
|
+
y
|
|
1068
1066
|
};
|
|
1069
1067
|
set$1(id, state, state);
|
|
1070
1068
|
};
|
|
@@ -1073,7 +1071,7 @@ const RenderItems = 4;
|
|
|
1073
1071
|
|
|
1074
1072
|
const diffType = RenderItems;
|
|
1075
1073
|
const isEqual = (oldState, newState) => {
|
|
1076
|
-
return oldState.allGroups === newState.allGroups && oldState.
|
|
1074
|
+
return oldState.allGroups === newState.allGroups && oldState.visibleItems === newState.visibleItems && oldState.items === newState.items && oldState.minLineY === newState.minLineY && oldState.maxLineY === newState.maxLineY && oldState.deltaY === newState.deltaY;
|
|
1077
1075
|
};
|
|
1078
1076
|
|
|
1079
1077
|
const modules = [isEqual];
|
|
@@ -1164,7 +1162,7 @@ const Directory = 3;
|
|
|
1164
1162
|
const DirectoryExpanded = 4;
|
|
1165
1163
|
const File = 7;
|
|
1166
1164
|
|
|
1167
|
-
const getFileIcon
|
|
1165
|
+
const getFileIcon = ({
|
|
1168
1166
|
name
|
|
1169
1167
|
}) => {
|
|
1170
1168
|
return '';
|
|
@@ -1221,7 +1219,7 @@ const getDisplayItemsGroup = (group, isExpanded) => {
|
|
|
1221
1219
|
detail: folderName,
|
|
1222
1220
|
posInSet: i + 1,
|
|
1223
1221
|
setSize: length,
|
|
1224
|
-
icon: getFileIcon
|
|
1222
|
+
icon: getFileIcon({
|
|
1225
1223
|
name: file
|
|
1226
1224
|
}),
|
|
1227
1225
|
decorationIcon: icon,
|
|
@@ -1245,47 +1243,31 @@ const getDisplayItems = (allGroups, isExpanded) => {
|
|
|
1245
1243
|
return displayItems;
|
|
1246
1244
|
};
|
|
1247
1245
|
|
|
1248
|
-
const
|
|
1249
|
-
|
|
1246
|
+
const getIconType = direntType => {
|
|
1247
|
+
switch (direntType) {
|
|
1248
|
+
case Directory:
|
|
1249
|
+
case DirectoryExpanded:
|
|
1250
|
+
return 2;
|
|
1251
|
+
default:
|
|
1252
|
+
return 1;
|
|
1253
|
+
}
|
|
1250
1254
|
};
|
|
1251
|
-
|
|
1252
1255
|
const getMissingIconRequests = (dirents, fileIconCache) => {
|
|
1253
1256
|
const missingRequests = [];
|
|
1254
1257
|
for (const dirent of dirents) {
|
|
1255
1258
|
if (!(dirent.file in fileIconCache)) {
|
|
1256
1259
|
missingRequests.push({
|
|
1257
|
-
type: dirent.type,
|
|
1258
|
-
name: dirent.label
|
|
1259
|
-
path: dirent.file
|
|
1260
|
+
type: getIconType(dirent.type),
|
|
1261
|
+
name: dirent.label
|
|
1260
1262
|
});
|
|
1261
1263
|
}
|
|
1262
1264
|
}
|
|
1263
1265
|
return missingRequests;
|
|
1264
1266
|
};
|
|
1265
1267
|
|
|
1266
|
-
const getPath = item => {
|
|
1267
|
-
return item.file;
|
|
1268
|
-
};
|
|
1269
|
-
|
|
1270
|
-
const getPaths = items => {
|
|
1271
|
-
return items.map(getPath);
|
|
1272
|
-
};
|
|
1273
|
-
|
|
1274
|
-
const getFileIcon = async name => {
|
|
1275
|
-
return invoke$1('IconTheme.getFileIcon', {
|
|
1276
|
-
name
|
|
1277
|
-
});
|
|
1278
|
-
};
|
|
1279
|
-
|
|
1280
|
-
const getFolderIcon = async name => {
|
|
1281
|
-
return invoke$1('IconTheme.getFolderIcon', {
|
|
1282
|
-
name
|
|
1283
|
-
});
|
|
1284
|
-
};
|
|
1285
|
-
|
|
1286
1268
|
const requestFileIcons = async requests => {
|
|
1287
|
-
const
|
|
1288
|
-
return
|
|
1269
|
+
const results = await invoke$1('IconTheme.getIcons', requests);
|
|
1270
|
+
return results;
|
|
1289
1271
|
};
|
|
1290
1272
|
|
|
1291
1273
|
const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
@@ -1298,7 +1280,7 @@ const updateIconCache = (iconCache, missingRequests, newIcons) => {
|
|
|
1298
1280
|
for (let i = 0; i < missingRequests.length; i++) {
|
|
1299
1281
|
const request = missingRequests[i];
|
|
1300
1282
|
const icon = newIcons[i];
|
|
1301
|
-
newFileIconCache[request.
|
|
1283
|
+
newFileIconCache[request.name] = icon;
|
|
1302
1284
|
}
|
|
1303
1285
|
return newFileIconCache;
|
|
1304
1286
|
};
|
|
@@ -1307,12 +1289,7 @@ const getFileIcons = async (dirents, fileIconCache) => {
|
|
|
1307
1289
|
const missingRequests = getMissingIconRequests(dirents, fileIconCache);
|
|
1308
1290
|
const newIcons = await requestFileIcons(missingRequests);
|
|
1309
1291
|
const newFileIconCache = updateIconCache(fileIconCache, missingRequests, newIcons);
|
|
1310
|
-
|
|
1311
|
-
const icons = getIconsCached(paths, newFileIconCache);
|
|
1312
|
-
return {
|
|
1313
|
-
icons,
|
|
1314
|
-
newFileIconCache
|
|
1315
|
-
};
|
|
1292
|
+
return newFileIconCache;
|
|
1316
1293
|
};
|
|
1317
1294
|
|
|
1318
1295
|
const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
@@ -1382,59 +1359,6 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
|
1382
1359
|
return Math.min(totalHeight, maxHeight);
|
|
1383
1360
|
};
|
|
1384
1361
|
|
|
1385
|
-
const getExtensions = async () => {
|
|
1386
|
-
return invoke('Extensions.getExtensions');
|
|
1387
|
-
};
|
|
1388
|
-
|
|
1389
|
-
const requestSourceActions = async () => {
|
|
1390
|
-
const extensions = await getExtensions();
|
|
1391
|
-
const newCache = Object.create(null);
|
|
1392
|
-
for (const extension of extensions) {
|
|
1393
|
-
if (extension && extension['source-control-actions']) {
|
|
1394
|
-
for (const [key, value] of Object.entries(extension['source-control-actions'])) {
|
|
1395
|
-
newCache.cache[key] = value;
|
|
1396
|
-
}
|
|
1397
|
-
}
|
|
1398
|
-
}
|
|
1399
|
-
return newCache;
|
|
1400
|
-
};
|
|
1401
|
-
|
|
1402
|
-
const state = {
|
|
1403
|
-
cache: Object.create(null)
|
|
1404
|
-
};
|
|
1405
|
-
const getContextId = (groupId, type) => {
|
|
1406
|
-
if (type === File) {
|
|
1407
|
-
return `${groupId}-item`;
|
|
1408
|
-
}
|
|
1409
|
-
return groupId;
|
|
1410
|
-
};
|
|
1411
|
-
const ensureActions = async () => {
|
|
1412
|
-
if (Object.keys(state.cache).length > 0) {
|
|
1413
|
-
return;
|
|
1414
|
-
}
|
|
1415
|
-
const newCache = await requestSourceActions();
|
|
1416
|
-
state.cache = newCache;
|
|
1417
|
-
};
|
|
1418
|
-
const getSourceControlActions = async (providerId, groupId, type) => {
|
|
1419
|
-
string(groupId);
|
|
1420
|
-
await ensureActions();
|
|
1421
|
-
const contextId = getContextId(groupId, type);
|
|
1422
|
-
const value = state.cache[contextId] || [];
|
|
1423
|
-
return value;
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
const getNewButtons = async (displayItems, providerId, buttonIndex, actionsCache) => {
|
|
1427
|
-
if (buttonIndex === -1) {
|
|
1428
|
-
return [];
|
|
1429
|
-
}
|
|
1430
|
-
const item = displayItems[buttonIndex];
|
|
1431
|
-
if (!item) {
|
|
1432
|
-
return [];
|
|
1433
|
-
}
|
|
1434
|
-
const actions = await getSourceControlActions(providerId, item.groupId, item.type);
|
|
1435
|
-
return actions;
|
|
1436
|
-
};
|
|
1437
|
-
|
|
1438
1362
|
// TODO optimize this function to return the minimum number
|
|
1439
1363
|
// of visible items needed, e.g. when not scrolled 5 items with
|
|
1440
1364
|
// 20px fill 100px but when scrolled 6 items are needed
|
|
@@ -1456,10 +1380,52 @@ const getProtocol = uri => {
|
|
|
1456
1380
|
return Disk;
|
|
1457
1381
|
};
|
|
1458
1382
|
|
|
1383
|
+
const emptySourceControlButtons = [];
|
|
1384
|
+
|
|
1385
|
+
const getContextId = (groupId, type) => {
|
|
1386
|
+
if (type === File) {
|
|
1387
|
+
return `${groupId}-item`;
|
|
1388
|
+
}
|
|
1389
|
+
return groupId;
|
|
1390
|
+
};
|
|
1391
|
+
|
|
1392
|
+
const getVisibleSourceControlItems = (items, minLineY, maxLineY, actionsCache, fileIconCache) => {
|
|
1393
|
+
const visible = [];
|
|
1394
|
+
for (let i = minLineY; i < maxLineY; i++) {
|
|
1395
|
+
const item = items[i];
|
|
1396
|
+
const contextId = getContextId(item.groupId, item.type);
|
|
1397
|
+
const buttons = actionsCache[contextId] || emptySourceControlButtons;
|
|
1398
|
+
const fileIcon = fileIconCache[item.label] || '';
|
|
1399
|
+
visible.push({
|
|
1400
|
+
...item,
|
|
1401
|
+
buttons,
|
|
1402
|
+
fileIcon
|
|
1403
|
+
});
|
|
1404
|
+
}
|
|
1405
|
+
return visible;
|
|
1406
|
+
};
|
|
1407
|
+
|
|
1459
1408
|
const get = key => {
|
|
1460
1409
|
return false;
|
|
1461
1410
|
};
|
|
1462
1411
|
|
|
1412
|
+
const getExtensions = async () => {
|
|
1413
|
+
return invoke('Extensions.getExtensions');
|
|
1414
|
+
};
|
|
1415
|
+
|
|
1416
|
+
const requestSourceActions = async () => {
|
|
1417
|
+
const extensions = await getExtensions();
|
|
1418
|
+
const newCache = Object.create(null);
|
|
1419
|
+
for (const extension of extensions) {
|
|
1420
|
+
if (extension && extension['source-control-actions']) {
|
|
1421
|
+
for (const [key, value] of Object.entries(extension['source-control-actions'])) {
|
|
1422
|
+
newCache[key] = value;
|
|
1423
|
+
}
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
return newCache;
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1463
1429
|
const getScrollBarSize = (size, contentSize, minimumSliderSize) => {
|
|
1464
1430
|
if (size >= contentSize) {
|
|
1465
1431
|
return 0;
|
|
@@ -1473,9 +1439,8 @@ const loadContent = async state => {
|
|
|
1473
1439
|
height,
|
|
1474
1440
|
minimumSliderSize,
|
|
1475
1441
|
workspacePath,
|
|
1476
|
-
fileIconCache
|
|
1477
|
-
|
|
1478
|
-
buttonIndex} = state;
|
|
1442
|
+
fileIconCache
|
|
1443
|
+
} = state;
|
|
1479
1444
|
const root = workspacePath;
|
|
1480
1445
|
const scheme = getProtocol(root);
|
|
1481
1446
|
const enabledProviderIds = await getEnabledProviderIds(scheme, root);
|
|
@@ -1484,46 +1449,43 @@ const loadContent = async state => {
|
|
|
1484
1449
|
gitRoot
|
|
1485
1450
|
} = await getGroups(enabledProviderIds);
|
|
1486
1451
|
const isExpanded = true;
|
|
1487
|
-
const
|
|
1488
|
-
const
|
|
1452
|
+
const displayItems = getDisplayItems(allGroups, isExpanded);
|
|
1453
|
+
const actionsCache = await requestSourceActions();
|
|
1489
1454
|
const splitButtonEnabled = get();
|
|
1490
|
-
const total =
|
|
1455
|
+
const total = displayItems.length;
|
|
1491
1456
|
const contentHeight = total * itemHeight;
|
|
1492
1457
|
const listHeight = getListHeight(total, itemHeight, height);
|
|
1493
1458
|
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
1494
1459
|
const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1460
|
+
const minLineY = 0;
|
|
1495
1461
|
const maxLineY = Math.min(numberOfVisible, total);
|
|
1462
|
+
const newFileIconCache = await getFileIcons(displayItems, fileIconCache);
|
|
1463
|
+
const visibleItems = getVisibleSourceControlItems(displayItems, minLineY, maxLineY, actionsCache, newFileIconCache);
|
|
1496
1464
|
const finalDeltaY = getFinalDeltaY(listHeight, itemHeight, total);
|
|
1497
|
-
const {
|
|
1498
|
-
icons,
|
|
1499
|
-
newFileIconCache
|
|
1500
|
-
} = await getFileIcons(items, fileIconCache);
|
|
1501
1465
|
return {
|
|
1502
1466
|
...state,
|
|
1503
1467
|
allGroups,
|
|
1504
1468
|
gitRoot,
|
|
1505
|
-
items,
|
|
1469
|
+
items: displayItems,
|
|
1470
|
+
visibleItems,
|
|
1506
1471
|
enabledProviderIds,
|
|
1507
1472
|
isExpanded,
|
|
1508
|
-
buttons,
|
|
1509
1473
|
root,
|
|
1510
1474
|
splitButtonEnabled,
|
|
1511
1475
|
maxLineY,
|
|
1512
1476
|
scrollBarHeight,
|
|
1513
1477
|
finalDeltaY,
|
|
1514
|
-
|
|
1515
|
-
|
|
1478
|
+
fileIconCache: newFileIconCache,
|
|
1479
|
+
actionsCache
|
|
1516
1480
|
};
|
|
1517
1481
|
};
|
|
1518
1482
|
|
|
1519
1483
|
const handleButtonClick = async (state, clickedIndex) => {
|
|
1520
1484
|
const {
|
|
1521
|
-
|
|
1522
|
-
buttons,
|
|
1523
|
-
items
|
|
1485
|
+
visibleItems
|
|
1524
1486
|
} = state;
|
|
1525
|
-
const
|
|
1526
|
-
const
|
|
1487
|
+
const item = visibleItems[clickedIndex];
|
|
1488
|
+
const button = item.buttons[clickedIndex];
|
|
1527
1489
|
if (!button) {
|
|
1528
1490
|
return state;
|
|
1529
1491
|
}
|
|
@@ -1543,35 +1505,46 @@ const getIndex = (state, eventX, eventY) => {
|
|
|
1543
1505
|
return index;
|
|
1544
1506
|
};
|
|
1545
1507
|
|
|
1546
|
-
const
|
|
1508
|
+
const updateVisibleItems = async (state, isExpanded) => {
|
|
1547
1509
|
const {
|
|
1548
|
-
allGroups
|
|
1510
|
+
allGroups,
|
|
1511
|
+
itemHeight,
|
|
1512
|
+
height,
|
|
1513
|
+
minimumSliderSize,
|
|
1514
|
+
fileIconCache,
|
|
1515
|
+
actionsCache
|
|
1549
1516
|
} = state;
|
|
1550
|
-
const isExpanded = true;
|
|
1551
1517
|
const displayItems = getDisplayItems(allGroups, isExpanded);
|
|
1552
1518
|
const newMaxLineY = displayItems.length;
|
|
1519
|
+
const total = displayItems.length;
|
|
1520
|
+
const contentHeight = total * itemHeight;
|
|
1521
|
+
const listHeight = getListHeight(total, itemHeight, height);
|
|
1522
|
+
const scrollBarHeight = getScrollBarSize(height, contentHeight, minimumSliderSize);
|
|
1523
|
+
const numberOfVisible = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1524
|
+
const minLineY = 0;
|
|
1525
|
+
const maxLineY = Math.min(numberOfVisible, total);
|
|
1526
|
+
const slicedItems = displayItems.slice(minLineY, maxLineY);
|
|
1527
|
+
const newFileIconCache = await getFileIcons(slicedItems, fileIconCache);
|
|
1528
|
+
const visibleItems = getVisibleSourceControlItems(displayItems, minLineY, maxLineY, actionsCache, newFileIconCache);
|
|
1553
1529
|
return {
|
|
1554
1530
|
...state,
|
|
1555
1531
|
items: displayItems,
|
|
1556
1532
|
isExpanded,
|
|
1557
|
-
maxLineY: newMaxLineY
|
|
1533
|
+
maxLineY: newMaxLineY,
|
|
1534
|
+
fileIconCache: newFileIconCache,
|
|
1535
|
+
visibleItems,
|
|
1536
|
+
scrollBarHeight
|
|
1558
1537
|
};
|
|
1559
1538
|
};
|
|
1560
1539
|
|
|
1540
|
+
const handleClickDirectory = async (state, item) => {
|
|
1541
|
+
const isExpanded = true;
|
|
1542
|
+
return updateVisibleItems(state, isExpanded);
|
|
1543
|
+
};
|
|
1544
|
+
|
|
1561
1545
|
const handleClickDirectoryExpanded = async (state, item) => {
|
|
1562
|
-
const {
|
|
1563
|
-
allGroups,
|
|
1564
|
-
maxLineY
|
|
1565
|
-
} = state;
|
|
1566
1546
|
const isExpanded = false;
|
|
1567
|
-
|
|
1568
|
-
const newMaxLineY = Math.min(displayItems.length, maxLineY);
|
|
1569
|
-
return {
|
|
1570
|
-
...state,
|
|
1571
|
-
items: displayItems,
|
|
1572
|
-
isExpanded,
|
|
1573
|
-
maxLineY: newMaxLineY
|
|
1574
|
-
};
|
|
1547
|
+
return updateVisibleItems(state, isExpanded);
|
|
1575
1548
|
};
|
|
1576
1549
|
|
|
1577
1550
|
const readFile = async (uri, encoding = 'utf8') => {
|
|
@@ -1645,9 +1618,7 @@ const handleMouseOut = (state, index) => {
|
|
|
1645
1618
|
} = state;
|
|
1646
1619
|
if (index === -1 || index > items.length) {
|
|
1647
1620
|
return {
|
|
1648
|
-
...state
|
|
1649
|
-
buttonIndex: -1,
|
|
1650
|
-
buttons: []
|
|
1621
|
+
...state
|
|
1651
1622
|
};
|
|
1652
1623
|
}
|
|
1653
1624
|
return state;
|
|
@@ -1660,22 +1631,14 @@ const handleMouseOutAt = (state, eventX, eventY) => {
|
|
|
1660
1631
|
|
|
1661
1632
|
const handleMouseOver = async (state, index) => {
|
|
1662
1633
|
const {
|
|
1663
|
-
items
|
|
1664
|
-
providerId,
|
|
1665
|
-
buttonIndex
|
|
1634
|
+
items
|
|
1666
1635
|
} = state;
|
|
1667
|
-
if (index === buttonIndex) {
|
|
1668
|
-
return state;
|
|
1669
|
-
}
|
|
1670
1636
|
const item = items[index];
|
|
1671
1637
|
if (!item) {
|
|
1672
1638
|
return state;
|
|
1673
1639
|
}
|
|
1674
|
-
const actions = await getSourceControlActions(providerId, item.groupId, item.type);
|
|
1675
1640
|
return {
|
|
1676
|
-
...state
|
|
1677
|
-
buttonIndex: index,
|
|
1678
|
-
buttons: actions
|
|
1641
|
+
...state
|
|
1679
1642
|
};
|
|
1680
1643
|
};
|
|
1681
1644
|
|
|
@@ -1684,6 +1647,35 @@ const handleMouseOverAt = async (state, eventX, eventY) => {
|
|
|
1684
1647
|
return handleMouseOver(state, index);
|
|
1685
1648
|
};
|
|
1686
1649
|
|
|
1650
|
+
const setDeltaY = async (state, newDeltaY) => {
|
|
1651
|
+
const {
|
|
1652
|
+
itemHeight,
|
|
1653
|
+
items,
|
|
1654
|
+
height,
|
|
1655
|
+
headerHeight,
|
|
1656
|
+
actionsCache,
|
|
1657
|
+
fileIconCache
|
|
1658
|
+
} = state;
|
|
1659
|
+
const normalizedDeltaY = Math.max(newDeltaY, 0);
|
|
1660
|
+
const newMinLineY = Math.floor(normalizedDeltaY / itemHeight);
|
|
1661
|
+
const total = items.length;
|
|
1662
|
+
const listHeight = height - headerHeight;
|
|
1663
|
+
const visibleCount = getNumberOfVisibleItems(listHeight, itemHeight);
|
|
1664
|
+
const maxLineY = Math.min(newMinLineY + visibleCount, total);
|
|
1665
|
+
const visible = getVisibleSourceControlItems(items, newMinLineY, maxLineY, actionsCache, fileIconCache);
|
|
1666
|
+
return {
|
|
1667
|
+
...state,
|
|
1668
|
+
deltaY: newDeltaY,
|
|
1669
|
+
visibleItems: visible,
|
|
1670
|
+
minLineY: newMinLineY,
|
|
1671
|
+
maxLineY
|
|
1672
|
+
};
|
|
1673
|
+
};
|
|
1674
|
+
|
|
1675
|
+
const handleWheel = async (state, deltaMode, deltaY) => {
|
|
1676
|
+
return setDeltaY(state, state.deltaY + deltaY);
|
|
1677
|
+
};
|
|
1678
|
+
|
|
1687
1679
|
const getPortTuple = () => {
|
|
1688
1680
|
const {
|
|
1689
1681
|
port1,
|
|
@@ -1838,8 +1830,6 @@ const getBadgeVirtualDom = (className, count) => {
|
|
|
1838
1830
|
}, text(`${count}`)];
|
|
1839
1831
|
};
|
|
1840
1832
|
|
|
1841
|
-
const emptySourceControlButtons = [];
|
|
1842
|
-
|
|
1843
1833
|
const getIconVirtualDom = (icon, type = Div) => {
|
|
1844
1834
|
return {
|
|
1845
1835
|
type,
|
|
@@ -2061,23 +2051,8 @@ const getSourceControlVirtualDom = (items, splitButtonEnabled) => {
|
|
|
2061
2051
|
return dom;
|
|
2062
2052
|
};
|
|
2063
2053
|
|
|
2064
|
-
const getVisibleSourceControlItems = (items, minLineY, maxLineY, buttons, buttonIndex, icons) => {
|
|
2065
|
-
const visible = [];
|
|
2066
|
-
for (let i = minLineY; i < maxLineY; i++) {
|
|
2067
|
-
const item = items[i];
|
|
2068
|
-
const itemButtons = i === buttonIndex ? buttons : emptySourceControlButtons;
|
|
2069
|
-
const fileIcon = icons[i - minLineY];
|
|
2070
|
-
visible.push({
|
|
2071
|
-
...item,
|
|
2072
|
-
buttons: itemButtons,
|
|
2073
|
-
fileIcon
|
|
2074
|
-
});
|
|
2075
|
-
}
|
|
2076
|
-
return visible;
|
|
2077
|
-
};
|
|
2078
|
-
|
|
2079
2054
|
const renderItems = (oldState, newState) => {
|
|
2080
|
-
const visible =
|
|
2055
|
+
const visible = newState.visibleItems;
|
|
2081
2056
|
const dom = getSourceControlVirtualDom(visible, newState.splitButtonEnabled);
|
|
2082
2057
|
return ['Viewlet.setDom2', dom];
|
|
2083
2058
|
};
|
|
@@ -2219,13 +2194,10 @@ const updateIcons = async state => {
|
|
|
2219
2194
|
maxLineY
|
|
2220
2195
|
} = state;
|
|
2221
2196
|
const visible = items.slice(minLineY, maxLineY);
|
|
2222
|
-
const
|
|
2223
|
-
|
|
2224
|
-
newFileIconCache
|
|
2225
|
-
} = await getFileIcons(visible, Object.create(null));
|
|
2197
|
+
const newFileIconCache = await getFileIcons(visible, Object.create(null));
|
|
2198
|
+
// TODO update visible items
|
|
2226
2199
|
return {
|
|
2227
2200
|
...state,
|
|
2228
|
-
icons,
|
|
2229
2201
|
fileIconCache: newFileIconCache
|
|
2230
2202
|
};
|
|
2231
2203
|
};
|
|
@@ -2243,6 +2215,8 @@ const commandMap = {
|
|
|
2243
2215
|
'SourceControl.handleMouseOutAt': wrapCommand(handleMouseOutAt),
|
|
2244
2216
|
'SourceControl.handleMouseOver': wrapCommand(handleMouseOver),
|
|
2245
2217
|
'SourceControl.handleMouseOverAt': wrapCommand(handleMouseOverAt),
|
|
2218
|
+
'SourceControl.setDeltaY': wrapCommand(setDeltaY),
|
|
2219
|
+
'SourceControl.handleWheel': wrapCommand(handleWheel),
|
|
2246
2220
|
'SourceControl.loadContent': wrapCommand(loadContent),
|
|
2247
2221
|
'SourceControl.render2': render2,
|
|
2248
2222
|
'SourceControl.renderActions2': renderActions,
|