@lvce-editor/editor-worker 5.1.0 → 5.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 +261 -140
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -18,6 +18,11 @@ const execute$1 = (command, ...args) => {
|
|
|
18
18
|
return fn(...args);
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
+
const codeGeneratorAccept = state => {
|
|
22
|
+
// TODO close code generator widget
|
|
23
|
+
return state;
|
|
24
|
+
};
|
|
25
|
+
|
|
21
26
|
let AssertionError$1 = class AssertionError extends Error {
|
|
22
27
|
constructor(message) {
|
|
23
28
|
super(message);
|
|
@@ -1034,6 +1039,13 @@ const set$6 = (id, oldEditor, newEditor) => {
|
|
|
1034
1039
|
};
|
|
1035
1040
|
};
|
|
1036
1041
|
|
|
1042
|
+
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
1043
|
+
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
1044
|
+
const HoverExecute = 'ExtensionHostHover.execute';
|
|
1045
|
+
const RenameExecuteRename = 'ExtensionHostRename.executeRenameProvider';
|
|
1046
|
+
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
1047
|
+
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
1048
|
+
|
|
1037
1049
|
const Two = '2.0';
|
|
1038
1050
|
class AssertionError extends Error {
|
|
1039
1051
|
constructor(message) {
|
|
@@ -1718,13 +1730,6 @@ const {
|
|
|
1718
1730
|
invoke: invoke$2
|
|
1719
1731
|
} = createRpc(ExtensionHostWorker);
|
|
1720
1732
|
|
|
1721
|
-
const CompletionExecute = 'ExtensionHostCompletion.execute';
|
|
1722
|
-
const CompletionResolveExecute = 'ExtensionHostCompletion.executeResolve';
|
|
1723
|
-
const HoverExecute = 'ExtensionHostHover.execute';
|
|
1724
|
-
const RenameExecuteRename = 'ExtensionHostRename.executeRenameProvider';
|
|
1725
|
-
const TabCompletionExecuteTabCompletionProvider = 'ExtensionHost.executeTabCompletionProvider';
|
|
1726
|
-
const TextDocumentSyncFull = 'ExtensionHostTextDocument.syncFull';
|
|
1727
|
-
|
|
1728
1733
|
const ColorPicker$2 = 41;
|
|
1729
1734
|
const CompletionDetail$1 = 999;
|
|
1730
1735
|
const EditorCompletion = 9;
|
|
@@ -1746,6 +1751,123 @@ const measureCharacterWidth = (fontWeight, fontSize, fontFamily, letterSpacing)
|
|
|
1746
1751
|
return measureTextWidth('a', fontWeight, fontSize, fontFamily, letterSpacing, false, 0);
|
|
1747
1752
|
};
|
|
1748
1753
|
|
|
1754
|
+
const OnRename = 'onRename';
|
|
1755
|
+
const OnCompletion = 'onCompletion';
|
|
1756
|
+
const OnDiagnostic = 'onDiagnostic';
|
|
1757
|
+
const OnHover = 'onHover';
|
|
1758
|
+
const OnTabCompletion = 'onTabCompletion';
|
|
1759
|
+
|
|
1760
|
+
// TODO add tests for this
|
|
1761
|
+
const activateByEvent = async event => {
|
|
1762
|
+
await invoke$3('ExtensionHostManagement.activateByEvent', event);
|
|
1763
|
+
};
|
|
1764
|
+
|
|
1765
|
+
const execute = async ({
|
|
1766
|
+
editor,
|
|
1767
|
+
args,
|
|
1768
|
+
event,
|
|
1769
|
+
method,
|
|
1770
|
+
noProviderFoundMessage,
|
|
1771
|
+
noProviderFoundResult = undefined
|
|
1772
|
+
}) => {
|
|
1773
|
+
const fullEvent = `${event}:${editor.languageId}`;
|
|
1774
|
+
await activateByEvent(fullEvent);
|
|
1775
|
+
const result = await invoke$2(method, editor.uid, ...args);
|
|
1776
|
+
return result;
|
|
1777
|
+
};
|
|
1778
|
+
|
|
1779
|
+
const combineResults$3 = results => {
|
|
1780
|
+
return results[0];
|
|
1781
|
+
};
|
|
1782
|
+
const executeDiagnosticProvider = editor => {
|
|
1783
|
+
return execute({
|
|
1784
|
+
editor,
|
|
1785
|
+
event: OnDiagnostic,
|
|
1786
|
+
method: 'ExtensionHost.executeDiagnosticProvider',
|
|
1787
|
+
args: [],
|
|
1788
|
+
noProviderFoundMessage: 'no diagnostic provider found',
|
|
1789
|
+
noProviderResult: [],
|
|
1790
|
+
combineResults: combineResults$3
|
|
1791
|
+
});
|
|
1792
|
+
};
|
|
1793
|
+
|
|
1794
|
+
const getDiagnosticType = diagnostic => {
|
|
1795
|
+
return diagnostic.type;
|
|
1796
|
+
};
|
|
1797
|
+
|
|
1798
|
+
const getVisibleDiagnostics = (editor, diagnostics) => {
|
|
1799
|
+
const visibleDiagnostics = [];
|
|
1800
|
+
const {
|
|
1801
|
+
width,
|
|
1802
|
+
rowHeight,
|
|
1803
|
+
minLineY,
|
|
1804
|
+
charWidth,
|
|
1805
|
+
letterSpacing,
|
|
1806
|
+
lines,
|
|
1807
|
+
fontWeight,
|
|
1808
|
+
fontSize,
|
|
1809
|
+
fontFamily,
|
|
1810
|
+
isMonospaceFont,
|
|
1811
|
+
tabSize
|
|
1812
|
+
} = editor;
|
|
1813
|
+
for (const diagnostic of diagnostics) {
|
|
1814
|
+
const {
|
|
1815
|
+
rowIndex,
|
|
1816
|
+
columnIndex,
|
|
1817
|
+
endColumnIndex
|
|
1818
|
+
} = diagnostic;
|
|
1819
|
+
const columnDelta = endColumnIndex - columnIndex;
|
|
1820
|
+
const diagnosticWidth = columnDelta * charWidth;
|
|
1821
|
+
const endLineDifference = 0;
|
|
1822
|
+
const halfCursorWidth = 0;
|
|
1823
|
+
const x = getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
|
|
1824
|
+
const y = getY(rowIndex, minLineY, rowHeight);
|
|
1825
|
+
visibleDiagnostics.push({
|
|
1826
|
+
x,
|
|
1827
|
+
y,
|
|
1828
|
+
width: diagnosticWidth,
|
|
1829
|
+
height: rowHeight,
|
|
1830
|
+
type: getDiagnosticType(diagnostic)
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
return visibleDiagnostics;
|
|
1834
|
+
};
|
|
1835
|
+
|
|
1836
|
+
const updateDiagnostics = async uid => {
|
|
1837
|
+
try {
|
|
1838
|
+
// TODO handle error
|
|
1839
|
+
// TODO handle race condition
|
|
1840
|
+
const {
|
|
1841
|
+
newState
|
|
1842
|
+
} = get$6(uid);
|
|
1843
|
+
|
|
1844
|
+
// TODO sync textdocument incrementally
|
|
1845
|
+
// TODO sync and ask for diagnostics at the same time?
|
|
1846
|
+
// TODO throttle diagnostics
|
|
1847
|
+
const content = getText$1(newState);
|
|
1848
|
+
await invoke$2(TextDocumentSyncFull, newState.uri, newState.id, newState.languageId, content);
|
|
1849
|
+
const diagnostics = await executeDiagnosticProvider(newState);
|
|
1850
|
+
const latest = get$6(uid);
|
|
1851
|
+
if (!latest) {
|
|
1852
|
+
return;
|
|
1853
|
+
}
|
|
1854
|
+
const decorations = getVisibleDiagnostics(latest.newState, diagnostics);
|
|
1855
|
+
const newEditor = {
|
|
1856
|
+
...latest.newState,
|
|
1857
|
+
diagnostics,
|
|
1858
|
+
decorations
|
|
1859
|
+
};
|
|
1860
|
+
set$6(uid, latest.oldState, newEditor);
|
|
1861
|
+
await invoke$3('Editor.rerender', uid);
|
|
1862
|
+
} catch (error) {
|
|
1863
|
+
// @ts-ignore
|
|
1864
|
+
if (error && error.message.includes('No diagnostic provider found')) {
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
console.error(`Failed to update diagnostics: ${error}`);
|
|
1868
|
+
}
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1749
1871
|
const emptyEditor = {
|
|
1750
1872
|
uri: '',
|
|
1751
1873
|
languageId: '',
|
|
@@ -1796,7 +1918,8 @@ const createEditor = async ({
|
|
|
1796
1918
|
fontWeight,
|
|
1797
1919
|
fontFamily,
|
|
1798
1920
|
isMonospaceFont,
|
|
1799
|
-
uri
|
|
1921
|
+
uri,
|
|
1922
|
+
diagnosticsEnabled
|
|
1800
1923
|
}) => {
|
|
1801
1924
|
number$1(id);
|
|
1802
1925
|
string(content);
|
|
@@ -1856,7 +1979,8 @@ const createEditor = async ({
|
|
|
1856
1979
|
uid: id,
|
|
1857
1980
|
id,
|
|
1858
1981
|
widgets: [],
|
|
1859
|
-
focusKey: Empty
|
|
1982
|
+
focusKey: Empty,
|
|
1983
|
+
diagnosticsEnabled
|
|
1860
1984
|
};
|
|
1861
1985
|
// TODO avoid creating intermediate editors here
|
|
1862
1986
|
const newEditor1 = setBounds(editor, x, y, width, height, 9);
|
|
@@ -1868,6 +1992,9 @@ const createEditor = async ({
|
|
|
1868
1992
|
};
|
|
1869
1993
|
set$6(id, emptyEditor, newEditor4);
|
|
1870
1994
|
await invoke$2(TextDocumentSyncFull, uri, id, languageId, content);
|
|
1995
|
+
if (diagnosticsEnabled) {
|
|
1996
|
+
updateDiagnostics(editor.uid);
|
|
1997
|
+
}
|
|
1871
1998
|
};
|
|
1872
1999
|
|
|
1873
2000
|
// @ts-ignore
|
|
@@ -2260,6 +2387,16 @@ const cancelSelection = editor => {
|
|
|
2260
2387
|
return scheduleSelections(editor, newSelections);
|
|
2261
2388
|
};
|
|
2262
2389
|
|
|
2390
|
+
// TODO use numeric widget id
|
|
2391
|
+
const CodeGenerator = 1;
|
|
2392
|
+
const ColorPicker$1 = 2;
|
|
2393
|
+
const Completion = 3;
|
|
2394
|
+
const CompletionDetail = 4;
|
|
2395
|
+
const Find = 5;
|
|
2396
|
+
const Hover = 6;
|
|
2397
|
+
const Rename = 7;
|
|
2398
|
+
const SourceAction = 8;
|
|
2399
|
+
|
|
2263
2400
|
const getIndex = (widgets, id) => {
|
|
2264
2401
|
for (const [i, widget] of widgets.entries()) {
|
|
2265
2402
|
if (widget.id === id) {
|
|
@@ -2274,15 +2411,24 @@ const removeEditorWidget = (widgets, id) => {
|
|
|
2274
2411
|
return newWidgets;
|
|
2275
2412
|
};
|
|
2276
2413
|
|
|
2277
|
-
|
|
2278
|
-
|
|
2279
|
-
|
|
2280
|
-
const
|
|
2281
|
-
const
|
|
2282
|
-
|
|
2283
|
-
|
|
2284
|
-
const
|
|
2285
|
-
|
|
2414
|
+
const isMatchingWidget$2 = widget => {
|
|
2415
|
+
return widget.id === CodeGenerator;
|
|
2416
|
+
};
|
|
2417
|
+
const closeCodeGenerator = editor => {
|
|
2418
|
+
const {
|
|
2419
|
+
widgets
|
|
2420
|
+
} = editor;
|
|
2421
|
+
const index = widgets.findIndex(isMatchingWidget$2);
|
|
2422
|
+
if (index === -1) {
|
|
2423
|
+
return editor;
|
|
2424
|
+
}
|
|
2425
|
+
const newWidgets = removeEditorWidget(widgets, CodeGenerator);
|
|
2426
|
+
return {
|
|
2427
|
+
...editor,
|
|
2428
|
+
widgets: newWidgets,
|
|
2429
|
+
focused: true
|
|
2430
|
+
};
|
|
2431
|
+
};
|
|
2286
2432
|
|
|
2287
2433
|
const isCompletionWidget = widget => {
|
|
2288
2434
|
return widget.id === Completion;
|
|
@@ -2302,14 +2448,14 @@ const closeCompletion = editor => {
|
|
|
2302
2448
|
};
|
|
2303
2449
|
};
|
|
2304
2450
|
|
|
2305
|
-
const isMatchingWidget$
|
|
2451
|
+
const isMatchingWidget$1 = widget => {
|
|
2306
2452
|
return widget.id === Find;
|
|
2307
2453
|
};
|
|
2308
2454
|
const closeFind = editor => {
|
|
2309
2455
|
const {
|
|
2310
2456
|
widgets
|
|
2311
2457
|
} = editor;
|
|
2312
|
-
const index = widgets.findIndex(isMatchingWidget$
|
|
2458
|
+
const index = widgets.findIndex(isMatchingWidget$1);
|
|
2313
2459
|
if (index === -1) {
|
|
2314
2460
|
return editor;
|
|
2315
2461
|
}
|
|
@@ -2341,14 +2487,14 @@ const closeRename = editor => {
|
|
|
2341
2487
|
};
|
|
2342
2488
|
};
|
|
2343
2489
|
|
|
2344
|
-
const isMatchingWidget
|
|
2490
|
+
const isMatchingWidget = widget => {
|
|
2345
2491
|
return widget.id === SourceAction;
|
|
2346
2492
|
};
|
|
2347
2493
|
const closeSourceAction = editor => {
|
|
2348
2494
|
const {
|
|
2349
2495
|
widgets
|
|
2350
2496
|
} = editor;
|
|
2351
|
-
const index = widgets.findIndex(isMatchingWidget
|
|
2497
|
+
const index = widgets.findIndex(isMatchingWidget);
|
|
2352
2498
|
if (index === -1) {
|
|
2353
2499
|
return editor;
|
|
2354
2500
|
}
|
|
@@ -2841,7 +2987,6 @@ const wordPartRight = (line, columnIndex) => {
|
|
|
2841
2987
|
return tryRegexArray(partialLine, ARRAY_PARTIAL_WORD_RIGHT_2);
|
|
2842
2988
|
};
|
|
2843
2989
|
|
|
2844
|
-
// @ts-ignore
|
|
2845
2990
|
const cursorCharacterLeft = editor => {
|
|
2846
2991
|
return editorCursorHorizontalLeft(editor, characterLeft);
|
|
2847
2992
|
};
|
|
@@ -3186,25 +3331,6 @@ const findAllReferences = async editor => {
|
|
|
3186
3331
|
return editor;
|
|
3187
3332
|
};
|
|
3188
3333
|
|
|
3189
|
-
// TODO add tests for this
|
|
3190
|
-
const activateByEvent = async event => {
|
|
3191
|
-
await invoke$3('ExtensionHostManagement.activateByEvent', event);
|
|
3192
|
-
};
|
|
3193
|
-
|
|
3194
|
-
const execute = async ({
|
|
3195
|
-
editor,
|
|
3196
|
-
args,
|
|
3197
|
-
event,
|
|
3198
|
-
method,
|
|
3199
|
-
noProviderFoundMessage,
|
|
3200
|
-
noProviderFoundResult = undefined
|
|
3201
|
-
}) => {
|
|
3202
|
-
const fullEvent = `${event}:${editor.languageId}`;
|
|
3203
|
-
await activateByEvent(fullEvent);
|
|
3204
|
-
const result = await invoke$2(method, editor.uid, ...args);
|
|
3205
|
-
return result;
|
|
3206
|
-
};
|
|
3207
|
-
|
|
3208
3334
|
const getFormattingEdits = async editor => {
|
|
3209
3335
|
const edits = await execute({
|
|
3210
3336
|
editor,
|
|
@@ -4521,7 +4647,54 @@ const moveSelectionPx = (editor, x, y) => {
|
|
|
4521
4647
|
return editorMoveSelection(editor, position);
|
|
4522
4648
|
};
|
|
4523
4649
|
|
|
4650
|
+
const User = 1;
|
|
4651
|
+
const Script = 2;
|
|
4652
|
+
const Unknown$1 = 0;
|
|
4653
|
+
|
|
4524
4654
|
const create$6 = () => {
|
|
4655
|
+
const completionUid = create$8();
|
|
4656
|
+
const widget = {
|
|
4657
|
+
id: CodeGenerator,
|
|
4658
|
+
oldState: {
|
|
4659
|
+
uid: completionUid,
|
|
4660
|
+
questions: [],
|
|
4661
|
+
x: 0,
|
|
4662
|
+
y: 0,
|
|
4663
|
+
width: 0,
|
|
4664
|
+
height: 0,
|
|
4665
|
+
focused: false,
|
|
4666
|
+
focusSource: Unknown$1
|
|
4667
|
+
},
|
|
4668
|
+
newState: {
|
|
4669
|
+
uid: completionUid,
|
|
4670
|
+
questions: [],
|
|
4671
|
+
x: 0,
|
|
4672
|
+
y: 0,
|
|
4673
|
+
width: 0,
|
|
4674
|
+
height: 0,
|
|
4675
|
+
focused: true,
|
|
4676
|
+
focusSource: Script
|
|
4677
|
+
}
|
|
4678
|
+
};
|
|
4679
|
+
return widget;
|
|
4680
|
+
};
|
|
4681
|
+
|
|
4682
|
+
const newStateGenerator$1 = async state => {
|
|
4683
|
+
const latestState = {
|
|
4684
|
+
...state,
|
|
4685
|
+
x: 100,
|
|
4686
|
+
y: 100,
|
|
4687
|
+
width: 150,
|
|
4688
|
+
height: 45
|
|
4689
|
+
};
|
|
4690
|
+
return latestState;
|
|
4691
|
+
};
|
|
4692
|
+
const openCodeGenerator = async editor => {
|
|
4693
|
+
const fullFocus = true;
|
|
4694
|
+
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create$6, newStateGenerator$1, fullFocus);
|
|
4695
|
+
};
|
|
4696
|
+
|
|
4697
|
+
const create$5 = () => {
|
|
4525
4698
|
const completionUid = create$8();
|
|
4526
4699
|
const completionWidget = {
|
|
4527
4700
|
id: Completion,
|
|
@@ -4563,11 +4736,6 @@ const create$6 = () => {
|
|
|
4563
4736
|
return completionWidget;
|
|
4564
4737
|
};
|
|
4565
4738
|
|
|
4566
|
-
const OnRename = 'onRename';
|
|
4567
|
-
const OnCompletion = 'onCompletion';
|
|
4568
|
-
const OnHover = 'onHover';
|
|
4569
|
-
const OnTabCompletion = 'onTabCompletion';
|
|
4570
|
-
|
|
4571
4739
|
const combineResults$2 = results => {
|
|
4572
4740
|
return results[0] ?? [];
|
|
4573
4741
|
};
|
|
@@ -5018,7 +5186,7 @@ const openCompletion = async editor => {
|
|
|
5018
5186
|
if (hasWidget(widgets, Completion)) {
|
|
5019
5187
|
return editor;
|
|
5020
5188
|
}
|
|
5021
|
-
const completionWidget = create$
|
|
5189
|
+
const completionWidget = create$5();
|
|
5022
5190
|
const newWidgets = [...widgets, completionWidget];
|
|
5023
5191
|
const newEditor = {
|
|
5024
5192
|
...editor,
|
|
@@ -5043,11 +5211,7 @@ const openCompletion = async editor => {
|
|
|
5043
5211
|
};
|
|
5044
5212
|
};
|
|
5045
5213
|
|
|
5046
|
-
const
|
|
5047
|
-
const Script = 2;
|
|
5048
|
-
const Unknown$1 = 0;
|
|
5049
|
-
|
|
5050
|
-
const create$5 = () => {
|
|
5214
|
+
const create$4 = () => {
|
|
5051
5215
|
const uid = create$8();
|
|
5052
5216
|
const widget = {
|
|
5053
5217
|
id: Find,
|
|
@@ -5453,7 +5617,7 @@ const openFind2 = async editor => {
|
|
|
5453
5617
|
return latestState;
|
|
5454
5618
|
};
|
|
5455
5619
|
const fullFocus = true;
|
|
5456
|
-
return addWidgetToEditor(Find, FindWidget, editor, create$
|
|
5620
|
+
return addWidgetToEditor(Find, FindWidget, editor, create$4, newStateGenerator, fullFocus);
|
|
5457
5621
|
};
|
|
5458
5622
|
|
|
5459
5623
|
const openFind = async state => {
|
|
@@ -5475,7 +5639,7 @@ const getRenamePosition = editor => {
|
|
|
5475
5639
|
};
|
|
5476
5640
|
};
|
|
5477
5641
|
|
|
5478
|
-
const create$
|
|
5642
|
+
const create$3 = () => {
|
|
5479
5643
|
const completionUid = create$8();
|
|
5480
5644
|
const renameWidget = {
|
|
5481
5645
|
id: Rename,
|
|
@@ -5536,7 +5700,7 @@ const openRename = async editor => {
|
|
|
5536
5700
|
return latestState;
|
|
5537
5701
|
};
|
|
5538
5702
|
const fullFocus = true;
|
|
5539
|
-
return addWidgetToEditor(Rename, FocusEditorRename, editor, create$
|
|
5703
|
+
return addWidgetToEditor(Rename, FocusEditorRename, editor, create$3, newStateGenerator, fullFocus);
|
|
5540
5704
|
};
|
|
5541
5705
|
|
|
5542
5706
|
const getOrganizeImportEdits = async editor => {
|
|
@@ -6432,7 +6596,7 @@ const showHover = async state => {
|
|
|
6432
6596
|
return state;
|
|
6433
6597
|
};
|
|
6434
6598
|
|
|
6435
|
-
const create$
|
|
6599
|
+
const create$2 = () => {
|
|
6436
6600
|
const uid = create$8();
|
|
6437
6601
|
const widget = {
|
|
6438
6602
|
id: Hover,
|
|
@@ -6698,11 +6862,11 @@ const loadHoverContent = async state => {
|
|
|
6698
6862
|
};
|
|
6699
6863
|
};
|
|
6700
6864
|
|
|
6701
|
-
const newStateGenerator
|
|
6865
|
+
const newStateGenerator = async state => {
|
|
6702
6866
|
return loadHoverContent(state);
|
|
6703
6867
|
};
|
|
6704
6868
|
const showHover2 = async editor => {
|
|
6705
|
-
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$
|
|
6869
|
+
return addWidgetToEditor(Hover, FocusEditorHover, editor, create$2, newStateGenerator);
|
|
6706
6870
|
};
|
|
6707
6871
|
|
|
6708
6872
|
// TODO ask extension host worker instead
|
|
@@ -6755,7 +6919,7 @@ const loadSourceActions = async (editor, state) => {
|
|
|
6755
6919
|
};
|
|
6756
6920
|
};
|
|
6757
6921
|
|
|
6758
|
-
const create$
|
|
6922
|
+
const create$1 = () => {
|
|
6759
6923
|
const completionUid = create$8();
|
|
6760
6924
|
const widget = {
|
|
6761
6925
|
id: SourceAction,
|
|
@@ -6787,7 +6951,7 @@ const showSourceActions = async editor => {
|
|
|
6787
6951
|
const newStateGenerator = async state => {
|
|
6788
6952
|
return loadSourceActions(editor, state);
|
|
6789
6953
|
};
|
|
6790
|
-
return addWidgetToEditor(SourceAction, SourceActions, editor, create$
|
|
6954
|
+
return addWidgetToEditor(SourceAction, SourceActions, editor, create$1, newStateGenerator);
|
|
6791
6955
|
};
|
|
6792
6956
|
|
|
6793
6957
|
const compareString = (a, b) => {
|
|
@@ -7666,7 +7830,7 @@ const handelWheel = (state, deltaMode, deltaY) => {
|
|
|
7666
7830
|
return newState;
|
|
7667
7831
|
};
|
|
7668
7832
|
|
|
7669
|
-
const create
|
|
7833
|
+
const create = () => {
|
|
7670
7834
|
const completionUid = create$8();
|
|
7671
7835
|
const completionWidget = {
|
|
7672
7836
|
id: CompletionDetail,
|
|
@@ -7720,7 +7884,7 @@ const openDetails = editor => {
|
|
|
7720
7884
|
};
|
|
7721
7885
|
return newestState;
|
|
7722
7886
|
};
|
|
7723
|
-
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create
|
|
7887
|
+
return addWidgetToEditor(CompletionDetail, CompletionDetail$1, editor, create, newStateGenerator);
|
|
7724
7888
|
};
|
|
7725
7889
|
|
|
7726
7890
|
const getEdits = async (editor, completionItem) => {
|
|
@@ -7859,6 +8023,8 @@ const ColorPickerDark = 'ColorPickerDark';
|
|
|
7859
8023
|
const ColorPickerLight = 'ColorPickerLight';
|
|
7860
8024
|
const ColorPickerRectangle = 'ColorPickerRectangle';
|
|
7861
8025
|
const ColorPickerSlider = 'ColorPickerSlider';
|
|
8026
|
+
const DiagnosticError = 'DiagnosticError';
|
|
8027
|
+
const DiagnosticWarning = 'DiagnosticWarning';
|
|
7862
8028
|
const ColorPickerSliderThumb = 'ColorPickerSliderThumb';
|
|
7863
8029
|
const CompletionDetailCloseButton = 'CompletionDetailCloseButton';
|
|
7864
8030
|
const CompletionDetailContent = 'CompletionDetailContent';
|
|
@@ -8133,6 +8299,11 @@ const handleBlur = editor => {
|
|
|
8133
8299
|
return closeRename(editor);
|
|
8134
8300
|
};
|
|
8135
8301
|
|
|
8302
|
+
const rerender = editor => {
|
|
8303
|
+
// TODO avoid slow clone
|
|
8304
|
+
return structuredClone(editor);
|
|
8305
|
+
};
|
|
8306
|
+
|
|
8136
8307
|
const focusIndex = (state, index) => {
|
|
8137
8308
|
const newState = {
|
|
8138
8309
|
...state,
|
|
@@ -8239,9 +8410,6 @@ const loadFont = async (fontName, fontUrl) => {
|
|
|
8239
8410
|
}
|
|
8240
8411
|
};
|
|
8241
8412
|
|
|
8242
|
-
const load = async (fontName, fontUrl) => {
|
|
8243
|
-
return loadFont(fontName, fontUrl);
|
|
8244
|
-
};
|
|
8245
8413
|
const ensure = async (fontName, fontUrl) => {
|
|
8246
8414
|
if (isLoaded(fontName)) {
|
|
8247
8415
|
return;
|
|
@@ -8249,7 +8417,7 @@ const ensure = async (fontName, fontUrl) => {
|
|
|
8249
8417
|
if (hasPending(fontName)) {
|
|
8250
8418
|
return getPending(fontName);
|
|
8251
8419
|
}
|
|
8252
|
-
const promise =
|
|
8420
|
+
const promise = loadFont(fontName, fontUrl);
|
|
8253
8421
|
setPending(fontName, promise);
|
|
8254
8422
|
await promise;
|
|
8255
8423
|
removePending(fontName);
|
|
@@ -8344,49 +8512,6 @@ const moveLineDown = editor => {
|
|
|
8344
8512
|
return editor;
|
|
8345
8513
|
};
|
|
8346
8514
|
|
|
8347
|
-
const create = () => {
|
|
8348
|
-
const completionUid = create$8();
|
|
8349
|
-
const widget = {
|
|
8350
|
-
id: CodeGenerator,
|
|
8351
|
-
oldState: {
|
|
8352
|
-
uid: completionUid,
|
|
8353
|
-
questions: [],
|
|
8354
|
-
x: 0,
|
|
8355
|
-
y: 0,
|
|
8356
|
-
width: 0,
|
|
8357
|
-
height: 0,
|
|
8358
|
-
focused: false,
|
|
8359
|
-
focusSource: Unknown$1
|
|
8360
|
-
},
|
|
8361
|
-
newState: {
|
|
8362
|
-
uid: completionUid,
|
|
8363
|
-
questions: [],
|
|
8364
|
-
x: 0,
|
|
8365
|
-
y: 0,
|
|
8366
|
-
width: 0,
|
|
8367
|
-
height: 0,
|
|
8368
|
-
focused: true,
|
|
8369
|
-
focusSource: Script
|
|
8370
|
-
}
|
|
8371
|
-
};
|
|
8372
|
-
return widget;
|
|
8373
|
-
};
|
|
8374
|
-
|
|
8375
|
-
const newStateGenerator = async state => {
|
|
8376
|
-
const latestState = {
|
|
8377
|
-
...state,
|
|
8378
|
-
x: 100,
|
|
8379
|
-
y: 100,
|
|
8380
|
-
width: 150,
|
|
8381
|
-
height: 45
|
|
8382
|
-
};
|
|
8383
|
-
return latestState;
|
|
8384
|
-
};
|
|
8385
|
-
const openCodeGenerator = async editor => {
|
|
8386
|
-
const fullFocus = true;
|
|
8387
|
-
return addWidgetToEditor(CodeGenerator, FocusCodeGenerator, editor, create, newStateGenerator, fullFocus);
|
|
8388
|
-
};
|
|
8389
|
-
|
|
8390
8515
|
// TODO handle multiple cursors
|
|
8391
8516
|
const moveLineUp = editor => {
|
|
8392
8517
|
// const rowIndex = editor.cursor.rowIndex
|
|
@@ -8911,20 +9036,25 @@ const getCursorsVirtualDom = cursors => {
|
|
|
8911
9036
|
return dom;
|
|
8912
9037
|
};
|
|
8913
9038
|
|
|
9039
|
+
// TODO use numeric value
|
|
8914
9040
|
const Error$1 = 'error';
|
|
8915
9041
|
const Warning = 'warning';
|
|
8916
9042
|
|
|
8917
9043
|
const getDiagnosticClassName = type => {
|
|
8918
|
-
// TODO use classnames enum
|
|
8919
9044
|
switch (type) {
|
|
8920
9045
|
case Error$1:
|
|
8921
|
-
return
|
|
9046
|
+
return DiagnosticError;
|
|
8922
9047
|
case Warning:
|
|
8923
|
-
return
|
|
9048
|
+
return DiagnosticWarning;
|
|
8924
9049
|
default:
|
|
8925
|
-
return
|
|
9050
|
+
return DiagnosticError;
|
|
8926
9051
|
}
|
|
8927
9052
|
};
|
|
9053
|
+
|
|
9054
|
+
const mergeClassNames = (...classNames) => {
|
|
9055
|
+
return classNames.filter(Boolean).join(' ');
|
|
9056
|
+
};
|
|
9057
|
+
|
|
8928
9058
|
const getDiagnosticVirtualDom = diagnostic => {
|
|
8929
9059
|
const {
|
|
8930
9060
|
x,
|
|
@@ -8936,7 +9066,7 @@ const getDiagnosticVirtualDom = diagnostic => {
|
|
|
8936
9066
|
const extraClassName = getDiagnosticClassName(type);
|
|
8937
9067
|
return [{
|
|
8938
9068
|
type: Div,
|
|
8939
|
-
className:
|
|
9069
|
+
className: mergeClassNames(Diagnostic, extraClassName),
|
|
8940
9070
|
width,
|
|
8941
9071
|
height,
|
|
8942
9072
|
top: y,
|
|
@@ -9226,23 +9356,15 @@ const renderEditor = async id => {
|
|
|
9226
9356
|
return commands;
|
|
9227
9357
|
};
|
|
9228
9358
|
|
|
9229
|
-
const
|
|
9230
|
-
|
|
9231
|
-
|
|
9232
|
-
|
|
9233
|
-
|
|
9234
|
-
|
|
9235
|
-
|
|
9236
|
-
|
|
9237
|
-
if (index === -1) {
|
|
9238
|
-
return editor;
|
|
9359
|
+
const editorDiagnosticEffect = {
|
|
9360
|
+
isActive(oldEditor, newEditor) {
|
|
9361
|
+
// TODO avoid slow comparison
|
|
9362
|
+
return newEditor.diagnosticsEnabled && JSON.stringify(oldEditor.lines) !== JSON.stringify(newEditor.lines);
|
|
9363
|
+
},
|
|
9364
|
+
// TODO set effects delay / diagnostic delay
|
|
9365
|
+
async apply(editor) {
|
|
9366
|
+
await updateDiagnostics(editor.id);
|
|
9239
9367
|
}
|
|
9240
|
-
const newWidgets = removeEditorWidget(widgets, CodeGenerator);
|
|
9241
|
-
return {
|
|
9242
|
-
...editor,
|
|
9243
|
-
widgets: newWidgets,
|
|
9244
|
-
focused: true
|
|
9245
|
-
};
|
|
9246
9368
|
};
|
|
9247
9369
|
|
|
9248
9370
|
const keep = [
|
|
@@ -9302,9 +9424,16 @@ const widgetCommands = {
|
|
|
9302
9424
|
|
|
9303
9425
|
// TODO wrap commands globally, not per editor
|
|
9304
9426
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
9427
|
+
|
|
9428
|
+
const effects = [editorDiagnosticEffect];
|
|
9305
9429
|
const wrapCommand = fn => async (editorUid, ...args) => {
|
|
9306
9430
|
const oldInstance = get$6(editorUid);
|
|
9307
9431
|
const newEditor = await fn(oldInstance.newState, ...args);
|
|
9432
|
+
for (const effect of effects) {
|
|
9433
|
+
if (effect.isActive(oldInstance.newState, newEditor)) {
|
|
9434
|
+
effect.apply(newEditor);
|
|
9435
|
+
}
|
|
9436
|
+
}
|
|
9308
9437
|
set$6(editorUid, oldInstance.newState, newEditor);
|
|
9309
9438
|
// TODO if possible, rendering should be sync
|
|
9310
9439
|
const commands = await renderEditor(editorUid);
|
|
@@ -9323,11 +9452,6 @@ const wrapCommands = commands => {
|
|
|
9323
9452
|
}
|
|
9324
9453
|
};
|
|
9325
9454
|
|
|
9326
|
-
const codeGeneratorAccept = state => {
|
|
9327
|
-
// TODO close code generator widget
|
|
9328
|
-
return state;
|
|
9329
|
-
};
|
|
9330
|
-
|
|
9331
9455
|
const commandMap = {
|
|
9332
9456
|
'CodeGenerator.accept': codeGeneratorAccept,
|
|
9333
9457
|
'ColorPicker.handleSliderPointerDown': handleSliderPointerDown,
|
|
@@ -9430,6 +9554,7 @@ const commandMap = {
|
|
|
9430
9554
|
'Editor.pasteText': pasteText,
|
|
9431
9555
|
'Editor.render': renderEditor,
|
|
9432
9556
|
'Editor.replaceRange': replaceRange,
|
|
9557
|
+
'Editor.rerender': rerender,
|
|
9433
9558
|
'Editor.save': save,
|
|
9434
9559
|
'Editor.selectAll': selectAll,
|
|
9435
9560
|
'Editor.selectAllLeft': editorSelectAllLeft,
|
|
@@ -10034,10 +10159,6 @@ const removeWidget = widget => {
|
|
|
10034
10159
|
return [['Viewlet.send', widget.newState.uid, 'dispose']];
|
|
10035
10160
|
};
|
|
10036
10161
|
|
|
10037
|
-
const mergeClassNames = (...classNames) => {
|
|
10038
|
-
return classNames.filter(Boolean).join(' ');
|
|
10039
|
-
};
|
|
10040
|
-
|
|
10041
10162
|
const getCodeGeneratorVirtualDom = state => {
|
|
10042
10163
|
const escapeToClose$1 = escapeToClose();
|
|
10043
10164
|
const enterCode$1 = enterCode();
|