@lvce-editor/editor-worker 19.68.6 → 19.69.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/editorWorkerMain.js +333 -217
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -1343,6 +1343,7 @@ const {
|
|
|
1343
1343
|
|
|
1344
1344
|
const {
|
|
1345
1345
|
invoke: invoke$g,
|
|
1346
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1346
1347
|
set: set$d
|
|
1347
1348
|
} = create$c(ExtensionManagementWorker);
|
|
1348
1349
|
const getLanguages$1 = (platform, assetDir) => {
|
|
@@ -1437,7 +1438,7 @@ const {
|
|
|
1437
1438
|
|
|
1438
1439
|
const {
|
|
1439
1440
|
invoke: invoke$d,
|
|
1440
|
-
invokeAndTransfer,
|
|
1441
|
+
invokeAndTransfer: invokeAndTransfer$1,
|
|
1441
1442
|
set: set$a
|
|
1442
1443
|
} = create$c(RendererWorker);
|
|
1443
1444
|
const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
@@ -1449,19 +1450,19 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
|
|
|
1449
1450
|
};
|
|
1450
1451
|
const sendMessagePortToDragAndDropWorker = async port => {
|
|
1451
1452
|
const command = 'DragAndDrop.handleMessagePort';
|
|
1452
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command);
|
|
1453
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToRendererProcess', port, command);
|
|
1453
1454
|
};
|
|
1454
1455
|
const sendMessagePortToOpenerWorker = async (port, rpcId) => {
|
|
1455
1456
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1456
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
|
|
1457
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToOpenerWorker', port, command, rpcId);
|
|
1457
1458
|
};
|
|
1458
1459
|
const sendMessagePortToDialogWorker = async port => {
|
|
1459
1460
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1460
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1461
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
|
|
1461
1462
|
};
|
|
1462
1463
|
const sendMessagePortToErrorWorker = async (port, rpcId) => {
|
|
1463
1464
|
const command = 'Errors.handleMessagePort';
|
|
1464
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1465
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToErrorWorker', port, command, rpcId);
|
|
1465
1466
|
};
|
|
1466
1467
|
const writeClipBoardText = async text => {
|
|
1467
1468
|
await invoke$d('ClipBoard.writeText', /* text */text);
|
|
@@ -1471,11 +1472,11 @@ const readClipBoardText = async () => {
|
|
|
1471
1472
|
};
|
|
1472
1473
|
const sendMessagePortToTextMeasurementWorker = async port => {
|
|
1473
1474
|
const command = 'TextMeasurement.handleMessagePort';
|
|
1474
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1475
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToTextMeasurementWorker', port, command, 0);
|
|
1475
1476
|
};
|
|
1476
1477
|
const sendMessagePortToExtensionManagementWorker$1 = async (port, rpcId) => {
|
|
1477
1478
|
const command = 'Extensions.handleMessagePort';
|
|
1478
|
-
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1479
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
|
|
1479
1480
|
};
|
|
1480
1481
|
const getPreference = async key => {
|
|
1481
1482
|
return await invoke$d('Preferences.get', key);
|
|
@@ -1488,7 +1489,7 @@ const openUri = async (uri, focus, options) => {
|
|
|
1488
1489
|
});
|
|
1489
1490
|
};
|
|
1490
1491
|
const sendMessagePortToSyntaxHighlightingWorker$1 = async port => {
|
|
1491
|
-
await invokeAndTransfer('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
|
|
1492
|
+
await invokeAndTransfer$1('SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort2');
|
|
1492
1493
|
};
|
|
1493
1494
|
|
|
1494
1495
|
const {
|
|
@@ -3847,7 +3848,7 @@ const splitLines = lines => {
|
|
|
3847
3848
|
const state$9 = {};
|
|
3848
3849
|
const create$a = () => create$g({
|
|
3849
3850
|
commandMap: {},
|
|
3850
|
-
send: port => invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, 'FileSystem.connect')
|
|
3851
|
+
send: port => invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToFileSystemWorker', port, 'FileSystem.connect')
|
|
3851
3852
|
});
|
|
3852
3853
|
const invoke$a = async (method, ...args) => {
|
|
3853
3854
|
state$9.rpcPromise ||= create$a();
|
|
@@ -4618,6 +4619,9 @@ const updateColorPickerValue$1 = async (editor, value) => {
|
|
|
4618
4619
|
const invoke$8 = async (applicationId, method, ...args) => {
|
|
4619
4620
|
return applicationId === undefined ? invoke$g(method, ...args) : invoke$g('Extensions.invokeForApplication', applicationId, method, ...args);
|
|
4620
4621
|
};
|
|
4622
|
+
const invokeAndTransfer = async (applicationId, method, ...args) => {
|
|
4623
|
+
return applicationId === undefined ? invokeAndTransfer$2(method, ...args) : invokeAndTransfer$2('Extensions.invokeForApplication', applicationId, method, ...args);
|
|
4624
|
+
};
|
|
4621
4625
|
|
|
4622
4626
|
const getTextDocument$3 = editor => ({
|
|
4623
4627
|
documentId: editor.id || editor.uid,
|
|
@@ -5265,7 +5269,7 @@ const launchWorker = async (name, url, intializeCommand, commandMap = {}) => {
|
|
|
5265
5269
|
commandMap,
|
|
5266
5270
|
isMessagePortOpen: true,
|
|
5267
5271
|
async send(port) {
|
|
5268
|
-
await invokeAndTransfer('IpcParent.create', {
|
|
5272
|
+
await invokeAndTransfer$1('IpcParent.create', {
|
|
5269
5273
|
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug,
|
|
5270
5274
|
name,
|
|
5271
5275
|
port,
|
|
@@ -6211,6 +6215,317 @@ const renderWidgets$1 = (oldState, newState) => {
|
|
|
6211
6215
|
return allCommands.filter(item => item[0] !== 'Viewlet.appendToBody' && (item[0] !== 'Viewlet.setFocusContext' || item.length >= 3));
|
|
6212
6216
|
};
|
|
6213
6217
|
|
|
6218
|
+
const queues = {};
|
|
6219
|
+
const enqueue = async (uid, callback) => {
|
|
6220
|
+
const instance = get$8(uid);
|
|
6221
|
+
if (!instance) {
|
|
6222
|
+
return undefined;
|
|
6223
|
+
}
|
|
6224
|
+
const {
|
|
6225
|
+
applicationId,
|
|
6226
|
+
uri
|
|
6227
|
+
} = instance.newState;
|
|
6228
|
+
const key = JSON.stringify([applicationId ?? null, uri || uid]);
|
|
6229
|
+
const previous = queues[key];
|
|
6230
|
+
const {
|
|
6231
|
+
promise,
|
|
6232
|
+
resolve
|
|
6233
|
+
} = Promise.withResolvers();
|
|
6234
|
+
queues[key] = promise;
|
|
6235
|
+
if (previous) {
|
|
6236
|
+
await previous;
|
|
6237
|
+
}
|
|
6238
|
+
try {
|
|
6239
|
+
return await callback();
|
|
6240
|
+
} finally {
|
|
6241
|
+
resolve();
|
|
6242
|
+
if (queues[key] === promise) {
|
|
6243
|
+
delete queues[key];
|
|
6244
|
+
}
|
|
6245
|
+
}
|
|
6246
|
+
};
|
|
6247
|
+
|
|
6248
|
+
const logError = async (error, prefix) => {
|
|
6249
|
+
const prettyError = await invoke$h('Errors.prepare', error);
|
|
6250
|
+
await invoke$h('Errors.print', prettyError, prefix);
|
|
6251
|
+
};
|
|
6252
|
+
const logFallback = (error, prefix) => {
|
|
6253
|
+
if (prefix) {
|
|
6254
|
+
console.error(prefix, error);
|
|
6255
|
+
return;
|
|
6256
|
+
}
|
|
6257
|
+
console.error(error);
|
|
6258
|
+
};
|
|
6259
|
+
const handleError$1 = async (error, prefix = '') => {
|
|
6260
|
+
try {
|
|
6261
|
+
await logError(error, prefix);
|
|
6262
|
+
} catch (otherError) {
|
|
6263
|
+
console.warn('ErrorHandling error', otherError);
|
|
6264
|
+
logFallback(error, prefix);
|
|
6265
|
+
}
|
|
6266
|
+
};
|
|
6267
|
+
|
|
6268
|
+
const getTextDocument$2 = editor => {
|
|
6269
|
+
return {
|
|
6270
|
+
documentId: editor.id || editor.uid,
|
|
6271
|
+
languageId: editor.languageId,
|
|
6272
|
+
text: getText$1(editor),
|
|
6273
|
+
uri: editor.uri
|
|
6274
|
+
};
|
|
6275
|
+
};
|
|
6276
|
+
const streamIsolatedDiagnosticProvider = async (editor, resultPort) => {
|
|
6277
|
+
const textDocument = getTextDocument$2(editor);
|
|
6278
|
+
return invokeAndTransfer(editor.applicationId, 'Extensions.streamDiagnosticProvider', textDocument, resultPort);
|
|
6279
|
+
};
|
|
6280
|
+
const streamDiagnosticProvider = async (editor, resultPort) => {
|
|
6281
|
+
return streamIsolatedDiagnosticProvider(editor, resultPort);
|
|
6282
|
+
};
|
|
6283
|
+
|
|
6284
|
+
const invoke$5 = (...args) => invoke$d(...args);
|
|
6285
|
+
|
|
6286
|
+
/**
|
|
6287
|
+
* Merges link decorations with diagnostic decorations
|
|
6288
|
+
* Links should always be present, but we also need to include any diagnostic decorations
|
|
6289
|
+
*/
|
|
6290
|
+
const mergeLinksWithDiagnosticDecorations = (editor, diagnosticDecorations) => {
|
|
6291
|
+
// Get link decorations
|
|
6292
|
+
const linkDecorations = detectAllLinksAsDecorations(editor);
|
|
6293
|
+
|
|
6294
|
+
// Merge with diagnostic decorations
|
|
6295
|
+
const allDecorations = [...linkDecorations, ...diagnosticDecorations];
|
|
6296
|
+
|
|
6297
|
+
// Sort by offset to maintain proper order
|
|
6298
|
+
const sortedDecorations = [];
|
|
6299
|
+
for (let i = 0; i < allDecorations.length; i += 4) {
|
|
6300
|
+
sortedDecorations.push({
|
|
6301
|
+
length: allDecorations[i + 1],
|
|
6302
|
+
modifiers: allDecorations[i + 3],
|
|
6303
|
+
offset: allDecorations[i],
|
|
6304
|
+
type: allDecorations[i + 2]
|
|
6305
|
+
});
|
|
6306
|
+
}
|
|
6307
|
+
sortedDecorations.sort((a, b) => a.offset - b.offset);
|
|
6308
|
+
|
|
6309
|
+
// Flatten back to array format
|
|
6310
|
+
const result = [];
|
|
6311
|
+
for (const dec of sortedDecorations) {
|
|
6312
|
+
result.push(dec.offset, dec.length, dec.type, dec.modifiers);
|
|
6313
|
+
}
|
|
6314
|
+
return result;
|
|
6315
|
+
};
|
|
6316
|
+
|
|
6317
|
+
const requestGenerations = new Map();
|
|
6318
|
+
const requestDiagnosticSnapshots = new Map();
|
|
6319
|
+
const previousProviderResults = new Map();
|
|
6320
|
+
const getDiagnostics$1 = async (editor, resultPort) => {
|
|
6321
|
+
return streamDiagnosticProvider(editor, resultPort);
|
|
6322
|
+
};
|
|
6323
|
+
const addDiagnostics = async (editor, diagnostics) => {
|
|
6324
|
+
const visualDecorations = await getVisibleDiagnostics(editor, diagnostics);
|
|
6325
|
+
const diagnosticDecorations = visualDecorations.flatMap(decoration => [decoration.offset, decoration.length, decoration.type, decoration.modifiers || 0]);
|
|
6326
|
+
const decorations = mergeLinksWithDiagnosticDecorations(editor, diagnosticDecorations);
|
|
6327
|
+
return {
|
|
6328
|
+
...editor,
|
|
6329
|
+
decorations,
|
|
6330
|
+
diagnostics,
|
|
6331
|
+
lightBulbRowIndex: -1,
|
|
6332
|
+
visualDecorations
|
|
6333
|
+
};
|
|
6334
|
+
};
|
|
6335
|
+
const handleError = async (error, editor) => {
|
|
6336
|
+
if (error instanceof Error && error.message.includes('No diagnostic provider found')) {
|
|
6337
|
+
return editor;
|
|
6338
|
+
}
|
|
6339
|
+
await handleError$1(error, 'Failed to update diagnostics: ');
|
|
6340
|
+
return editor;
|
|
6341
|
+
};
|
|
6342
|
+
const notifyDiagnosticsChange = async (uri, applicationId) => {
|
|
6343
|
+
try {
|
|
6344
|
+
await invoke$9(applicationId, 'Layout.handleDiagnosticsChange', uri);
|
|
6345
|
+
} catch {
|
|
6346
|
+
// Older renderer workers do not support diagnostics change listeners.
|
|
6347
|
+
}
|
|
6348
|
+
};
|
|
6349
|
+
const diagnosticsEqual = (left, right) => {
|
|
6350
|
+
if (left === right) {
|
|
6351
|
+
return true;
|
|
6352
|
+
}
|
|
6353
|
+
if ((left?.length ?? 0) !== right.length) {
|
|
6354
|
+
return false;
|
|
6355
|
+
}
|
|
6356
|
+
return right.every((diagnostic, index) => {
|
|
6357
|
+
const other = left[index];
|
|
6358
|
+
return other.code === diagnostic.code && other.columnIndex === diagnostic.columnIndex && other.endColumnIndex === diagnostic.endColumnIndex && other.endRowIndex === diagnostic.endRowIndex && other.message === diagnostic.message && other.rowIndex === diagnostic.rowIndex && other.source === diagnostic.source && other.type === diagnostic.type && other.uri === diagnostic.uri;
|
|
6359
|
+
});
|
|
6360
|
+
};
|
|
6361
|
+
const diagnosticLayoutEqual = (left, right) => left.charWidth === right.charWidth && left.deltaY === right.deltaY && left.fontFamily === right.fontFamily && left.fontSize === right.fontSize && left.fontWeight === right.fontWeight && left.isMonospaceFont === right.isMonospaceFont && left.itemHeight === right.itemHeight && left.letterSpacing === right.letterSpacing && left.lines === right.lines && left.minLineY === right.minLineY && left.rowHeight === right.rowHeight && left.tabSize === right.tabSize && left.viewLineIndices === right.viewLineIndices && left.width === right.width;
|
|
6362
|
+
const isApplicable = (latest, editor, generation) => latest && requestGenerations.get(editor.id) === generation && latest.newState.diagnostics === requestDiagnosticSnapshots.get(editor.id) && latest.newState.diagnosticsEnabled && !latest.newState.loadError && latest.newState.languageId === editor.languageId && latest.newState.lines === editor.lines && latest.newState.uri === editor.uri;
|
|
6363
|
+
const mergeDiagnostics = (editor, editorWithDiagnostics) => ({
|
|
6364
|
+
...editor,
|
|
6365
|
+
decorations: editorWithDiagnostics.decorations,
|
|
6366
|
+
diagnostics: editorWithDiagnostics.diagnostics,
|
|
6367
|
+
lightBulbRowIndex: editorWithDiagnostics.lightBulbRowIndex,
|
|
6368
|
+
visualDecorations: editorWithDiagnostics.visualDecorations
|
|
6369
|
+
});
|
|
6370
|
+
const commitDiagnostics = async (editor, generation, diagnostics) => {
|
|
6371
|
+
return (await enqueue(editor.id, async () => {
|
|
6372
|
+
let latest = get$8(editor.id);
|
|
6373
|
+
if (!isApplicable(latest, editor, generation)) {
|
|
6374
|
+
return editor;
|
|
6375
|
+
}
|
|
6376
|
+
if (diagnosticsEqual(latest.newState.diagnostics, diagnostics)) {
|
|
6377
|
+
return latest.newState;
|
|
6378
|
+
}
|
|
6379
|
+
let calculationState = latest.newState;
|
|
6380
|
+
let editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
6381
|
+
latest = get$8(editor.id);
|
|
6382
|
+
while (isApplicable(latest, editor, generation) && !diagnosticLayoutEqual(calculationState, latest.newState)) {
|
|
6383
|
+
calculationState = latest.newState;
|
|
6384
|
+
editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
6385
|
+
latest = get$8(editor.id);
|
|
6386
|
+
}
|
|
6387
|
+
if (!isApplicable(latest, editor, generation)) {
|
|
6388
|
+
return editor;
|
|
6389
|
+
}
|
|
6390
|
+
if (diagnosticsEqual(latest.newState.diagnostics, diagnostics)) {
|
|
6391
|
+
return latest.newState;
|
|
6392
|
+
}
|
|
6393
|
+
const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
|
|
6394
|
+
set$8(editor.id, latest.oldState, newEditor);
|
|
6395
|
+
requestDiagnosticSnapshots.set(editor.id, diagnostics);
|
|
6396
|
+
await invoke$5('Editor.renderPending', newEditor.id);
|
|
6397
|
+
await notifyDiagnosticsChange(newEditor.uri, newEditor.applicationId);
|
|
6398
|
+
return newEditor;
|
|
6399
|
+
})) ?? editor;
|
|
6400
|
+
};
|
|
6401
|
+
const flattenProviderDiagnostics = providers => {
|
|
6402
|
+
return providers.values().toArray().toSorted((left, right) => left.providerIndex - right.providerIndex).flatMap(({
|
|
6403
|
+
diagnostics
|
|
6404
|
+
}) => diagnostics);
|
|
6405
|
+
};
|
|
6406
|
+
const updateDiagnostics = async editor => {
|
|
6407
|
+
if (!editor.diagnosticsEnabled || editor.loadError) {
|
|
6408
|
+
return editor;
|
|
6409
|
+
}
|
|
6410
|
+
const generation = (requestGenerations.get(editor.id) ?? 0) + 1;
|
|
6411
|
+
requestGenerations.set(editor.id, generation);
|
|
6412
|
+
requestDiagnosticSnapshots.set(editor.id, get$8(editor.id)?.newState.diagnostics ?? editor.diagnostics);
|
|
6413
|
+
const providers = new Map();
|
|
6414
|
+
const previous = previousProviderResults.get(editor.id);
|
|
6415
|
+
if (previous && previous.languageId === editor.languageId && previous.lines === editor.lines && previous.uri === editor.uri) {
|
|
6416
|
+
for (const [providerId, result] of previous.providers) {
|
|
6417
|
+
providers.set(providerId, result);
|
|
6418
|
+
}
|
|
6419
|
+
}
|
|
6420
|
+
const {
|
|
6421
|
+
port1,
|
|
6422
|
+
port2
|
|
6423
|
+
} = new MessageChannel();
|
|
6424
|
+
const completed = Promise.withResolvers();
|
|
6425
|
+
let commitQueue = Promise.resolve();
|
|
6426
|
+
let providerCount = -1;
|
|
6427
|
+
port1.onmessage = event => {
|
|
6428
|
+
const previousCommit = commitQueue;
|
|
6429
|
+
commitQueue = (async () => {
|
|
6430
|
+
await previousCommit;
|
|
6431
|
+
try {
|
|
6432
|
+
const message = event.data;
|
|
6433
|
+
if (requestGenerations.get(editor.id) !== generation) {
|
|
6434
|
+
if (message.type === 'done') {
|
|
6435
|
+
port1.close();
|
|
6436
|
+
completed.resolve();
|
|
6437
|
+
}
|
|
6438
|
+
return;
|
|
6439
|
+
}
|
|
6440
|
+
if (message.type === 'providers') {
|
|
6441
|
+
providerCount = message.providerCount ?? 0;
|
|
6442
|
+
const providerIds = message.providerIds ?? [];
|
|
6443
|
+
for (const providerId of providers.keys()) {
|
|
6444
|
+
if (providerIds.includes(providerId)) {
|
|
6445
|
+
const previousResult = providers.get(providerId);
|
|
6446
|
+
providers.set(providerId, {
|
|
6447
|
+
...previousResult,
|
|
6448
|
+
providerIndex: providerIds.indexOf(providerId)
|
|
6449
|
+
});
|
|
6450
|
+
} else {
|
|
6451
|
+
providers.delete(providerId);
|
|
6452
|
+
}
|
|
6453
|
+
}
|
|
6454
|
+
return;
|
|
6455
|
+
}
|
|
6456
|
+
if (message.type === 'result' && message.providerId !== undefined) {
|
|
6457
|
+
providers.set(message.providerId, {
|
|
6458
|
+
diagnostics: message.diagnostics ?? [],
|
|
6459
|
+
providerIndex: message.providerIndex ?? providers.size
|
|
6460
|
+
});
|
|
6461
|
+
await commitDiagnostics(editor, generation, flattenProviderDiagnostics(providers));
|
|
6462
|
+
return;
|
|
6463
|
+
}
|
|
6464
|
+
if (message.type === 'done') {
|
|
6465
|
+
if (providerCount === 0) {
|
|
6466
|
+
providers.clear();
|
|
6467
|
+
await commitDiagnostics(editor, generation, []);
|
|
6468
|
+
}
|
|
6469
|
+
previousProviderResults.set(editor.id, {
|
|
6470
|
+
languageId: editor.languageId,
|
|
6471
|
+
lines: editor.lines,
|
|
6472
|
+
providers: new Map(providers),
|
|
6473
|
+
uri: editor.uri
|
|
6474
|
+
});
|
|
6475
|
+
port1.close();
|
|
6476
|
+
completed.resolve();
|
|
6477
|
+
}
|
|
6478
|
+
} catch (error) {
|
|
6479
|
+
port1.close();
|
|
6480
|
+
completed.resolve();
|
|
6481
|
+
await handleError(error, editor);
|
|
6482
|
+
}
|
|
6483
|
+
})();
|
|
6484
|
+
};
|
|
6485
|
+
port1.start();
|
|
6486
|
+
try {
|
|
6487
|
+
const response = await getDiagnostics$1(editor, port2);
|
|
6488
|
+
if (Array.isArray(response) && providerCount === -1) {
|
|
6489
|
+
providers.set('legacy', {
|
|
6490
|
+
diagnostics: response,
|
|
6491
|
+
providerIndex: 0
|
|
6492
|
+
});
|
|
6493
|
+
await commitDiagnostics(editor, generation, response);
|
|
6494
|
+
previousProviderResults.set(editor.id, {
|
|
6495
|
+
languageId: editor.languageId,
|
|
6496
|
+
lines: editor.lines,
|
|
6497
|
+
providers: new Map(providers),
|
|
6498
|
+
uri: editor.uri
|
|
6499
|
+
});
|
|
6500
|
+
port1.close();
|
|
6501
|
+
completed.resolve();
|
|
6502
|
+
}
|
|
6503
|
+
await completed.promise;
|
|
6504
|
+
const latest = get$8(editor.id);
|
|
6505
|
+
return isApplicable(latest, editor, generation) ? latest.newState : editor;
|
|
6506
|
+
} catch (error) {
|
|
6507
|
+
port1.close();
|
|
6508
|
+
return handleError(error, editor);
|
|
6509
|
+
}
|
|
6510
|
+
};
|
|
6511
|
+
const requestDiagnostics = editor => {
|
|
6512
|
+
void updateDiagnostics(editor);
|
|
6513
|
+
return editor;
|
|
6514
|
+
};
|
|
6515
|
+
const clearDiagnosticRequestState = editorId => {
|
|
6516
|
+
requestGenerations.delete(editorId);
|
|
6517
|
+
requestDiagnosticSnapshots.delete(editorId);
|
|
6518
|
+
previousProviderResults.delete(editorId);
|
|
6519
|
+
};
|
|
6520
|
+
const updateDiagnosticsAll = async () => {
|
|
6521
|
+
for (const key of getKeys$2()) {
|
|
6522
|
+
const editor = get$8(Number(key))?.newState;
|
|
6523
|
+
if (editor) {
|
|
6524
|
+
await updateDiagnostics(editor);
|
|
6525
|
+
}
|
|
6526
|
+
}
|
|
6527
|
+
};
|
|
6528
|
+
|
|
6214
6529
|
const disposeEditor = async editorUid => {
|
|
6215
6530
|
const editor = get$8(editorUid)?.newState;
|
|
6216
6531
|
if (!editor) {
|
|
@@ -6221,6 +6536,7 @@ const disposeEditor = async editorUid => {
|
|
|
6221
6536
|
delete editor.lifecycle.sentLines;
|
|
6222
6537
|
}
|
|
6223
6538
|
// Invalidate the registry before awaiting widget or worker cleanup.
|
|
6539
|
+
clearDiagnosticRequestState(editorUid);
|
|
6224
6540
|
dispose$6(editorUid);
|
|
6225
6541
|
try {
|
|
6226
6542
|
await invoke$9(editor.applicationId, 'Layout.handleDiagnosticsChange', editor.uri);
|
|
@@ -6833,26 +7149,6 @@ const hasWidget = (widgets, id) => {
|
|
|
6833
7149
|
return false;
|
|
6834
7150
|
};
|
|
6835
7151
|
|
|
6836
|
-
const logError = async (error, prefix) => {
|
|
6837
|
-
const prettyError = await invoke$h('Errors.prepare', error);
|
|
6838
|
-
await invoke$h('Errors.print', prettyError, prefix);
|
|
6839
|
-
};
|
|
6840
|
-
const logFallback = (error, prefix) => {
|
|
6841
|
-
if (prefix) {
|
|
6842
|
-
console.error(prefix, error);
|
|
6843
|
-
return;
|
|
6844
|
-
}
|
|
6845
|
-
console.error(error);
|
|
6846
|
-
};
|
|
6847
|
-
const handleError$1 = async (error, prefix = '') => {
|
|
6848
|
-
try {
|
|
6849
|
-
await logError(error, prefix);
|
|
6850
|
-
} catch (otherError) {
|
|
6851
|
-
console.warn('ErrorHandling error', otherError);
|
|
6852
|
-
logFallback(error, prefix);
|
|
6853
|
-
}
|
|
6854
|
-
};
|
|
6855
|
-
|
|
6856
7152
|
const getFormattingEdits = async editor => {
|
|
6857
7153
|
if (editor.largeFile) {
|
|
6858
7154
|
return [];
|
|
@@ -9870,7 +10166,7 @@ const create$5 = () => {
|
|
|
9870
10166
|
return widget;
|
|
9871
10167
|
};
|
|
9872
10168
|
|
|
9873
|
-
const getTextDocument$
|
|
10169
|
+
const getTextDocument$1 = editor => {
|
|
9874
10170
|
return {
|
|
9875
10171
|
documentId: editor.id || editor.uid,
|
|
9876
10172
|
languageId: editor.languageId,
|
|
@@ -9879,7 +10175,7 @@ const getTextDocument$2 = editor => {
|
|
|
9879
10175
|
};
|
|
9880
10176
|
};
|
|
9881
10177
|
const executeIsolatedHoverProvider = async (editor, offset) => {
|
|
9882
|
-
const textDocument = getTextDocument$
|
|
10178
|
+
const textDocument = getTextDocument$1(editor);
|
|
9883
10179
|
return invoke$8(editor.applicationId, 'Extensions.executeHoverProvider', textDocument, offset);
|
|
9884
10180
|
};
|
|
9885
10181
|
const executeHoverProvider = async (editor, offset) => {
|
|
@@ -9896,8 +10192,6 @@ const getHover = async (editor, offset) => {
|
|
|
9896
10192
|
return hover;
|
|
9897
10193
|
};
|
|
9898
10194
|
|
|
9899
|
-
const invoke$5 = (...args) => invoke$d(...args);
|
|
9900
|
-
|
|
9901
10195
|
const getVirtualDomFromMarkdown = async markdown => {
|
|
9902
10196
|
const html = await invoke$5('Markdown.renderMarkdown', markdown, {
|
|
9903
10197
|
linksExternal: true
|
|
@@ -12522,7 +12816,7 @@ const getSignatureHelpWidgetBounds = (editor, rowIndex, columnIndex, lineCount,
|
|
|
12522
12816
|
};
|
|
12523
12817
|
};
|
|
12524
12818
|
|
|
12525
|
-
const getTextDocument
|
|
12819
|
+
const getTextDocument = editor => {
|
|
12526
12820
|
return {
|
|
12527
12821
|
documentId: editor.id || editor.uid,
|
|
12528
12822
|
languageId: editor.languageId,
|
|
@@ -12533,7 +12827,7 @@ const getTextDocument$1 = editor => {
|
|
|
12533
12827
|
const executeSignatureHelpProvider = async (editor, offset) => {
|
|
12534
12828
|
object(editor);
|
|
12535
12829
|
number(offset);
|
|
12536
|
-
const textDocument = getTextDocument
|
|
12830
|
+
const textDocument = getTextDocument(editor);
|
|
12537
12831
|
return invoke$8(editor.applicationId, 'Extensions.executeSignatureHelpProvider', textDocument, offset);
|
|
12538
12832
|
};
|
|
12539
12833
|
|
|
@@ -14443,7 +14737,7 @@ const getSourceActions = async editorUid => {
|
|
|
14443
14737
|
const actions = await getEditorSourceActions(editorUid);
|
|
14444
14738
|
return actions;
|
|
14445
14739
|
};
|
|
14446
|
-
const getDiagnostics
|
|
14740
|
+
const getDiagnostics = async editorUid => {
|
|
14447
14741
|
const editor = getEditor$1(editorUid);
|
|
14448
14742
|
const {
|
|
14449
14743
|
diagnostics
|
|
@@ -15496,7 +15790,7 @@ const sendMessagePortToSyntaxHighlightingWorker = async port => {
|
|
|
15496
15790
|
await sendMessagePortToSyntaxHighlightingWorker$1(port);
|
|
15497
15791
|
} catch {
|
|
15498
15792
|
// deprecated
|
|
15499
|
-
await invokeAndTransfer(
|
|
15793
|
+
await invokeAndTransfer$1(
|
|
15500
15794
|
// @ts-ignore
|
|
15501
15795
|
'SendMessagePortToSyntaxHighlightingWorker.sendMessagePortToSyntaxHighlightingWorker', port, 'HandleMessagePort.handleMessagePort');
|
|
15502
15796
|
}
|
|
@@ -17280,184 +17574,6 @@ const updateDebugInfo = async debugId => {
|
|
|
17280
17574
|
await invoke$d('Editor.rerender', key);
|
|
17281
17575
|
};
|
|
17282
17576
|
|
|
17283
|
-
const queues = {};
|
|
17284
|
-
const enqueue = async (uid, callback) => {
|
|
17285
|
-
const instance = get$8(uid);
|
|
17286
|
-
if (!instance) {
|
|
17287
|
-
return undefined;
|
|
17288
|
-
}
|
|
17289
|
-
const {
|
|
17290
|
-
applicationId,
|
|
17291
|
-
uri
|
|
17292
|
-
} = instance.newState;
|
|
17293
|
-
const key = JSON.stringify([applicationId ?? null, uri || uid]);
|
|
17294
|
-
const previous = queues[key];
|
|
17295
|
-
const {
|
|
17296
|
-
promise,
|
|
17297
|
-
resolve
|
|
17298
|
-
} = Promise.withResolvers();
|
|
17299
|
-
queues[key] = promise;
|
|
17300
|
-
if (previous) {
|
|
17301
|
-
await previous;
|
|
17302
|
-
}
|
|
17303
|
-
try {
|
|
17304
|
-
return await callback();
|
|
17305
|
-
} finally {
|
|
17306
|
-
resolve();
|
|
17307
|
-
if (queues[key] === promise) {
|
|
17308
|
-
delete queues[key];
|
|
17309
|
-
}
|
|
17310
|
-
}
|
|
17311
|
-
};
|
|
17312
|
-
|
|
17313
|
-
const getTextDocument = editor => {
|
|
17314
|
-
return {
|
|
17315
|
-
documentId: editor.id || editor.uid,
|
|
17316
|
-
languageId: editor.languageId,
|
|
17317
|
-
text: getText$1(editor),
|
|
17318
|
-
uri: editor.uri
|
|
17319
|
-
};
|
|
17320
|
-
};
|
|
17321
|
-
const executeIsolatedDiagnosticProvider = async editor => {
|
|
17322
|
-
const textDocument = getTextDocument(editor);
|
|
17323
|
-
return invoke$8(editor.applicationId, 'Extensions.executeDiagnosticProvider', textDocument);
|
|
17324
|
-
};
|
|
17325
|
-
const executeDiagnosticProvider = async editor => {
|
|
17326
|
-
return executeIsolatedDiagnosticProvider(editor);
|
|
17327
|
-
};
|
|
17328
|
-
|
|
17329
|
-
/**
|
|
17330
|
-
* Merges link decorations with diagnostic decorations
|
|
17331
|
-
* Links should always be present, but we also need to include any diagnostic decorations
|
|
17332
|
-
*/
|
|
17333
|
-
const mergeLinksWithDiagnosticDecorations = (editor, diagnosticDecorations) => {
|
|
17334
|
-
// Get link decorations
|
|
17335
|
-
const linkDecorations = detectAllLinksAsDecorations(editor);
|
|
17336
|
-
|
|
17337
|
-
// Merge with diagnostic decorations
|
|
17338
|
-
const allDecorations = [...linkDecorations, ...diagnosticDecorations];
|
|
17339
|
-
|
|
17340
|
-
// Sort by offset to maintain proper order
|
|
17341
|
-
const sortedDecorations = [];
|
|
17342
|
-
for (let i = 0; i < allDecorations.length; i += 4) {
|
|
17343
|
-
sortedDecorations.push({
|
|
17344
|
-
length: allDecorations[i + 1],
|
|
17345
|
-
modifiers: allDecorations[i + 3],
|
|
17346
|
-
offset: allDecorations[i],
|
|
17347
|
-
type: allDecorations[i + 2]
|
|
17348
|
-
});
|
|
17349
|
-
}
|
|
17350
|
-
sortedDecorations.sort((a, b) => a.offset - b.offset);
|
|
17351
|
-
|
|
17352
|
-
// Flatten back to array format
|
|
17353
|
-
const result = [];
|
|
17354
|
-
for (const dec of sortedDecorations) {
|
|
17355
|
-
result.push(dec.offset, dec.length, dec.type, dec.modifiers);
|
|
17356
|
-
}
|
|
17357
|
-
return result;
|
|
17358
|
-
};
|
|
17359
|
-
|
|
17360
|
-
const getDiagnostics = async editor => {
|
|
17361
|
-
return executeDiagnosticProvider(editor);
|
|
17362
|
-
};
|
|
17363
|
-
const addDiagnostics = async (editor, diagnostics) => {
|
|
17364
|
-
const visualDecorations = await getVisibleDiagnostics(editor, diagnostics);
|
|
17365
|
-
const diagnosticDecorations = visualDecorations.flatMap(decoration => [decoration.offset, decoration.length, decoration.type, decoration.modifiers || 0]);
|
|
17366
|
-
const decorations = mergeLinksWithDiagnosticDecorations(editor, diagnosticDecorations);
|
|
17367
|
-
return {
|
|
17368
|
-
...editor,
|
|
17369
|
-
decorations,
|
|
17370
|
-
diagnostics,
|
|
17371
|
-
lightBulbRowIndex: -1,
|
|
17372
|
-
visualDecorations
|
|
17373
|
-
};
|
|
17374
|
-
};
|
|
17375
|
-
const handleError = async (error, editor) => {
|
|
17376
|
-
if (error instanceof Error && error.message.includes('No diagnostic provider found')) {
|
|
17377
|
-
return editor;
|
|
17378
|
-
}
|
|
17379
|
-
await handleError$1(error, 'Failed to update diagnostics: ');
|
|
17380
|
-
return editor;
|
|
17381
|
-
};
|
|
17382
|
-
const notifyDiagnosticsChange = async (uri, applicationId) => {
|
|
17383
|
-
try {
|
|
17384
|
-
await invoke$9(applicationId, 'Layout.handleDiagnosticsChange', uri);
|
|
17385
|
-
} catch {
|
|
17386
|
-
// Older renderer workers do not support diagnostics change listeners.
|
|
17387
|
-
}
|
|
17388
|
-
};
|
|
17389
|
-
const diagnosticsEqual = (left, right) => {
|
|
17390
|
-
if (left === right) {
|
|
17391
|
-
return true;
|
|
17392
|
-
}
|
|
17393
|
-
if ((left?.length ?? 0) !== right.length) {
|
|
17394
|
-
return false;
|
|
17395
|
-
}
|
|
17396
|
-
return right.every((diagnostic, index) => {
|
|
17397
|
-
const other = left[index];
|
|
17398
|
-
return other.code === diagnostic.code && other.columnIndex === diagnostic.columnIndex && other.endColumnIndex === diagnostic.endColumnIndex && other.endRowIndex === diagnostic.endRowIndex && other.message === diagnostic.message && other.rowIndex === diagnostic.rowIndex && other.source === diagnostic.source && other.type === diagnostic.type && other.uri === diagnostic.uri;
|
|
17399
|
-
});
|
|
17400
|
-
};
|
|
17401
|
-
const diagnosticLayoutEqual = (left, right) => left.charWidth === right.charWidth && left.deltaY === right.deltaY && left.fontFamily === right.fontFamily && left.fontSize === right.fontSize && left.fontWeight === right.fontWeight && left.isMonospaceFont === right.isMonospaceFont && left.itemHeight === right.itemHeight && left.letterSpacing === right.letterSpacing && left.lines === right.lines && left.minLineY === right.minLineY && left.rowHeight === right.rowHeight && left.tabSize === right.tabSize && left.viewLineIndices === right.viewLineIndices && left.width === right.width;
|
|
17402
|
-
const isApplicable = (latest, editor) => latest && latest.newState.diagnosticsEnabled && !latest.newState.loadError && latest.newState.diagnostics === editor.diagnostics && latest.newState.languageId === editor.languageId && latest.newState.lines === editor.lines && latest.newState.uri === editor.uri;
|
|
17403
|
-
const mergeDiagnostics = (editor, editorWithDiagnostics) => ({
|
|
17404
|
-
...editor,
|
|
17405
|
-
decorations: editorWithDiagnostics.decorations,
|
|
17406
|
-
diagnostics: editorWithDiagnostics.diagnostics,
|
|
17407
|
-
lightBulbRowIndex: editorWithDiagnostics.lightBulbRowIndex,
|
|
17408
|
-
visualDecorations: editorWithDiagnostics.visualDecorations
|
|
17409
|
-
});
|
|
17410
|
-
const updateDiagnostics = async editor => {
|
|
17411
|
-
if (!editor.diagnosticsEnabled || editor.loadError) {
|
|
17412
|
-
return editor;
|
|
17413
|
-
}
|
|
17414
|
-
try {
|
|
17415
|
-
const diagnostics = await getDiagnostics(editor);
|
|
17416
|
-
return (await enqueue(editor.id, async () => {
|
|
17417
|
-
let latest = get$8(editor.id);
|
|
17418
|
-
if (!isApplicable(latest, editor)) {
|
|
17419
|
-
return editor;
|
|
17420
|
-
}
|
|
17421
|
-
if (diagnosticsEqual(latest.newState.diagnostics, diagnostics)) {
|
|
17422
|
-
return latest.newState;
|
|
17423
|
-
}
|
|
17424
|
-
let calculationState = latest.newState;
|
|
17425
|
-
let editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
17426
|
-
latest = get$8(editor.id);
|
|
17427
|
-
while (isApplicable(latest, editor) && !diagnosticLayoutEqual(calculationState, latest.newState)) {
|
|
17428
|
-
calculationState = latest.newState;
|
|
17429
|
-
editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
|
|
17430
|
-
latest = get$8(editor.id);
|
|
17431
|
-
}
|
|
17432
|
-
if (!isApplicable(latest, editor)) {
|
|
17433
|
-
return editor;
|
|
17434
|
-
}
|
|
17435
|
-
if (diagnosticsEqual(latest.newState.diagnostics, diagnostics)) {
|
|
17436
|
-
return latest.newState;
|
|
17437
|
-
}
|
|
17438
|
-
const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
|
|
17439
|
-
set$8(editor.id, latest.oldState, newEditor);
|
|
17440
|
-
await invoke$5('Editor.renderPending', newEditor.id);
|
|
17441
|
-
await notifyDiagnosticsChange(newEditor.uri, newEditor.applicationId);
|
|
17442
|
-
return newEditor;
|
|
17443
|
-
})) ?? editor;
|
|
17444
|
-
} catch (error) {
|
|
17445
|
-
return handleError(error, editor);
|
|
17446
|
-
}
|
|
17447
|
-
};
|
|
17448
|
-
const requestDiagnostics = editor => {
|
|
17449
|
-
void updateDiagnostics(editor);
|
|
17450
|
-
return editor;
|
|
17451
|
-
};
|
|
17452
|
-
const updateDiagnosticsAll = async () => {
|
|
17453
|
-
for (const key of getKeys$2()) {
|
|
17454
|
-
const editor = get$8(Number(key))?.newState;
|
|
17455
|
-
if (editor) {
|
|
17456
|
-
await updateDiagnostics(editor);
|
|
17457
|
-
}
|
|
17458
|
-
}
|
|
17459
|
-
};
|
|
17460
|
-
|
|
17461
17577
|
const editorDiagnosticEffect = {
|
|
17462
17578
|
// TODO set effects delay / diagnostic delay
|
|
17463
17579
|
apply(editor) {
|
|
@@ -17694,7 +17810,7 @@ const commandMap = {
|
|
|
17694
17810
|
'Editor.fold': wrapCommand(fold$1),
|
|
17695
17811
|
'Editor.format': wrapCommand(format),
|
|
17696
17812
|
'Editor.getCommandIds': getCommandIds,
|
|
17697
|
-
'Editor.getDiagnostics': getDiagnostics
|
|
17813
|
+
'Editor.getDiagnostics': getDiagnostics,
|
|
17698
17814
|
'Editor.getKeyBindings': getKeyBindings,
|
|
17699
17815
|
'Editor.getKeys': getKeys,
|
|
17700
17816
|
'Editor.getLanguageId': getLanguageId,
|