@lvce-editor/completion-worker 1.23.0 → 1.25.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 +39 -32
- package/package.json +1 -1
|
@@ -626,7 +626,8 @@ const splitLines = lines => {
|
|
|
626
626
|
return lines.split(NewLine);
|
|
627
627
|
};
|
|
628
628
|
const getCurrentStack = () => {
|
|
629
|
-
const
|
|
629
|
+
const stackLinesToSkip = 3;
|
|
630
|
+
const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
|
|
630
631
|
return currentStack;
|
|
631
632
|
};
|
|
632
633
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
@@ -897,6 +898,12 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
|
897
898
|
return invokeHelper(ipc, method, params, true);
|
|
898
899
|
};
|
|
899
900
|
|
|
901
|
+
class CommandNotFoundError extends Error {
|
|
902
|
+
constructor(command) {
|
|
903
|
+
super(`Command not found ${command}`);
|
|
904
|
+
this.name = 'CommandNotFoundError';
|
|
905
|
+
}
|
|
906
|
+
}
|
|
900
907
|
const commands = Object.create(null);
|
|
901
908
|
const register = commandMap => {
|
|
902
909
|
Object.assign(commands, commandMap);
|
|
@@ -907,7 +914,7 @@ const getCommand$1 = key => {
|
|
|
907
914
|
const execute$1 = (command, ...args) => {
|
|
908
915
|
const fn = getCommand$1(command);
|
|
909
916
|
if (!fn) {
|
|
910
|
-
throw new
|
|
917
|
+
throw new CommandNotFoundError(command);
|
|
911
918
|
}
|
|
912
919
|
return fn(...args);
|
|
913
920
|
};
|
|
@@ -1130,14 +1137,14 @@ const create$1 = rpcId => {
|
|
|
1130
1137
|
}
|
|
1131
1138
|
};
|
|
1132
1139
|
};
|
|
1133
|
-
const EditorWorker$
|
|
1140
|
+
const EditorWorker$1 = 99;
|
|
1134
1141
|
const ExtensionHostWorker = 44;
|
|
1135
1142
|
const {
|
|
1136
|
-
invoke: invoke$
|
|
1143
|
+
invoke: invoke$c,
|
|
1137
1144
|
invokeAndTransfer: invokeAndTransfer$c,
|
|
1138
1145
|
set: set$c,
|
|
1139
1146
|
dispose: dispose$c
|
|
1140
|
-
} = create$1(EditorWorker$
|
|
1147
|
+
} = create$1(EditorWorker$1);
|
|
1141
1148
|
const sendMessagePortToExtensionHostWorker$1$1 = async port => {
|
|
1142
1149
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1143
1150
|
await invokeAndTransfer$c(
|
|
@@ -1149,40 +1156,40 @@ const sendMessagePortToExtensionHostWorker$1$1 = async port => {
|
|
|
1149
1156
|
// TODO add tests for this
|
|
1150
1157
|
const activateByEvent$1$1 = async event => {
|
|
1151
1158
|
// @ts-ignore
|
|
1152
|
-
await invoke$
|
|
1159
|
+
await invoke$c('ActivateByEvent.activateByEvent', event);
|
|
1153
1160
|
};
|
|
1154
1161
|
const applyEdit$2 = async (editorUid, changes) => {
|
|
1155
1162
|
// @ts-ignore
|
|
1156
|
-
await
|
|
1163
|
+
await invoke$c('Editor.applyEdit2', editorUid, changes);
|
|
1157
1164
|
};
|
|
1158
1165
|
const closeWidget$1 = async (editorUid, widgetId, widgetName, focusId) => {
|
|
1159
1166
|
// @ts-ignore
|
|
1160
|
-
await invoke$
|
|
1167
|
+
await invoke$c('Editor.closeWidget2', editorUid, widgetId, widgetName, focusId);
|
|
1161
1168
|
};
|
|
1162
1169
|
const getWordAt$1 = async (uid, rowIndex, columnIndex) => {
|
|
1163
1170
|
// @ts-ignore
|
|
1164
|
-
const word = await invoke$
|
|
1171
|
+
const word = await invoke$c('Editor.getWordAt2', uid, rowIndex, columnIndex);
|
|
1165
1172
|
return word;
|
|
1166
1173
|
};
|
|
1167
1174
|
const getLines$2 = async editorUid => {
|
|
1168
|
-
const lines = await invoke$
|
|
1175
|
+
const lines = await invoke$c('Editor.getLines2', editorUid);
|
|
1169
1176
|
return lines;
|
|
1170
1177
|
};
|
|
1171
1178
|
const getPositionAtCursor$2 = async parentUid => {
|
|
1172
|
-
const position = await invoke$
|
|
1179
|
+
const position = await invoke$c('Editor.getPositionAtCursor', parentUid);
|
|
1173
1180
|
return position;
|
|
1174
1181
|
};
|
|
1175
1182
|
const getSelections$2 = async editorUid => {
|
|
1176
|
-
const selections = await invoke$
|
|
1183
|
+
const selections = await invoke$c('Editor.getSelections2', editorUid);
|
|
1177
1184
|
return selections;
|
|
1178
1185
|
};
|
|
1179
1186
|
const getWordAtOffset2$1 = async editorUid => {
|
|
1180
|
-
return invoke$
|
|
1187
|
+
return invoke$c('Editor.getWordAtOffset2', editorUid);
|
|
1181
1188
|
};
|
|
1182
1189
|
const getWordBefore$2 = async (editorUid, rowIndex, columnIndex) => {
|
|
1183
|
-
return invoke$
|
|
1190
|
+
return invoke$c('Editor.getWordBefore2', editorUid, rowIndex, columnIndex);
|
|
1184
1191
|
};
|
|
1185
|
-
const EditorWorker$
|
|
1192
|
+
const EditorWorker$2 = {
|
|
1186
1193
|
__proto__: null,
|
|
1187
1194
|
activateByEvent: activateByEvent$1$1,
|
|
1188
1195
|
applyEdit: applyEdit$2,
|
|
@@ -1194,17 +1201,16 @@ const EditorWorker$1$1 = {
|
|
|
1194
1201
|
getWordAt: getWordAt$1,
|
|
1195
1202
|
getWordAtOffset2: getWordAtOffset2$1,
|
|
1196
1203
|
getWordBefore: getWordBefore$2,
|
|
1197
|
-
invoke: invoke$
|
|
1204
|
+
invoke: invoke$c,
|
|
1198
1205
|
invokeAndTransfer: invokeAndTransfer$c,
|
|
1199
1206
|
sendMessagePortToExtensionHostWorker: sendMessagePortToExtensionHostWorker$1$1,
|
|
1200
|
-
set: set$c
|
|
1201
|
-
};
|
|
1207
|
+
set: set$c};
|
|
1202
1208
|
const {
|
|
1203
|
-
invoke: invoke$
|
|
1209
|
+
invoke: invoke$9,
|
|
1204
1210
|
set: set$9} = create$1(ExtensionHostWorker);
|
|
1205
1211
|
const ExtensionHost = {
|
|
1206
1212
|
__proto__: null,
|
|
1207
|
-
invoke: invoke$
|
|
1213
|
+
invoke: invoke$9,
|
|
1208
1214
|
set: set$9
|
|
1209
1215
|
};
|
|
1210
1216
|
|
|
@@ -1223,9 +1229,9 @@ const {
|
|
|
1223
1229
|
getWordAtOffset2,
|
|
1224
1230
|
getWordBefore: getWordBefore$1,
|
|
1225
1231
|
invokeAndTransfer
|
|
1226
|
-
} = EditorWorker$
|
|
1232
|
+
} = EditorWorker$2;
|
|
1227
1233
|
|
|
1228
|
-
const EditorWorker
|
|
1234
|
+
const EditorWorker = {
|
|
1229
1235
|
__proto__: null,
|
|
1230
1236
|
activateByEvent: activateByEvent$1,
|
|
1231
1237
|
applyEdit: applyEdit$1,
|
|
@@ -1383,11 +1389,11 @@ const applyEdit = async (editorUid, changes) => {
|
|
|
1383
1389
|
|
|
1384
1390
|
const {
|
|
1385
1391
|
getLines
|
|
1386
|
-
} = EditorWorker
|
|
1392
|
+
} = EditorWorker;
|
|
1387
1393
|
|
|
1388
1394
|
const {
|
|
1389
1395
|
getSelections
|
|
1390
|
-
} = EditorWorker
|
|
1396
|
+
} = EditorWorker;
|
|
1391
1397
|
|
|
1392
1398
|
const getSelectionPairs = (selections, i) => {
|
|
1393
1399
|
const first = selections[i];
|
|
@@ -1447,7 +1453,7 @@ const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
|
1447
1453
|
|
|
1448
1454
|
const {
|
|
1449
1455
|
activateByEvent
|
|
1450
|
-
} = EditorWorker
|
|
1456
|
+
} = EditorWorker;
|
|
1451
1457
|
|
|
1452
1458
|
const {
|
|
1453
1459
|
invoke,
|
|
@@ -1488,9 +1494,10 @@ const executeResolveCompletionItem = async (editorUid, offset, name, completionI
|
|
|
1488
1494
|
noProviderFoundResult: []});
|
|
1489
1495
|
};
|
|
1490
1496
|
|
|
1491
|
-
const getOffsetAtCursor = editorUid => {
|
|
1497
|
+
const getOffsetAtCursor = async editorUid => {
|
|
1492
1498
|
// TODO ask editor worker
|
|
1493
|
-
|
|
1499
|
+
// @ts-ignore
|
|
1500
|
+
return invoke$1('Editor.getOffsetAtCursor', editorUid);
|
|
1494
1501
|
};
|
|
1495
1502
|
|
|
1496
1503
|
// TODO don't send unnecessary parts of completion item like matches
|
|
@@ -1498,7 +1505,7 @@ const resolveCompletion = async (editorUid, name, completionItem) => {
|
|
|
1498
1505
|
try {
|
|
1499
1506
|
string(name);
|
|
1500
1507
|
object(completionItem);
|
|
1501
|
-
const offset = getOffsetAtCursor(editorUid);
|
|
1508
|
+
const offset = await getOffsetAtCursor(editorUid);
|
|
1502
1509
|
const resolvedCompletionItem = await executeResolveCompletionItem(editorUid, offset, name, completionItem);
|
|
1503
1510
|
return resolvedCompletionItem;
|
|
1504
1511
|
} catch {
|
|
@@ -1846,7 +1853,7 @@ const getListHeight = (itemsLength, itemHeight, maxHeight) => {
|
|
|
1846
1853
|
|
|
1847
1854
|
const {
|
|
1848
1855
|
getPositionAtCursor
|
|
1849
|
-
} = EditorWorker
|
|
1856
|
+
} = EditorWorker;
|
|
1850
1857
|
|
|
1851
1858
|
const getWordAtOffset = getWordAtOffset2;
|
|
1852
1859
|
|
|
@@ -1885,7 +1892,7 @@ const handleEditorDeleteLeft = async state => {
|
|
|
1885
1892
|
|
|
1886
1893
|
const {
|
|
1887
1894
|
getWordBefore
|
|
1888
|
-
} = EditorWorker
|
|
1895
|
+
} = EditorWorker;
|
|
1889
1896
|
|
|
1890
1897
|
const handleEditorType = async state => {
|
|
1891
1898
|
const {
|
|
@@ -1991,7 +1998,7 @@ const handleWheel = (state, deltaMode, deltaY) => {
|
|
|
1991
1998
|
|
|
1992
1999
|
const {
|
|
1993
2000
|
sendMessagePortToExtensionHostWorker
|
|
1994
|
-
} = EditorWorker
|
|
2001
|
+
} = EditorWorker;
|
|
1995
2002
|
|
|
1996
2003
|
const createExtensionHostRpc = async () => {
|
|
1997
2004
|
try {
|
|
@@ -2019,7 +2026,7 @@ const error = message => {
|
|
|
2019
2026
|
// TODO possible to do this with events/state machine instead of promises -> enables canceling operations / concurrent calls
|
|
2020
2027
|
const getCompletions = async (editorUid, editorLanguageId) => {
|
|
2021
2028
|
try {
|
|
2022
|
-
const offset = getOffsetAtCursor(editorUid);
|
|
2029
|
+
const offset = await getOffsetAtCursor(editorUid);
|
|
2023
2030
|
const completions = await executeCompletionProvider(editorUid, editorLanguageId, offset);
|
|
2024
2031
|
return completions;
|
|
2025
2032
|
} catch (error$1) {
|