@lvce-editor/editor-worker 19.33.1 → 19.35.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 +104 -7
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -3482,6 +3482,7 @@ const getUrlAtOffset = (editor, offset) => {
|
|
|
3482
3482
|
};
|
|
3483
3483
|
|
|
3484
3484
|
const EditorChange = 1;
|
|
3485
|
+
const EditorSelection$1 = 2;
|
|
3485
3486
|
|
|
3486
3487
|
const state$9 = Object.create(null);
|
|
3487
3488
|
|
|
@@ -4544,6 +4545,7 @@ const createEditor2 = (id, uri, x, y, width, height, platform, assetDir) => {
|
|
|
4544
4545
|
diagnosticsEnabled: false,
|
|
4545
4546
|
differences: [],
|
|
4546
4547
|
embeds: [],
|
|
4548
|
+
endOfLineDecorations: [],
|
|
4547
4549
|
finalDeltaY: 0,
|
|
4548
4550
|
finalY: 0,
|
|
4549
4551
|
focus: 0,
|
|
@@ -4627,6 +4629,7 @@ const emptyEditor = {
|
|
|
4627
4629
|
diagnostics: [],
|
|
4628
4630
|
differences: [],
|
|
4629
4631
|
embeds: [],
|
|
4632
|
+
endOfLineDecorations: [],
|
|
4630
4633
|
focused: false,
|
|
4631
4634
|
foldingRanges: [],
|
|
4632
4635
|
hasListener: false,
|
|
@@ -4791,6 +4794,7 @@ const createEditor = async ({
|
|
|
4791
4794
|
diagnostics: [],
|
|
4792
4795
|
diagnosticsEnabled,
|
|
4793
4796
|
differences: [],
|
|
4797
|
+
endOfLineDecorations: [],
|
|
4794
4798
|
finalDeltaY: 0,
|
|
4795
4799
|
finalY: 0,
|
|
4796
4800
|
focused: false,
|
|
@@ -5064,6 +5068,36 @@ const dispose$2 = uid => {
|
|
|
5064
5068
|
pendingSaves.delete(uid);
|
|
5065
5069
|
};
|
|
5066
5070
|
|
|
5071
|
+
const getEditorStatus = editor => {
|
|
5072
|
+
const primarySelectionIndex = editor.primarySelectionIndex || 0;
|
|
5073
|
+
const rowIndex = editor.selections[primarySelectionIndex + 2] || 0;
|
|
5074
|
+
const columnIndex = editor.selections[primarySelectionIndex + 3] || 0;
|
|
5075
|
+
return {
|
|
5076
|
+
column: columnIndex + 1,
|
|
5077
|
+
encoding: 'utf8',
|
|
5078
|
+
languageId: editor.languageId,
|
|
5079
|
+
line: rowIndex + 1,
|
|
5080
|
+
tabSize: editor.tabSize
|
|
5081
|
+
};
|
|
5082
|
+
};
|
|
5083
|
+
|
|
5084
|
+
const equals = (oldStatus, newStatus) => {
|
|
5085
|
+
return oldStatus.column === newStatus.column && oldStatus.encoding === newStatus.encoding && oldStatus.languageId === newStatus.languageId && oldStatus.line === newStatus.line && oldStatus.tabSize === newStatus.tabSize;
|
|
5086
|
+
};
|
|
5087
|
+
const notifyEditorStatusChange = async (oldEditor, newEditor) => {
|
|
5088
|
+
if (newEditor.initial || !newEditor.focused) {
|
|
5089
|
+
return;
|
|
5090
|
+
}
|
|
5091
|
+
const newStatus = getEditorStatus(newEditor);
|
|
5092
|
+
if (!oldEditor.initial && oldEditor.focused && equals(getEditorStatus(oldEditor), newStatus)) {
|
|
5093
|
+
return;
|
|
5094
|
+
}
|
|
5095
|
+
await notifyListeners(EditorSelection$1, 'StatusBar.handleEditorStatusChanged', newStatus);
|
|
5096
|
+
};
|
|
5097
|
+
const notifyEditorStatusCleared = async () => {
|
|
5098
|
+
await notifyListeners(EditorSelection$1, 'StatusBar.handleEditorStatusChanged', undefined);
|
|
5099
|
+
};
|
|
5100
|
+
|
|
5067
5101
|
const addWidget$1 = widget => {
|
|
5068
5102
|
const module = get$7(widget.id);
|
|
5069
5103
|
if (!module) {
|
|
@@ -5157,6 +5191,9 @@ const disposeEditor = async editorUid => {
|
|
|
5157
5191
|
dispose$1(editorUid);
|
|
5158
5192
|
dispose$2(editorUid);
|
|
5159
5193
|
dispose$3(editorUid);
|
|
5194
|
+
if (getKeys$2().length === 0) {
|
|
5195
|
+
await notifyEditorStatusCleared();
|
|
5196
|
+
}
|
|
5160
5197
|
return commands;
|
|
5161
5198
|
};
|
|
5162
5199
|
|
|
@@ -7856,6 +7893,43 @@ const getClickHandler = modifier => {
|
|
|
7856
7893
|
}
|
|
7857
7894
|
};
|
|
7858
7895
|
|
|
7896
|
+
const isProviderDecoration = value => {
|
|
7897
|
+
return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
|
|
7898
|
+
};
|
|
7899
|
+
const getProviderDecorations = (results, rowIndex) => {
|
|
7900
|
+
if (!Array.isArray(results)) {
|
|
7901
|
+
return [];
|
|
7902
|
+
}
|
|
7903
|
+
const decorations = [];
|
|
7904
|
+
for (const result of results) {
|
|
7905
|
+
if (!Array.isArray(result)) {
|
|
7906
|
+
continue;
|
|
7907
|
+
}
|
|
7908
|
+
for (const decoration of result) {
|
|
7909
|
+
if (isProviderDecoration(decoration) && typeof decoration.text === 'string') {
|
|
7910
|
+
decorations.push({
|
|
7911
|
+
rowIndex,
|
|
7912
|
+
text: decoration.text
|
|
7913
|
+
});
|
|
7914
|
+
}
|
|
7915
|
+
}
|
|
7916
|
+
}
|
|
7917
|
+
return decorations;
|
|
7918
|
+
};
|
|
7919
|
+
const getEditorLineDecorations = async (editor, rowIndex) => {
|
|
7920
|
+
const textDocument = {
|
|
7921
|
+
languageId: editor.languageId,
|
|
7922
|
+
text: getText$1(editor),
|
|
7923
|
+
uri: editor.uri
|
|
7924
|
+
};
|
|
7925
|
+
try {
|
|
7926
|
+
const results = await invoke$d('Extensions.executeProvidersByEvent', 'onEditorLineDecoration', 'ExtensionApi.executeEditorLineDecorationProvider', textDocument, rowIndex);
|
|
7927
|
+
return getProviderDecorations(results, rowIndex);
|
|
7928
|
+
} catch {
|
|
7929
|
+
return [];
|
|
7930
|
+
}
|
|
7931
|
+
};
|
|
7932
|
+
|
|
7859
7933
|
const handleClickAtPosition = async (editor, modifier, rowIndex, columnIndex) => {
|
|
7860
7934
|
object(editor);
|
|
7861
7935
|
number(modifier);
|
|
@@ -7866,7 +7940,11 @@ const handleClickAtPosition = async (editor, modifier, rowIndex, columnIndex) =>
|
|
|
7866
7940
|
columnIndex,
|
|
7867
7941
|
rowIndex
|
|
7868
7942
|
});
|
|
7869
|
-
|
|
7943
|
+
const endOfLineDecorations = await getEditorLineDecorations(newEditor, rowIndex);
|
|
7944
|
+
return {
|
|
7945
|
+
...newEditor,
|
|
7946
|
+
endOfLineDecorations
|
|
7947
|
+
};
|
|
7870
7948
|
};
|
|
7871
7949
|
|
|
7872
7950
|
const Editor = 3;
|
|
@@ -11583,6 +11661,7 @@ const CompletionDetailContent = 'CompletionDetailContent';
|
|
|
11583
11661
|
const Diagnostic = 'Diagnostic';
|
|
11584
11662
|
const EditorCursor = 'EditorCursor';
|
|
11585
11663
|
const EditorHoverDiagnosticOnly = 'EditorHoverDiagnosticOnly';
|
|
11664
|
+
const EditorLineDecoration = 'EditorLineDecoration';
|
|
11586
11665
|
const EditorRow = 'EditorRow';
|
|
11587
11666
|
const EditorRowHighlighted = 'EditorRowHighlighted';
|
|
11588
11667
|
const EditorSelection = 'EditorSelection';
|
|
@@ -13271,6 +13350,12 @@ ${editorSelector} .EditorRow {
|
|
|
13271
13350
|
height: var(--EditorRowHeight);
|
|
13272
13351
|
line-height: var(--EditorRowHeight);
|
|
13273
13352
|
}
|
|
13353
|
+
${editorSelector} .EditorLineDecoration {
|
|
13354
|
+
color: var(--EditorInlineBlameForeground, rgba(255, 255, 255, 0.5));
|
|
13355
|
+
font-style: italic;
|
|
13356
|
+
margin-left: 2em;
|
|
13357
|
+
user-select: none;
|
|
13358
|
+
}
|
|
13274
13359
|
${editorSelector} .R{background-color:#add6ff40}
|
|
13275
13360
|
${editorSelector} .ScrollBarThumbVertical {
|
|
13276
13361
|
height: var(--ScrollBarHeight);
|
|
@@ -13689,17 +13774,24 @@ const getEditorDiagnosticsVirtualDom = diagnostics => {
|
|
|
13689
13774
|
}, ...diagnosticsDom];
|
|
13690
13775
|
};
|
|
13691
13776
|
|
|
13692
|
-
const
|
|
13777
|
+
const editorLineDecorationNode = {
|
|
13778
|
+
childCount: 1,
|
|
13779
|
+
className: EditorLineDecoration,
|
|
13780
|
+
type: Span
|
|
13781
|
+
};
|
|
13782
|
+
const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
|
|
13693
13783
|
const dom = [];
|
|
13694
13784
|
for (let i = 0; i < textInfos.length; i++) {
|
|
13695
13785
|
const textInfo = textInfos[i];
|
|
13696
13786
|
const difference = differences[i];
|
|
13787
|
+
const rowIndex = visibleLineIndices[i] ?? i;
|
|
13788
|
+
const rowDecorations = endOfLineDecorations.filter(decoration => decoration.rowIndex === rowIndex);
|
|
13697
13789
|
let className = EditorRow;
|
|
13698
13790
|
if (i === highlightedLine) {
|
|
13699
13791
|
className = mergeClassNames(className, EditorRowHighlighted);
|
|
13700
13792
|
}
|
|
13701
13793
|
dom.push({
|
|
13702
|
-
childCount: textInfo.length / 2,
|
|
13794
|
+
childCount: textInfo.length / 2 + rowDecorations.length,
|
|
13703
13795
|
className,
|
|
13704
13796
|
translate: px(difference),
|
|
13705
13797
|
type: Div
|
|
@@ -13713,12 +13805,15 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
13713
13805
|
type: Span
|
|
13714
13806
|
}, text(tokenText));
|
|
13715
13807
|
}
|
|
13808
|
+
for (const decoration of rowDecorations) {
|
|
13809
|
+
dom.push(editorLineDecorationNode, text(decoration.text));
|
|
13810
|
+
}
|
|
13716
13811
|
}
|
|
13717
13812
|
return dom;
|
|
13718
13813
|
};
|
|
13719
13814
|
|
|
13720
|
-
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1) => {
|
|
13721
|
-
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine);
|
|
13815
|
+
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = []) => {
|
|
13816
|
+
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations);
|
|
13722
13817
|
return [{
|
|
13723
13818
|
childCount: textInfos.length,
|
|
13724
13819
|
className: 'EditorRows',
|
|
@@ -14012,6 +14107,7 @@ const renderLines = {
|
|
|
14012
14107
|
}
|
|
14013
14108
|
const {
|
|
14014
14109
|
differences,
|
|
14110
|
+
endOfLineDecorations,
|
|
14015
14111
|
textInfos
|
|
14016
14112
|
} = newState;
|
|
14017
14113
|
newState.differences = differences;
|
|
@@ -14020,10 +14116,10 @@ const renderLines = {
|
|
|
14020
14116
|
visibleLineIndices
|
|
14021
14117
|
} = newState;
|
|
14022
14118
|
const relativeLine = visibleLineIndices.indexOf(highlightedLine);
|
|
14023
|
-
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine);
|
|
14119
|
+
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, relativeLine, visibleLineIndices, endOfLineDecorations);
|
|
14024
14120
|
return [/* method */'setText', dom];
|
|
14025
14121
|
},
|
|
14026
|
-
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
|
|
14122
|
+
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.debugEnabled === newState.debugEnabled
|
|
14027
14123
|
};
|
|
14028
14124
|
const renderSelections = {
|
|
14029
14125
|
apply: (oldState, newState) => {
|
|
@@ -14468,6 +14564,7 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
|
|
|
14468
14564
|
}
|
|
14469
14565
|
set$8(uid, state, finalEditor);
|
|
14470
14566
|
}
|
|
14567
|
+
await notifyEditorStatusChange(state, finalEditor);
|
|
14471
14568
|
if (!initial && uri === finalEditor.uri && (lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
14472
14569
|
for (const key of getKeys$2()) {
|
|
14473
14570
|
const otherUid = Number(key);
|