@lvce-editor/completion-worker 1.34.0 → 3.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.
- package/README.md +0 -4
- package/dist/completionWorkerMain.js +210 -206
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -237,8 +237,8 @@ const getModuleNotFoundError = stderr => {
|
|
|
237
237
|
const messageIndex = lines.findIndex(isModuleNotFoundMessage);
|
|
238
238
|
const message = lines[messageIndex];
|
|
239
239
|
return {
|
|
240
|
-
|
|
241
|
-
|
|
240
|
+
code: ERR_MODULE_NOT_FOUND,
|
|
241
|
+
message
|
|
242
242
|
};
|
|
243
243
|
};
|
|
244
244
|
const isModuleNotFoundError = stderr => {
|
|
@@ -261,14 +261,14 @@ const isUnhelpfulNativeModuleError = stderr => {
|
|
|
261
261
|
const getNativeModuleErrorMessage = stderr => {
|
|
262
262
|
const message = getMessageCodeBlock(stderr);
|
|
263
263
|
return {
|
|
264
|
-
|
|
265
|
-
|
|
264
|
+
code: E_INCOMPATIBLE_NATIVE_MODULE,
|
|
265
|
+
message: `Incompatible native node module: ${message}`
|
|
266
266
|
};
|
|
267
267
|
};
|
|
268
268
|
const getModuleSyntaxError = () => {
|
|
269
269
|
return {
|
|
270
|
-
|
|
271
|
-
|
|
270
|
+
code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
|
|
271
|
+
message: `ES Modules are not supported in electron`
|
|
272
272
|
};
|
|
273
273
|
};
|
|
274
274
|
const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
@@ -287,8 +287,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
|
|
|
287
287
|
rest
|
|
288
288
|
} = getDetails(lines);
|
|
289
289
|
return {
|
|
290
|
-
message: actualMessage,
|
|
291
290
|
code: '',
|
|
291
|
+
message: actualMessage,
|
|
292
292
|
stack: rest
|
|
293
293
|
};
|
|
294
294
|
};
|
|
@@ -298,8 +298,8 @@ class IpcError extends VError {
|
|
|
298
298
|
if (stdout || stderr) {
|
|
299
299
|
// @ts-ignore
|
|
300
300
|
const {
|
|
301
|
-
message,
|
|
302
301
|
code,
|
|
302
|
+
message,
|
|
303
303
|
stack
|
|
304
304
|
} = getHelpfulChildProcessError(stdout, stderr);
|
|
305
305
|
const cause = new Error(message);
|
|
@@ -360,8 +360,8 @@ const wrap$f = global => {
|
|
|
360
360
|
};
|
|
361
361
|
const waitForFirstMessage = async port => {
|
|
362
362
|
const {
|
|
363
|
-
|
|
364
|
-
|
|
363
|
+
promise,
|
|
364
|
+
resolve
|
|
365
365
|
} = Promise.withResolvers();
|
|
366
366
|
port.addEventListener('message', resolve, {
|
|
367
367
|
once: true
|
|
@@ -381,8 +381,8 @@ const listen$6 = async () => {
|
|
|
381
381
|
const type = firstMessage.params[0];
|
|
382
382
|
if (type === 'message-port') {
|
|
383
383
|
parentIpc.send({
|
|
384
|
-
jsonrpc: '2.0',
|
|
385
384
|
id: firstMessage.id,
|
|
385
|
+
jsonrpc: '2.0',
|
|
386
386
|
result: null
|
|
387
387
|
});
|
|
388
388
|
parentIpc.dispose();
|
|
@@ -439,8 +439,8 @@ const removeListener = (emitter, type, callback) => {
|
|
|
439
439
|
};
|
|
440
440
|
const getFirstEvent = (eventEmitter, eventMap) => {
|
|
441
441
|
const {
|
|
442
|
-
|
|
443
|
-
|
|
442
|
+
promise,
|
|
443
|
+
resolve
|
|
444
444
|
} = Promise.withResolvers();
|
|
445
445
|
const listenerMap = Object.create(null);
|
|
446
446
|
const cleanup = value => {
|
|
@@ -452,8 +452,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
452
452
|
for (const [event, type] of Object.entries(eventMap)) {
|
|
453
453
|
const listener = event => {
|
|
454
454
|
cleanup({
|
|
455
|
-
|
|
456
|
-
|
|
455
|
+
event,
|
|
456
|
+
type
|
|
457
457
|
});
|
|
458
458
|
};
|
|
459
459
|
addListener(eventEmitter, event, listener);
|
|
@@ -463,8 +463,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
463
463
|
};
|
|
464
464
|
const Message$1 = 3;
|
|
465
465
|
const create$5$1 = async ({
|
|
466
|
-
|
|
467
|
-
|
|
466
|
+
isMessagePortOpen,
|
|
467
|
+
messagePort
|
|
468
468
|
}) => {
|
|
469
469
|
if (!isMessagePort(messagePort)) {
|
|
470
470
|
throw new IpcError('port must be of type MessagePort');
|
|
@@ -477,8 +477,8 @@ const create$5$1 = async ({
|
|
|
477
477
|
});
|
|
478
478
|
messagePort.start();
|
|
479
479
|
const {
|
|
480
|
-
|
|
481
|
-
|
|
480
|
+
event,
|
|
481
|
+
type
|
|
482
482
|
} = await eventPromise;
|
|
483
483
|
if (type !== Message$1) {
|
|
484
484
|
throw new IpcError('Failed to wait for ipc message');
|
|
@@ -1019,25 +1019,6 @@ const WebWorkerRpcClient = {
|
|
|
1019
1019
|
__proto__: null,
|
|
1020
1020
|
create: create$4
|
|
1021
1021
|
};
|
|
1022
|
-
const createMockRpc = ({
|
|
1023
|
-
commandMap
|
|
1024
|
-
}) => {
|
|
1025
|
-
const invocations = [];
|
|
1026
|
-
const invoke = (method, ...params) => {
|
|
1027
|
-
invocations.push([method, ...params]);
|
|
1028
|
-
const command = commandMap[method];
|
|
1029
|
-
if (!command) {
|
|
1030
|
-
throw new Error(`command ${method} not found`);
|
|
1031
|
-
}
|
|
1032
|
-
return command(...params);
|
|
1033
|
-
};
|
|
1034
|
-
const mockRpc = {
|
|
1035
|
-
invoke,
|
|
1036
|
-
invokeAndTransfer: invoke,
|
|
1037
|
-
invocations
|
|
1038
|
-
};
|
|
1039
|
-
return mockRpc;
|
|
1040
|
-
};
|
|
1041
1022
|
|
|
1042
1023
|
const toCommandId = key => {
|
|
1043
1024
|
const dotIndex = key.indexOf('.');
|
|
@@ -1124,26 +1105,6 @@ const terminate = () => {
|
|
|
1124
1105
|
globalThis.close();
|
|
1125
1106
|
};
|
|
1126
1107
|
|
|
1127
|
-
const Div = 4;
|
|
1128
|
-
const Span = 8;
|
|
1129
|
-
const Text = 12;
|
|
1130
|
-
const Img = 17;
|
|
1131
|
-
|
|
1132
|
-
const ClientX = 'event.clientX';
|
|
1133
|
-
const ClientY = 'event.clientY';
|
|
1134
|
-
const DeltaMode = 'event.deltaMode';
|
|
1135
|
-
const DeltaY = 'event.deltaY';
|
|
1136
|
-
|
|
1137
|
-
const Enter = 3;
|
|
1138
|
-
const Escape = 8;
|
|
1139
|
-
const Space$1 = 9;
|
|
1140
|
-
const End = 255;
|
|
1141
|
-
const Home = 12;
|
|
1142
|
-
const UpArrow = 14;
|
|
1143
|
-
const DownArrow = 16;
|
|
1144
|
-
|
|
1145
|
-
const CtrlCmd = 1 << 11 >>> 0;
|
|
1146
|
-
|
|
1147
1108
|
const EditorWorker$2 = 99;
|
|
1148
1109
|
const ExtensionHostWorker = 44;
|
|
1149
1110
|
|
|
@@ -1157,6 +1118,10 @@ const get$1 = id => {
|
|
|
1157
1118
|
|
|
1158
1119
|
const create$1 = rpcId => {
|
|
1159
1120
|
return {
|
|
1121
|
+
async dispose() {
|
|
1122
|
+
const rpc = get$1(rpcId);
|
|
1123
|
+
await rpc.dispose();
|
|
1124
|
+
},
|
|
1160
1125
|
// @ts-ignore
|
|
1161
1126
|
invoke(method, ...params) {
|
|
1162
1127
|
const rpc = get$1(rpcId);
|
|
@@ -1171,19 +1136,35 @@ const create$1 = rpcId => {
|
|
|
1171
1136
|
},
|
|
1172
1137
|
set(rpc) {
|
|
1173
1138
|
set$4(rpcId, rpc);
|
|
1174
|
-
},
|
|
1175
|
-
async dispose() {
|
|
1176
|
-
const rpc = get$1(rpcId);
|
|
1177
|
-
await rpc.dispose();
|
|
1178
1139
|
}
|
|
1179
1140
|
};
|
|
1180
1141
|
};
|
|
1181
1142
|
|
|
1143
|
+
const createMockRpc = ({
|
|
1144
|
+
commandMap
|
|
1145
|
+
}) => {
|
|
1146
|
+
const invocations = [];
|
|
1147
|
+
const invoke = (method, ...params) => {
|
|
1148
|
+
invocations.push([method, ...params]);
|
|
1149
|
+
const command = commandMap[method];
|
|
1150
|
+
if (!command) {
|
|
1151
|
+
throw new Error(`command ${method} not found`);
|
|
1152
|
+
}
|
|
1153
|
+
return command(...params);
|
|
1154
|
+
};
|
|
1155
|
+
const mockRpc = {
|
|
1156
|
+
invocations,
|
|
1157
|
+
invoke,
|
|
1158
|
+
invokeAndTransfer: invoke
|
|
1159
|
+
};
|
|
1160
|
+
return mockRpc;
|
|
1161
|
+
};
|
|
1162
|
+
|
|
1182
1163
|
const {
|
|
1164
|
+
dispose: dispose$2,
|
|
1183
1165
|
invoke: invoke$1,
|
|
1184
1166
|
invokeAndTransfer,
|
|
1185
|
-
set: set$3
|
|
1186
|
-
dispose: dispose$2
|
|
1167
|
+
set: set$3
|
|
1187
1168
|
} = create$1(EditorWorker$2);
|
|
1188
1169
|
const sendMessagePortToExtensionHostWorker$2 = async port => {
|
|
1189
1170
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
@@ -1285,20 +1266,21 @@ const EditorWorker$1 = {
|
|
|
1285
1266
|
|
|
1286
1267
|
const {
|
|
1287
1268
|
invoke,
|
|
1288
|
-
set: set$2
|
|
1269
|
+
set: set$2
|
|
1270
|
+
} = create$1(ExtensionHostWorker);
|
|
1289
1271
|
|
|
1290
1272
|
const {
|
|
1291
|
-
set: set$1,
|
|
1292
|
-
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
|
|
1293
1273
|
activateByEvent: activateByEvent$1,
|
|
1294
1274
|
applyEdit: applyEdit$1,
|
|
1295
1275
|
closeWidget,
|
|
1296
1276
|
getLines: getLines$1,
|
|
1277
|
+
getOffsetAtCursor: getOffsetAtCursor$1,
|
|
1297
1278
|
getPositionAtCursor: getPositionAtCursor$1,
|
|
1298
1279
|
getSelections: getSelections$1,
|
|
1299
|
-
getOffsetAtCursor: getOffsetAtCursor$1,
|
|
1300
1280
|
getWordAtOffset2,
|
|
1301
|
-
getWordBefore: getWordBefore$1
|
|
1281
|
+
getWordBefore: getWordBefore$1,
|
|
1282
|
+
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1,
|
|
1283
|
+
set: set$1
|
|
1302
1284
|
} = EditorWorker$1;
|
|
1303
1285
|
|
|
1304
1286
|
const EditorWorker = {
|
|
@@ -1330,35 +1312,35 @@ const close = async state => {
|
|
|
1330
1312
|
};
|
|
1331
1313
|
|
|
1332
1314
|
const {
|
|
1315
|
+
dispose: dispose$1,
|
|
1333
1316
|
get,
|
|
1334
1317
|
set,
|
|
1335
|
-
wrapCommand
|
|
1336
|
-
dispose: dispose$1
|
|
1318
|
+
wrapCommand
|
|
1337
1319
|
} = create$2();
|
|
1338
1320
|
|
|
1339
1321
|
const create = (uid, x, y, width, height, editorUid, editorLanguageId) => {
|
|
1340
1322
|
const state = {
|
|
1341
|
-
uid,
|
|
1342
|
-
items: [],
|
|
1343
|
-
itemHeight: 20,
|
|
1344
|
-
maxHeight: 150,
|
|
1345
|
-
minLineY: 0,
|
|
1346
|
-
maxLineY: 0,
|
|
1347
|
-
focusedIndex: -1,
|
|
1348
|
-
x: 0,
|
|
1349
|
-
y: 0,
|
|
1350
|
-
width: 0,
|
|
1351
|
-
height: 0,
|
|
1352
1323
|
deltaY: 0,
|
|
1324
|
+
editorLanguageId,
|
|
1325
|
+
editorUid,
|
|
1353
1326
|
finalDeltaY: 0,
|
|
1354
1327
|
focused: false,
|
|
1328
|
+
focusedIndex: -1,
|
|
1355
1329
|
headerHeight: 0,
|
|
1330
|
+
height: 0,
|
|
1331
|
+
itemHeight: 20,
|
|
1332
|
+
items: [],
|
|
1356
1333
|
leadingWord: '',
|
|
1334
|
+
maxHeight: 150,
|
|
1335
|
+
maxItems: 8,
|
|
1336
|
+
maxLineY: 0,
|
|
1337
|
+
minLineY: 0,
|
|
1338
|
+
uid,
|
|
1357
1339
|
unfilteredItems: [],
|
|
1358
1340
|
version: 0,
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1341
|
+
width: 0,
|
|
1342
|
+
x: 0,
|
|
1343
|
+
y: 0
|
|
1362
1344
|
};
|
|
1363
1345
|
set(uid, state, state);
|
|
1364
1346
|
};
|
|
@@ -1406,8 +1388,8 @@ const diff = (oldState, newState) => {
|
|
|
1406
1388
|
|
|
1407
1389
|
const diff2 = uid => {
|
|
1408
1390
|
const {
|
|
1409
|
-
|
|
1410
|
-
|
|
1391
|
+
newState,
|
|
1392
|
+
oldState
|
|
1411
1393
|
} = get(uid);
|
|
1412
1394
|
const diffResult = diff(oldState, newState);
|
|
1413
1395
|
return diffResult;
|
|
@@ -1420,8 +1402,8 @@ const dispose = uid => {
|
|
|
1420
1402
|
const focusIndex = (state, index) => {
|
|
1421
1403
|
const newState = {
|
|
1422
1404
|
...state,
|
|
1423
|
-
|
|
1424
|
-
|
|
1405
|
+
focused: true,
|
|
1406
|
+
focusedIndex: index
|
|
1425
1407
|
};
|
|
1426
1408
|
return newState;
|
|
1427
1409
|
};
|
|
@@ -1490,23 +1472,23 @@ const replaceRange = (lines, ranges, replacement, origin) => {
|
|
|
1490
1472
|
for (let i = 0; i < rangesLength; i += 4) {
|
|
1491
1473
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(ranges, i);
|
|
1492
1474
|
const start = {
|
|
1493
|
-
|
|
1494
|
-
|
|
1475
|
+
columnIndex: selectionStartColumn,
|
|
1476
|
+
rowIndex: selectionStartRow
|
|
1495
1477
|
};
|
|
1496
1478
|
const end = {
|
|
1497
|
-
|
|
1498
|
-
|
|
1479
|
+
columnIndex: selectionEndColumn,
|
|
1480
|
+
rowIndex: selectionEndRow
|
|
1499
1481
|
};
|
|
1500
1482
|
const selection = {
|
|
1501
|
-
|
|
1502
|
-
|
|
1483
|
+
end,
|
|
1484
|
+
start
|
|
1503
1485
|
};
|
|
1504
1486
|
changes.push({
|
|
1505
|
-
|
|
1487
|
+
deleted: getSelectionText(lines, selection),
|
|
1506
1488
|
end: end,
|
|
1507
1489
|
inserted: replacement,
|
|
1508
|
-
|
|
1509
|
-
|
|
1490
|
+
origin,
|
|
1491
|
+
start: start
|
|
1510
1492
|
});
|
|
1511
1493
|
}
|
|
1512
1494
|
return changes;
|
|
@@ -1522,9 +1504,9 @@ const {
|
|
|
1522
1504
|
} = EditorWorker;
|
|
1523
1505
|
|
|
1524
1506
|
const execute = async ({
|
|
1507
|
+
args,
|
|
1525
1508
|
editorLanguageId,
|
|
1526
1509
|
editorUid,
|
|
1527
|
-
args,
|
|
1528
1510
|
event,
|
|
1529
1511
|
method
|
|
1530
1512
|
}) => {
|
|
@@ -1536,18 +1518,20 @@ const execute = async ({
|
|
|
1536
1518
|
|
|
1537
1519
|
const executeCompletionProvider = async (editorUid, editorLanguageId, offset) => {
|
|
1538
1520
|
return execute({
|
|
1539
|
-
|
|
1521
|
+
args: [offset],
|
|
1540
1522
|
editorLanguageId,
|
|
1523
|
+
editorUid,
|
|
1541
1524
|
event: OnCompletion,
|
|
1542
|
-
method: CompletionExecute
|
|
1543
|
-
|
|
1525
|
+
method: CompletionExecute
|
|
1526
|
+
});
|
|
1544
1527
|
};
|
|
1545
1528
|
const executeResolveCompletionItem = async (editorUid, offset, name, completionItem) => {
|
|
1546
1529
|
return execute({
|
|
1530
|
+
args: [offset, name, completionItem],
|
|
1547
1531
|
editorUid,
|
|
1548
1532
|
event: OnCompletion,
|
|
1549
|
-
method: CompletionResolveExecute
|
|
1550
|
-
|
|
1533
|
+
method: CompletionResolveExecute
|
|
1534
|
+
});
|
|
1551
1535
|
};
|
|
1552
1536
|
|
|
1553
1537
|
const getOffsetAtCursor = async editorUid => {
|
|
@@ -1618,6 +1602,26 @@ const getCommandIds = () => {
|
|
|
1618
1602
|
return commandIds;
|
|
1619
1603
|
};
|
|
1620
1604
|
|
|
1605
|
+
const Div = 4;
|
|
1606
|
+
const Span = 8;
|
|
1607
|
+
const Text = 12;
|
|
1608
|
+
const Img = 17;
|
|
1609
|
+
|
|
1610
|
+
const ClientX = 'event.clientX';
|
|
1611
|
+
const ClientY = 'event.clientY';
|
|
1612
|
+
const DeltaMode = 'event.deltaMode';
|
|
1613
|
+
const DeltaY = 'event.deltaY';
|
|
1614
|
+
|
|
1615
|
+
const Enter = 3;
|
|
1616
|
+
const Escape = 8;
|
|
1617
|
+
const Space$1 = 9;
|
|
1618
|
+
const End = 255;
|
|
1619
|
+
const Home = 12;
|
|
1620
|
+
const UpArrow = 14;
|
|
1621
|
+
const DownArrow = 16;
|
|
1622
|
+
|
|
1623
|
+
const CtrlCmd = 1 << 11 >>> 0;
|
|
1624
|
+
|
|
1621
1625
|
const mergeClassNames = (...classNames) => {
|
|
1622
1626
|
return classNames.filter(Boolean).join(' ');
|
|
1623
1627
|
};
|
|
@@ -1639,8 +1643,8 @@ const text = data => {
|
|
|
1639
1643
|
|
|
1640
1644
|
const getCommand = shortId => {
|
|
1641
1645
|
return {
|
|
1642
|
-
|
|
1643
|
-
|
|
1646
|
+
args: ['Completions', `Completions.${shortId}`, 0, Completion],
|
|
1647
|
+
command: 'Editor.executeWidgetCommand'
|
|
1644
1648
|
};
|
|
1645
1649
|
};
|
|
1646
1650
|
const getKeyBindings = () => {
|
|
@@ -1850,8 +1854,8 @@ const filterCompletionItems = (completionItems, word) => {
|
|
|
1850
1854
|
const deprecated = [];
|
|
1851
1855
|
for (const completionItem of completionItems) {
|
|
1852
1856
|
const {
|
|
1853
|
-
|
|
1854
|
-
|
|
1857
|
+
flags,
|
|
1858
|
+
label
|
|
1855
1859
|
} = completionItem;
|
|
1856
1860
|
const result = fuzzySearch(word, label);
|
|
1857
1861
|
if (result.length > 0) {
|
|
@@ -1893,11 +1897,11 @@ const getWordAtOffset = getWordAtOffset2;
|
|
|
1893
1897
|
|
|
1894
1898
|
const handleEditorDeleteLeft = async state => {
|
|
1895
1899
|
const {
|
|
1896
|
-
|
|
1900
|
+
editorUid,
|
|
1897
1901
|
itemHeight,
|
|
1898
1902
|
maxHeight,
|
|
1899
|
-
|
|
1900
|
-
|
|
1903
|
+
maxItems,
|
|
1904
|
+
unfilteredItems
|
|
1901
1905
|
} = state;
|
|
1902
1906
|
const {
|
|
1903
1907
|
x,
|
|
@@ -1915,12 +1919,12 @@ const handleEditorDeleteLeft = async state => {
|
|
|
1915
1919
|
const height = getListHeight(items.length, itemHeight, maxHeight);
|
|
1916
1920
|
return {
|
|
1917
1921
|
...state,
|
|
1922
|
+
height,
|
|
1918
1923
|
items,
|
|
1919
|
-
x,
|
|
1920
|
-
y,
|
|
1921
|
-
maxLineY: newMaxLineY,
|
|
1922
1924
|
leadingWord: wordAtOffset,
|
|
1923
|
-
|
|
1925
|
+
maxLineY: newMaxLineY,
|
|
1926
|
+
x,
|
|
1927
|
+
y
|
|
1924
1928
|
};
|
|
1925
1929
|
};
|
|
1926
1930
|
|
|
@@ -1930,16 +1934,16 @@ const {
|
|
|
1930
1934
|
|
|
1931
1935
|
const handleEditorType = async state => {
|
|
1932
1936
|
const {
|
|
1933
|
-
|
|
1937
|
+
editorUid,
|
|
1934
1938
|
itemHeight,
|
|
1935
1939
|
maxHeight,
|
|
1936
|
-
|
|
1940
|
+
unfilteredItems
|
|
1937
1941
|
} = state;
|
|
1938
1942
|
const {
|
|
1939
|
-
|
|
1940
|
-
y,
|
|
1943
|
+
columnIndex,
|
|
1941
1944
|
rowIndex,
|
|
1942
|
-
|
|
1945
|
+
x,
|
|
1946
|
+
y
|
|
1943
1947
|
} = await getPositionAtCursor(editorUid);
|
|
1944
1948
|
const wordAtOffset = await getWordBefore(editorUid, rowIndex, columnIndex);
|
|
1945
1949
|
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
@@ -1949,14 +1953,14 @@ const handleEditorType = async state => {
|
|
|
1949
1953
|
const finalDeltaY = items.length * itemHeight - height;
|
|
1950
1954
|
return {
|
|
1951
1955
|
...state,
|
|
1956
|
+
finalDeltaY,
|
|
1957
|
+
height,
|
|
1952
1958
|
items,
|
|
1953
|
-
x,
|
|
1954
|
-
y,
|
|
1955
|
-
minLineY: newMinLineY,
|
|
1956
|
-
maxLineY: newMaxLineY,
|
|
1957
1959
|
leadingWord: wordAtOffset,
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
+
maxLineY: newMaxLineY,
|
|
1961
|
+
minLineY: newMinLineY,
|
|
1962
|
+
x,
|
|
1963
|
+
y
|
|
1960
1964
|
};
|
|
1961
1965
|
};
|
|
1962
1966
|
|
|
@@ -1968,9 +1972,9 @@ const getIndexFromPosition = (y, clientY, itemHeight) => {
|
|
|
1968
1972
|
|
|
1969
1973
|
const handlePointerDown = async (state, clientX, clientY) => {
|
|
1970
1974
|
const {
|
|
1971
|
-
y,
|
|
1972
1975
|
itemHeight,
|
|
1973
|
-
items
|
|
1976
|
+
items,
|
|
1977
|
+
y
|
|
1974
1978
|
} = state;
|
|
1975
1979
|
const index = getIndexFromPosition(y, clientY, itemHeight);
|
|
1976
1980
|
if (index < 0 || index >= items.length) {
|
|
@@ -2001,18 +2005,18 @@ const getNewOffsets = (itemHeight, finalDeltaY, deltaY, height, headerHeight, va
|
|
|
2001
2005
|
return {
|
|
2002
2006
|
modified: false,
|
|
2003
2007
|
newDeltaY: 0,
|
|
2004
|
-
|
|
2005
|
-
|
|
2008
|
+
newMaxLineY: 0,
|
|
2009
|
+
newMinLineY: 0
|
|
2006
2010
|
};
|
|
2007
2011
|
}
|
|
2008
2012
|
// TODO when it only moves by one px, items don't need to be rerendered, only negative margin
|
|
2009
2013
|
const minLineY = Math.floor(newDeltaY / itemHeight);
|
|
2010
2014
|
const maxLineY = Math.min(minLineY + getNumberOfVisibleItems(listHeight, itemHeight), itemCount - 1);
|
|
2011
2015
|
return {
|
|
2016
|
+
modified: true,
|
|
2012
2017
|
newDeltaY: newDeltaY,
|
|
2013
|
-
newMinLineY: minLineY,
|
|
2014
2018
|
newMaxLineY: maxLineY,
|
|
2015
|
-
|
|
2019
|
+
newMinLineY: minLineY
|
|
2016
2020
|
};
|
|
2017
2021
|
};
|
|
2018
2022
|
|
|
@@ -2020,18 +2024,18 @@ const setDeltaY = (state, value) => {
|
|
|
2020
2024
|
object(state);
|
|
2021
2025
|
number(value);
|
|
2022
2026
|
const {
|
|
2023
|
-
itemHeight,
|
|
2024
|
-
finalDeltaY,
|
|
2025
2027
|
deltaY,
|
|
2026
|
-
|
|
2028
|
+
finalDeltaY,
|
|
2027
2029
|
headerHeight,
|
|
2030
|
+
height,
|
|
2031
|
+
itemHeight,
|
|
2028
2032
|
items
|
|
2029
2033
|
} = state;
|
|
2030
2034
|
const {
|
|
2035
|
+
modified,
|
|
2031
2036
|
newDeltaY,
|
|
2032
2037
|
newMaxLineY,
|
|
2033
|
-
newMinLineY
|
|
2034
|
-
modified
|
|
2038
|
+
newMinLineY
|
|
2035
2039
|
} = getNewOffsets(itemHeight, finalDeltaY, deltaY, height, headerHeight, value, items.length);
|
|
2036
2040
|
if (!modified) {
|
|
2037
2041
|
return state;
|
|
@@ -2039,8 +2043,8 @@ const setDeltaY = (state, value) => {
|
|
|
2039
2043
|
return {
|
|
2040
2044
|
...state,
|
|
2041
2045
|
deltaY: newDeltaY,
|
|
2042
|
-
|
|
2043
|
-
|
|
2046
|
+
maxLineY: newMaxLineY,
|
|
2047
|
+
minLineY: newMinLineY
|
|
2044
2048
|
};
|
|
2045
2049
|
};
|
|
2046
2050
|
|
|
@@ -2098,17 +2102,17 @@ const getFinalDeltaY = (height, itemHeight, itemsLength) => {
|
|
|
2098
2102
|
|
|
2099
2103
|
const loadContent = async state => {
|
|
2100
2104
|
const {
|
|
2101
|
-
|
|
2102
|
-
maxHeight,
|
|
2105
|
+
editorLanguageId,
|
|
2103
2106
|
editorUid,
|
|
2104
|
-
|
|
2107
|
+
itemHeight,
|
|
2108
|
+
maxHeight
|
|
2105
2109
|
} = state;
|
|
2106
2110
|
const unfilteredItems = await getCompletions(editorUid, editorLanguageId);
|
|
2107
2111
|
const wordAtOffset = await getWordAtOffset(editorUid);
|
|
2108
2112
|
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
2109
2113
|
const {
|
|
2110
|
-
rowIndex,
|
|
2111
2114
|
columnIndex,
|
|
2115
|
+
rowIndex,
|
|
2112
2116
|
x,
|
|
2113
2117
|
y
|
|
2114
2118
|
} = await getPositionAtCursor(editorUid);
|
|
@@ -2120,20 +2124,20 @@ const loadContent = async state => {
|
|
|
2120
2124
|
const finalDeltaY = getFinalDeltaY(height, itemHeight, total);
|
|
2121
2125
|
return {
|
|
2122
2126
|
...state,
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
x,
|
|
2126
|
-
y,
|
|
2127
|
-
maxLineY: newMaxLineY,
|
|
2128
|
-
focusedIndex: newFocusedIndex,
|
|
2127
|
+
// @ts-ignore
|
|
2128
|
+
columnIndex,
|
|
2129
2129
|
finalDeltaY,
|
|
2130
|
-
|
|
2130
|
+
focusedIndex: newFocusedIndex,
|
|
2131
2131
|
height,
|
|
2132
|
-
|
|
2132
|
+
items,
|
|
2133
|
+
leadingWord: wordAtOffset,
|
|
2134
|
+
maxLineY: newMaxLineY,
|
|
2133
2135
|
rowIndex,
|
|
2134
|
-
|
|
2136
|
+
unfilteredItems,
|
|
2137
|
+
version: 1,
|
|
2135
2138
|
width: 200,
|
|
2136
|
-
|
|
2139
|
+
x,
|
|
2140
|
+
y
|
|
2137
2141
|
};
|
|
2138
2142
|
};
|
|
2139
2143
|
|
|
@@ -2144,11 +2148,11 @@ const SetEventListeners = 'Viewlet.registerEventListeners';
|
|
|
2144
2148
|
|
|
2145
2149
|
const renderBounds = (oldState, newState) => {
|
|
2146
2150
|
const {
|
|
2147
|
-
x,
|
|
2148
|
-
y,
|
|
2149
|
-
width,
|
|
2150
2151
|
height,
|
|
2151
|
-
uid
|
|
2152
|
+
uid,
|
|
2153
|
+
width,
|
|
2154
|
+
x,
|
|
2155
|
+
y
|
|
2152
2156
|
} = newState;
|
|
2153
2157
|
return [SetBounds, uid, x, y, width, height];
|
|
2154
2158
|
};
|
|
@@ -2230,11 +2234,11 @@ const suggest = () => {
|
|
|
2230
2234
|
|
|
2231
2235
|
const getFileIconVirtualDom = icon => {
|
|
2232
2236
|
return {
|
|
2233
|
-
|
|
2237
|
+
childCount: 0,
|
|
2234
2238
|
className: FileIcon,
|
|
2235
|
-
src: icon,
|
|
2236
2239
|
role: None,
|
|
2237
|
-
|
|
2240
|
+
src: icon,
|
|
2241
|
+
type: Img
|
|
2238
2242
|
};
|
|
2239
2243
|
};
|
|
2240
2244
|
|
|
@@ -2243,21 +2247,21 @@ const getIconDom = (fileIcon, symbolName) => {
|
|
|
2243
2247
|
return getFileIconVirtualDom(fileIcon);
|
|
2244
2248
|
}
|
|
2245
2249
|
return {
|
|
2246
|
-
|
|
2250
|
+
childCount: 0,
|
|
2247
2251
|
className: `${ColoredMaskIcon} ${symbolName}`,
|
|
2248
|
-
|
|
2252
|
+
type: Div
|
|
2249
2253
|
};
|
|
2250
2254
|
};
|
|
2251
2255
|
|
|
2252
2256
|
const label1 = {
|
|
2253
|
-
|
|
2257
|
+
childCount: 1,
|
|
2254
2258
|
className: Label,
|
|
2255
|
-
|
|
2259
|
+
type: Div
|
|
2256
2260
|
};
|
|
2257
2261
|
const completionHighlight = {
|
|
2258
|
-
|
|
2262
|
+
childCount: 1,
|
|
2259
2263
|
className: EditorCompletionItemHighlight,
|
|
2260
|
-
|
|
2264
|
+
type: Span
|
|
2261
2265
|
};
|
|
2262
2266
|
const getHighlightedLabelDom = (label, highlights) => {
|
|
2263
2267
|
if (highlights.length === 0) {
|
|
@@ -2265,9 +2269,9 @@ const getHighlightedLabelDom = (label, highlights) => {
|
|
|
2265
2269
|
}
|
|
2266
2270
|
const dom = [];
|
|
2267
2271
|
const labelDom = {
|
|
2268
|
-
|
|
2272
|
+
childCount: 0,
|
|
2269
2273
|
className: Label,
|
|
2270
|
-
|
|
2274
|
+
type: Div
|
|
2271
2275
|
};
|
|
2272
2276
|
dom.push(labelDom);
|
|
2273
2277
|
let position = 0;
|
|
@@ -2294,13 +2298,13 @@ const getHighlightedLabelDom = (label, highlights) => {
|
|
|
2294
2298
|
|
|
2295
2299
|
const getCompletionItemVirtualDom = visibleItem => {
|
|
2296
2300
|
const {
|
|
2297
|
-
|
|
2301
|
+
deprecated,
|
|
2302
|
+
fileIcon,
|
|
2303
|
+
focused,
|
|
2304
|
+
highlights,
|
|
2298
2305
|
label,
|
|
2299
2306
|
symbolName,
|
|
2300
|
-
|
|
2301
|
-
focused,
|
|
2302
|
-
deprecated,
|
|
2303
|
-
fileIcon
|
|
2307
|
+
top
|
|
2304
2308
|
} = visibleItem;
|
|
2305
2309
|
let className = EditorCompletionItem;
|
|
2306
2310
|
if (focused) {
|
|
@@ -2310,17 +2314,17 @@ const getCompletionItemVirtualDom = visibleItem => {
|
|
|
2310
2314
|
className += ' ' + EditorCompletionItemDeprecated;
|
|
2311
2315
|
}
|
|
2312
2316
|
return [{
|
|
2313
|
-
|
|
2314
|
-
role: Option,
|
|
2317
|
+
childCount: 2,
|
|
2315
2318
|
className,
|
|
2319
|
+
role: Option,
|
|
2316
2320
|
top,
|
|
2317
|
-
|
|
2321
|
+
type: Div
|
|
2318
2322
|
}, getIconDom(fileIcon, symbolName), ...getHighlightedLabelDom(label, highlights)];
|
|
2319
2323
|
};
|
|
2320
2324
|
|
|
2321
2325
|
const parentNode = {
|
|
2322
|
-
|
|
2323
|
-
|
|
2326
|
+
childCount: 1,
|
|
2327
|
+
type: Div
|
|
2324
2328
|
};
|
|
2325
2329
|
const getNoResultsVirtualDom = () => {
|
|
2326
2330
|
return [parentNode, text(noSuggestions())];
|
|
@@ -2331,8 +2335,8 @@ const getCompletionItemsVirtualDom = visibleItems => {
|
|
|
2331
2335
|
return getNoResultsVirtualDom();
|
|
2332
2336
|
}
|
|
2333
2337
|
return [{
|
|
2334
|
-
|
|
2335
|
-
|
|
2338
|
+
childCount: visibleItems.length,
|
|
2339
|
+
type: Div
|
|
2336
2340
|
}, ...visibleItems.flatMap(getCompletionItemVirtualDom)];
|
|
2337
2341
|
};
|
|
2338
2342
|
|
|
@@ -2344,15 +2348,15 @@ const getScrollBarVirtualDom = (scrollBarHeight, scrollBarTop) => {
|
|
|
2344
2348
|
const heightString = px(scrollBarHeight);
|
|
2345
2349
|
const translateString = position(0, scrollBarTop);
|
|
2346
2350
|
return [{
|
|
2347
|
-
|
|
2351
|
+
childCount: 1,
|
|
2348
2352
|
className: mergeClassNames(ScrollBar, ScrollBarSmall),
|
|
2349
|
-
|
|
2353
|
+
type: Div
|
|
2350
2354
|
}, {
|
|
2351
|
-
type: Div,
|
|
2352
|
-
className: ScrollBarThumb,
|
|
2353
2355
|
childCount: 0,
|
|
2356
|
+
className: ScrollBarThumb,
|
|
2354
2357
|
height: heightString,
|
|
2355
|
-
translate: translateString
|
|
2358
|
+
translate: translateString,
|
|
2359
|
+
type: Div
|
|
2356
2360
|
}];
|
|
2357
2361
|
};
|
|
2358
2362
|
|
|
@@ -2362,17 +2366,17 @@ const getCompletionVirtualDom = (visibleItems, scrollBarHeight, scrollBarTop) =>
|
|
|
2362
2366
|
const scrollBarDom = getScrollBarVirtualDom(scrollBarHeight, scrollBarTop);
|
|
2363
2367
|
const childCount = scrollBarDom.length === 0 ? 1 : 2;
|
|
2364
2368
|
return [{
|
|
2365
|
-
|
|
2369
|
+
childCount: childCount,
|
|
2366
2370
|
className: mergeClassNames(Viewlet, EditorCompletion),
|
|
2367
2371
|
id: Completions,
|
|
2368
|
-
|
|
2372
|
+
type: Div
|
|
2369
2373
|
}, {
|
|
2370
|
-
type: Div,
|
|
2371
|
-
className: ListItems,
|
|
2372
|
-
role: ListBox,
|
|
2373
2374
|
ariaLabel: suggest(),
|
|
2374
2375
|
childCount: 1,
|
|
2375
|
-
|
|
2376
|
+
className: ListItems,
|
|
2377
|
+
onWheel: HandleWheel,
|
|
2378
|
+
role: ListBox,
|
|
2379
|
+
type: Div
|
|
2376
2380
|
}, ...getCompletionItemsVirtualDom(visibleItems), ...scrollBarDom
|
|
2377
2381
|
// TODO render scrollbar
|
|
2378
2382
|
];
|
|
@@ -2458,13 +2462,13 @@ const getTop = (i, minLineY, itemHeight, relative) => {
|
|
|
2458
2462
|
|
|
2459
2463
|
const getVisibleIem = (item, itemHeight, leadingWord, i, minLineY, focusedIndex, relative) => {
|
|
2460
2464
|
return {
|
|
2465
|
+
deprecated: item.flags & Deprecated,
|
|
2466
|
+
fileIcon: getCompletionFileIcon(item.kind),
|
|
2467
|
+
focused: i === focusedIndex,
|
|
2468
|
+
highlights: getHighlights(item),
|
|
2461
2469
|
label: getLabel(item),
|
|
2462
2470
|
symbolName: getSymbolName(item.kind),
|
|
2463
|
-
top: getTop(i, minLineY, itemHeight, relative)
|
|
2464
|
-
highlights: getHighlights(item),
|
|
2465
|
-
focused: i === focusedIndex,
|
|
2466
|
-
deprecated: item.flags & Deprecated,
|
|
2467
|
-
fileIcon: getCompletionFileIcon(item.kind)
|
|
2471
|
+
top: getTop(i, minLineY, itemHeight, relative)
|
|
2468
2472
|
};
|
|
2469
2473
|
};
|
|
2470
2474
|
|
|
@@ -2480,15 +2484,15 @@ const getVisibleItems = (filteredItems, itemHeight, leadingWord, minLineY, maxLi
|
|
|
2480
2484
|
|
|
2481
2485
|
const renderItems = (oldState, newState) => {
|
|
2482
2486
|
const {
|
|
2483
|
-
uid,
|
|
2484
|
-
height,
|
|
2485
2487
|
deltaY,
|
|
2486
|
-
|
|
2488
|
+
focusedIndex,
|
|
2489
|
+
height,
|
|
2487
2490
|
itemHeight,
|
|
2491
|
+
items,
|
|
2488
2492
|
leadingWord,
|
|
2489
|
-
minLineY,
|
|
2490
2493
|
maxLineY,
|
|
2491
|
-
|
|
2494
|
+
minLineY,
|
|
2495
|
+
uid
|
|
2492
2496
|
} = newState;
|
|
2493
2497
|
const visibleItems = getVisibleItems(items, itemHeight, leadingWord, minLineY, maxLineY, focusedIndex, deltaY);
|
|
2494
2498
|
const contentHeight = newState.items.length * newState.itemHeight;
|
|
@@ -2500,8 +2504,8 @@ const renderItems = (oldState, newState) => {
|
|
|
2500
2504
|
|
|
2501
2505
|
const renderUid = (oldState, newState) => {
|
|
2502
2506
|
const {
|
|
2503
|
-
|
|
2504
|
-
|
|
2507
|
+
editorUid,
|
|
2508
|
+
uid
|
|
2505
2509
|
} = newState;
|
|
2506
2510
|
return [SetUid, uid, editorUid];
|
|
2507
2511
|
};
|
|
@@ -2536,8 +2540,8 @@ const applyRender = (oldState, newState, diffResult) => {
|
|
|
2536
2540
|
|
|
2537
2541
|
const render2 = (uid, diffResult) => {
|
|
2538
2542
|
const {
|
|
2539
|
-
|
|
2540
|
-
|
|
2543
|
+
newState,
|
|
2544
|
+
oldState
|
|
2541
2545
|
} = get(uid);
|
|
2542
2546
|
set(uid, newState, newState);
|
|
2543
2547
|
const commands = applyRender(oldState, newState, diffResult);
|
|
@@ -2557,8 +2561,8 @@ const commandMap = {
|
|
|
2557
2561
|
'Completions.getKeyBindings': getKeyBindings,
|
|
2558
2562
|
'Completions.handleEditorDeleteLeft': wrapCommand(handleEditorDeleteLeft),
|
|
2559
2563
|
'Completions.handleEditorType': wrapCommand(handleEditorType),
|
|
2560
|
-
'Completions.handleWheel': wrapCommand(handleWheel),
|
|
2561
2564
|
'Completions.handlePointerDown': wrapCommand(handlePointerDown),
|
|
2565
|
+
'Completions.handleWheel': wrapCommand(handleWheel),
|
|
2562
2566
|
'Completions.initialize': initialize,
|
|
2563
2567
|
'Completions.loadContent': wrapCommand(loadContent),
|
|
2564
2568
|
'Completions.openDetails': wrapCommand(openDetails),
|