@lvce-editor/completion-worker 1.1.0 → 1.2.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/completionWorkerMain.js +23 -33
- package/package.json +1 -1
|
@@ -1020,7 +1020,7 @@ const {
|
|
|
1020
1020
|
wrapCommand
|
|
1021
1021
|
} = create$2();
|
|
1022
1022
|
|
|
1023
|
-
const create$1 = (uid, x, y, width, height,
|
|
1023
|
+
const create$1 = (uid, x, y, width, height, editorUid, editorLanguageId) => {
|
|
1024
1024
|
const state = {
|
|
1025
1025
|
uid,
|
|
1026
1026
|
items: [],
|
|
@@ -1039,7 +1039,9 @@ const create$1 = (uid, x, y, width, height, parentUid) => {
|
|
|
1039
1039
|
headerHeight: 0,
|
|
1040
1040
|
leadingWord: '',
|
|
1041
1041
|
unfilteredItems: [],
|
|
1042
|
-
version: 0
|
|
1042
|
+
version: 0,
|
|
1043
|
+
editorUid,
|
|
1044
|
+
editorLanguageId
|
|
1043
1045
|
};
|
|
1044
1046
|
set$2(uid, state, state);
|
|
1045
1047
|
};
|
|
@@ -1189,22 +1191,24 @@ const activateByEvent = async event => {
|
|
|
1189
1191
|
};
|
|
1190
1192
|
|
|
1191
1193
|
const execute = async ({
|
|
1192
|
-
|
|
1194
|
+
editorLanguageId,
|
|
1195
|
+
editorUid,
|
|
1193
1196
|
args,
|
|
1194
1197
|
event,
|
|
1195
1198
|
method,
|
|
1196
1199
|
noProviderFoundMessage,
|
|
1197
1200
|
noProviderFoundResult = undefined
|
|
1198
1201
|
}) => {
|
|
1199
|
-
const fullEvent = `${event}:${
|
|
1202
|
+
const fullEvent = `${event}:${editorLanguageId}`;
|
|
1200
1203
|
await activateByEvent(fullEvent);
|
|
1201
|
-
const result = await invoke(method,
|
|
1204
|
+
const result = await invoke(method, editorUid, ...args);
|
|
1202
1205
|
return result;
|
|
1203
1206
|
};
|
|
1204
1207
|
|
|
1205
|
-
const executeCompletionProvider = async (
|
|
1208
|
+
const executeCompletionProvider = async (editorUid, editorLanguageId, offset) => {
|
|
1206
1209
|
return execute({
|
|
1207
|
-
|
|
1210
|
+
editorUid,
|
|
1211
|
+
editorLanguageId,
|
|
1208
1212
|
event: OnCompletion,
|
|
1209
1213
|
method: CompletionExecute,
|
|
1210
1214
|
args: [offset],
|
|
@@ -1212,15 +1216,15 @@ const executeCompletionProvider = async (editor, offset) => {
|
|
|
1212
1216
|
noProviderFoundResult: []});
|
|
1213
1217
|
};
|
|
1214
1218
|
|
|
1215
|
-
const getOffsetAtCursor =
|
|
1216
|
-
// TODO
|
|
1219
|
+
const getOffsetAtCursor = editorUid => {
|
|
1220
|
+
// TODO ask editor worker
|
|
1217
1221
|
return 0;
|
|
1218
1222
|
};
|
|
1219
1223
|
|
|
1220
1224
|
// TODO possible to do this with events/state machine instead of promises -> enables canceling operations / concurrent calls
|
|
1221
|
-
const getCompletions = async
|
|
1225
|
+
const getCompletions = async (editorUid, editorLanguageId) => {
|
|
1222
1226
|
const offset = getOffsetAtCursor();
|
|
1223
|
-
const completions = await executeCompletionProvider(
|
|
1227
|
+
const completions = await executeCompletionProvider(editorUid, editorLanguageId, offset);
|
|
1224
1228
|
return completions;
|
|
1225
1229
|
};
|
|
1226
1230
|
|
|
@@ -1442,41 +1446,28 @@ const getPositionAtCursor = async parentUid => {
|
|
|
1442
1446
|
return position;
|
|
1443
1447
|
};
|
|
1444
1448
|
|
|
1445
|
-
const
|
|
1446
|
-
|
|
1447
|
-
const {
|
|
1448
|
-
lines,
|
|
1449
|
-
selections
|
|
1450
|
-
} = editor;
|
|
1451
|
-
const rowIndex = selections[0];
|
|
1452
|
-
const columnIndex = selections[1];
|
|
1453
|
-
const line = lines[rowIndex];
|
|
1454
|
-
const part = line.slice(0, columnIndex);
|
|
1455
|
-
const wordMatch = part.match(RE_WORD);
|
|
1456
|
-
if (wordMatch) {
|
|
1457
|
-
return wordMatch[0];
|
|
1458
|
-
}
|
|
1449
|
+
const getWordAtOffset = async editorUid => {
|
|
1450
|
+
// TODO ask editor worker
|
|
1459
1451
|
return '';
|
|
1460
1452
|
};
|
|
1461
1453
|
|
|
1462
1454
|
const loadContent = async state => {
|
|
1463
|
-
const editor = {}; // TODO
|
|
1464
1455
|
const {
|
|
1465
1456
|
itemHeight,
|
|
1466
|
-
maxHeight
|
|
1457
|
+
maxHeight,
|
|
1458
|
+
editorUid,
|
|
1459
|
+
editorLanguageId
|
|
1467
1460
|
} = state;
|
|
1468
|
-
const unfilteredItems = await getCompletions(
|
|
1469
|
-
const wordAtOffset = getWordAtOffset(
|
|
1461
|
+
const unfilteredItems = await getCompletions(editorUid, editorLanguageId);
|
|
1462
|
+
const wordAtOffset = await getWordAtOffset();
|
|
1470
1463
|
const items = filterCompletionItems(unfilteredItems, wordAtOffset);
|
|
1471
1464
|
const {
|
|
1472
1465
|
rowIndex,
|
|
1473
1466
|
columnIndex,
|
|
1474
1467
|
x,
|
|
1475
1468
|
y
|
|
1476
|
-
} = await getPositionAtCursor(
|
|
1469
|
+
} = await getPositionAtCursor(editorUid);
|
|
1477
1470
|
const newMaxLineY = Math.min(items.length, 8);
|
|
1478
|
-
editor.widgets = editor.widgets || [];
|
|
1479
|
-
// editor.widgets.push(ViewletModuleId.EditorCompletion)
|
|
1480
1471
|
const itemsLength = items.length;
|
|
1481
1472
|
const newFocusedIndex = itemsLength === 0 ? -1 : 0;
|
|
1482
1473
|
const total = items.length;
|
|
@@ -1496,7 +1487,6 @@ const loadContent = async state => {
|
|
|
1496
1487
|
// @ts-ignore
|
|
1497
1488
|
rowIndex,
|
|
1498
1489
|
columnIndex,
|
|
1499
|
-
// editorUid,
|
|
1500
1490
|
width: 200
|
|
1501
1491
|
};
|
|
1502
1492
|
};
|