@lvce-editor/editor-worker 12.1.0 → 12.3.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 +32 -23
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -3420,7 +3420,7 @@ const getVisibleDiagnostics = (editor, diagnostics) => {
|
|
|
3420
3420
|
const endLineDifference = 0;
|
|
3421
3421
|
const halfCursorWidth = 0;
|
|
3422
3422
|
const x = getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
|
|
3423
|
-
const y = getY(rowIndex, minLineY, rowHeight);
|
|
3423
|
+
const y = getY(rowIndex, minLineY, rowHeight) - rowHeight;
|
|
3424
3424
|
visibleDiagnostics.push({
|
|
3425
3425
|
x,
|
|
3426
3426
|
y,
|
|
@@ -3464,9 +3464,10 @@ const updateDiagnostics = async newState => {
|
|
|
3464
3464
|
} catch (error) {
|
|
3465
3465
|
// @ts-ignore
|
|
3466
3466
|
if (error && error.message.includes('No diagnostic provider found')) {
|
|
3467
|
-
return;
|
|
3467
|
+
return newState;
|
|
3468
3468
|
}
|
|
3469
3469
|
console.error(`Failed to update diagnostics: ${error}`);
|
|
3470
|
+
return newState;
|
|
3470
3471
|
}
|
|
3471
3472
|
};
|
|
3472
3473
|
|
|
@@ -3622,8 +3623,10 @@ const createEditor = async ({
|
|
|
3622
3623
|
// e.g. it might not always be necessary to send text to extension host worker
|
|
3623
3624
|
// @ts-ignore
|
|
3624
3625
|
await invoke$6(TextDocumentSyncFull, uri, id, languageId, content);
|
|
3626
|
+
|
|
3627
|
+
// TODO await promise
|
|
3625
3628
|
if (diagnosticsEnabled) {
|
|
3626
|
-
updateDiagnostics(newEditor4);
|
|
3629
|
+
await updateDiagnostics(newEditor4);
|
|
3627
3630
|
}
|
|
3628
3631
|
};
|
|
3629
3632
|
|
|
@@ -7823,7 +7826,21 @@ const tabCompletion = async editor => {
|
|
|
7823
7826
|
}
|
|
7824
7827
|
};
|
|
7825
7828
|
|
|
7826
|
-
const getBlockComment = async editor => {
|
|
7829
|
+
const getBlockComment = async (editor, offset) => {
|
|
7830
|
+
// TODO ask extension host worker,
|
|
7831
|
+
// execute block comment provider with
|
|
7832
|
+
// uri, language id, offset
|
|
7833
|
+
// and the extension returns a matching block comment or undefined
|
|
7834
|
+
try {
|
|
7835
|
+
await activateByEvent(`onLanguage:${editor.languageId}`);
|
|
7836
|
+
// @ts-ignore
|
|
7837
|
+
const blockComment = await invoke$6(`ExtensionHostCommment.execute`, editor.uid, offset);
|
|
7838
|
+
if (blockComment) {
|
|
7839
|
+
return blockComment;
|
|
7840
|
+
}
|
|
7841
|
+
} catch {
|
|
7842
|
+
// ignore
|
|
7843
|
+
}
|
|
7827
7844
|
const languageConfiguration = await getLanguageConfiguration(editor);
|
|
7828
7845
|
if (!languageConfiguration?.comments?.blockComment) {
|
|
7829
7846
|
return undefined;
|
|
@@ -8018,7 +8035,8 @@ const getBlockCommentEdits = (editor, blockComment) => {
|
|
|
8018
8035
|
};
|
|
8019
8036
|
|
|
8020
8037
|
const toggleBlockComment = async editor => {
|
|
8021
|
-
const
|
|
8038
|
+
const offset = getOffsetAtCursor$1(editor);
|
|
8039
|
+
const blockComment = await getBlockComment(editor, offset);
|
|
8022
8040
|
if (!blockComment) {
|
|
8023
8041
|
return editor;
|
|
8024
8042
|
}
|
|
@@ -9352,6 +9370,13 @@ const getSourceActions = async editorUid => {
|
|
|
9352
9370
|
const actions = await getEditorSourceActions(editorUid);
|
|
9353
9371
|
return actions;
|
|
9354
9372
|
};
|
|
9373
|
+
const getDiagnostics$1 = async editorUid => {
|
|
9374
|
+
const editor = getEditor(editorUid);
|
|
9375
|
+
const {
|
|
9376
|
+
diagnostics
|
|
9377
|
+
} = editor;
|
|
9378
|
+
return diagnostics;
|
|
9379
|
+
};
|
|
9355
9380
|
|
|
9356
9381
|
const pending = Object.create(null);
|
|
9357
9382
|
const loaded = Object.create(null);
|
|
@@ -10546,18 +10571,7 @@ const updateDebugInfo = async debugId => {
|
|
|
10546
10571
|
await invoke$9('Editor.rerender', key);
|
|
10547
10572
|
};
|
|
10548
10573
|
|
|
10549
|
-
const
|
|
10550
|
-
isActive(oldEditor, newEditor) {
|
|
10551
|
-
// TODO avoid slow comparison
|
|
10552
|
-
return newEditor.diagnosticsEnabled && JSON.stringify(oldEditor.lines) !== JSON.stringify(newEditor.lines);
|
|
10553
|
-
},
|
|
10554
|
-
// TODO set effects delay / diagnostic delay
|
|
10555
|
-
async apply(editor) {
|
|
10556
|
-
await updateDiagnostics(editor);
|
|
10557
|
-
}
|
|
10558
|
-
};
|
|
10559
|
-
|
|
10560
|
-
const keep = ['ActivateByEvent.activateByEvent', 'ExtensionHostManagement.activateByEvent', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.create', 'Editor.getKeyBindings', 'Editor.getSourceActions', 'Editor.getLines2', 'Editor.getPositionAtCursor', 'Editor.getOffsetAtCursor', 'Editor.getQuickPickMenuEntries', 'Editor.getSelections', 'Editor.hotReload', 'Editor.getSelections2', 'Editor.getText', 'Editor.getWordAt', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getUri', 'Editor.getWordBefore', 'Editor.getWordBefore2', 'Editor.offsetAt', 'Editor.render', 'Editor.setSelections2', 'Editor.updateDebugInfo', 'Editor.getLanguageId', 'Editor.getProblems', 'Editor.getKeys', 'Font.ensure', 'HandleMessagePort.handleMessagePort', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker'
|
|
10574
|
+
const keep = ['ActivateByEvent.activateByEvent', 'ExtensionHostManagement.activateByEvent', 'Editor.applyEdit2', 'Editor.applyEdits2', 'Editor.closeFind2', 'Editor.closeWidget2', 'Editor.create', 'Editor.getKeyBindings', 'Editor.getSourceActions', 'Editor.getLines2', 'Editor.getPositionAtCursor', 'Editor.getOffsetAtCursor', 'Editor.getQuickPickMenuEntries', 'Editor.getSelections', 'Editor.hotReload', 'Editor.getSelections2', 'Editor.getDiagnostics', 'Editor.getText', 'Editor.getWordAt', 'Editor.getWordAt2', 'Editor.getWordAtOffset2', 'Editor.getUri', 'Editor.getWordBefore', 'Editor.getWordBefore2', 'Editor.offsetAt', 'Editor.render', 'Editor.setSelections2', 'Editor.updateDebugInfo', 'Editor.getLanguageId', 'Editor.getProblems', 'Editor.getKeys', 'Font.ensure', 'HandleMessagePort.handleMessagePort', 'Hover.getHoverInfo', 'Hover.handleSashPointerDown', 'Hover.handleSashPointerMove', 'Hover.handleSashPointerUp', 'Hover.loadContent', 'Hover.render', 'Initialize.initialize', 'SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker'
|
|
10561
10575
|
// 'ColorPicker.handleSliderPointerDown',
|
|
10562
10576
|
// 'ColorPicker.handleSliderPointerMove',
|
|
10563
10577
|
// 'ColorPicker.loadContent',
|
|
@@ -10587,7 +10601,6 @@ const widgetCommands = {
|
|
|
10587
10601
|
// TODO wrap commands globally, not per editor
|
|
10588
10602
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
10589
10603
|
|
|
10590
|
-
const effects = [editorDiagnosticEffect];
|
|
10591
10604
|
const wrapCommand = fn => async (editorUid, ...args) => {
|
|
10592
10605
|
const oldInstance = get$4(editorUid);
|
|
10593
10606
|
const state = oldInstance.newState;
|
|
@@ -10595,11 +10608,6 @@ const wrapCommand = fn => async (editorUid, ...args) => {
|
|
|
10595
10608
|
if (state === newEditor) {
|
|
10596
10609
|
return newEditor;
|
|
10597
10610
|
}
|
|
10598
|
-
for (const effect of effects) {
|
|
10599
|
-
if (effect.isActive(oldInstance.newState, newEditor)) {
|
|
10600
|
-
effect.apply(newEditor);
|
|
10601
|
-
}
|
|
10602
|
-
}
|
|
10603
10611
|
// TODO if editor did not change, no need to update furthur
|
|
10604
10612
|
|
|
10605
10613
|
// TODO combine neweditor with latest editor?
|
|
@@ -10690,6 +10698,7 @@ const commandMap = {
|
|
|
10690
10698
|
'Editor.getQuickPickMenuEntries': getQuickPickMenuEntries,
|
|
10691
10699
|
'Editor.getSelections': getSelections,
|
|
10692
10700
|
'Editor.getSelections2': getSelections2,
|
|
10701
|
+
'Editor.getDiagnostics': getDiagnostics$1,
|
|
10693
10702
|
'Editor.getText': getText,
|
|
10694
10703
|
'Editor.getUri': getUri,
|
|
10695
10704
|
'Editor.getWordAt': getWordAt$1,
|