@lvce-editor/editor-worker 19.70.0 → 19.70.2
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 +94 -20
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -6381,7 +6381,7 @@ const diagnosticsEqual = (left, right) => {
|
|
|
6381
6381
|
}
|
|
6382
6382
|
return right.every((diagnostic, index) => {
|
|
6383
6383
|
const other = left[index];
|
|
6384
|
-
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;
|
|
6384
|
+
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.tags === diagnostic.tags || (other.tags?.length ?? 0) === (diagnostic.tags?.length ?? 0) && (other.tags ?? []).every((tag, index) => tag === diagnostic.tags?.[index])) && other.type === diagnostic.type && other.uri === diagnostic.uri;
|
|
6385
6385
|
});
|
|
6386
6386
|
};
|
|
6387
6387
|
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;
|
|
@@ -13206,11 +13206,21 @@ const getSnippetChanges = (lines, selections, snippet) => {
|
|
|
13206
13206
|
for (let i = 0; i < selections.length; i += 4) {
|
|
13207
13207
|
const [selectionStartRow, selectionStartColumn, selectionEndRow, selectionEndColumn] = getSelectionPairs(selections, i);
|
|
13208
13208
|
if (insertedLines.length > 1) {
|
|
13209
|
+
let placeholderRow = -1;
|
|
13210
|
+
let placeholderColumn = -1;
|
|
13211
|
+
const insertedLinesWithoutPlaceholder = insertedLines.map((line, rowIndex) => {
|
|
13212
|
+
const index = line.indexOf('$0');
|
|
13213
|
+
if (index !== -1 && placeholderRow === -1) {
|
|
13214
|
+
placeholderRow = rowIndex;
|
|
13215
|
+
placeholderColumn = index;
|
|
13216
|
+
}
|
|
13217
|
+
return line.replace('$0', '');
|
|
13218
|
+
});
|
|
13209
13219
|
const line = getLine$1({
|
|
13210
13220
|
lines
|
|
13211
13221
|
}, selectionStartRow);
|
|
13212
13222
|
const indent = getIndent(line);
|
|
13213
|
-
const insertedLinesHere = [
|
|
13223
|
+
const insertedLinesHere = [insertedLinesWithoutPlaceholder[0], ...insertedLinesWithoutPlaceholder.slice(1).map(line => indent + line)];
|
|
13214
13224
|
const deleted = [''];
|
|
13215
13225
|
changes.push({
|
|
13216
13226
|
deleted,
|
|
@@ -13226,11 +13236,17 @@ const getSnippetChanges = (lines, selections, snippet) => {
|
|
|
13226
13236
|
}
|
|
13227
13237
|
});
|
|
13228
13238
|
const lastInsertedLine = insertedLines.at(-1);
|
|
13229
|
-
|
|
13230
|
-
|
|
13231
|
-
|
|
13232
|
-
|
|
13233
|
-
|
|
13239
|
+
if (placeholderRow === -1) {
|
|
13240
|
+
selectionChanges.push(selectionEndRow + insertedLines.length - deleted.length,
|
|
13241
|
+
// @ts-ignore
|
|
13242
|
+
selectionEndColumn + lastInsertedLine.length, selectionEndRow + insertedLines.length - deleted.length,
|
|
13243
|
+
// @ts-ignore
|
|
13244
|
+
selectionEndColumn + lastInsertedLine.length);
|
|
13245
|
+
} else {
|
|
13246
|
+
const cursorRow = selectionStartRow + placeholderRow;
|
|
13247
|
+
const cursorColumn = placeholderColumn + (placeholderRow === 0 ? selectionStartColumn - snippet.deleted : indent.length);
|
|
13248
|
+
selectionChanges.push(cursorRow, cursorColumn, cursorRow, cursorColumn);
|
|
13249
|
+
}
|
|
13234
13250
|
} else {
|
|
13235
13251
|
const line = insertedLines[0];
|
|
13236
13252
|
const placeholderIndex = line.indexOf('$0');
|
|
@@ -16777,6 +16793,10 @@ const getEditorDiagnosticsVirtualDom = (diagnostics, bracketMatchInfos = []) =>
|
|
|
16777
16793
|
}, ...diagnosticsDom, ...bracketMatchesDom];
|
|
16778
16794
|
};
|
|
16779
16795
|
|
|
16796
|
+
const DiagnosticTag = {
|
|
16797
|
+
Unnecessary: 1
|
|
16798
|
+
};
|
|
16799
|
+
|
|
16780
16800
|
const editorLineDecorationNode = {
|
|
16781
16801
|
childCount: 1,
|
|
16782
16802
|
className: EditorLineDecoration,
|
|
@@ -16792,6 +16812,49 @@ const mergeConflictActions = [{
|
|
|
16792
16812
|
action: 'both',
|
|
16793
16813
|
label: 'Accept Both Changes'
|
|
16794
16814
|
}];
|
|
16815
|
+
const getUnnecessaryRanges = (diagnostics, rowIndex, textLength) => {
|
|
16816
|
+
return diagnostics.filter(diagnostic => diagnostic.tags?.includes(DiagnosticTag.Unnecessary)).flatMap(diagnostic => {
|
|
16817
|
+
if (rowIndex < diagnostic.rowIndex || rowIndex > diagnostic.endRowIndex) {
|
|
16818
|
+
return [];
|
|
16819
|
+
}
|
|
16820
|
+
const start = rowIndex === diagnostic.rowIndex ? diagnostic.columnIndex : 0;
|
|
16821
|
+
const end = rowIndex === diagnostic.endRowIndex ? diagnostic.endColumnIndex : textLength;
|
|
16822
|
+
return start < end ? [{
|
|
16823
|
+
end,
|
|
16824
|
+
start
|
|
16825
|
+
}] : [];
|
|
16826
|
+
}).toSorted((left, right) => left.start - right.start);
|
|
16827
|
+
};
|
|
16828
|
+
const getTokenParts = (textInfos, ranges) => {
|
|
16829
|
+
const parts = [];
|
|
16830
|
+
let offset = 0;
|
|
16831
|
+
for (let index = 0; index < textInfos.length; index += 2) {
|
|
16832
|
+
const tokenText = textInfos[index];
|
|
16833
|
+
const tokenClassName = textInfos[index + 1];
|
|
16834
|
+
const tokenEnd = offset + tokenText.length;
|
|
16835
|
+
const boundaries = new Set([offset, tokenEnd]);
|
|
16836
|
+
for (const range of ranges) {
|
|
16837
|
+
if (range.start > offset && range.start < tokenEnd) {
|
|
16838
|
+
boundaries.add(range.start);
|
|
16839
|
+
}
|
|
16840
|
+
if (range.end > offset && range.end < tokenEnd) {
|
|
16841
|
+
boundaries.add(range.end);
|
|
16842
|
+
}
|
|
16843
|
+
}
|
|
16844
|
+
const sortedBoundaries = [...boundaries].toSorted((left, right) => left - right);
|
|
16845
|
+
for (let boundaryIndex = 0; boundaryIndex < sortedBoundaries.length - 1; boundaryIndex++) {
|
|
16846
|
+
const start = sortedBoundaries[boundaryIndex];
|
|
16847
|
+
const end = sortedBoundaries[boundaryIndex + 1];
|
|
16848
|
+
const unnecessary = ranges.some(range => start >= range.start && end <= range.end);
|
|
16849
|
+
parts.push({
|
|
16850
|
+
className: unnecessary ? mergeClassNames(tokenClassName, 'EditorTokenUnnecessary') : tokenClassName,
|
|
16851
|
+
text: tokenText.slice(start - offset, end - offset)
|
|
16852
|
+
});
|
|
16853
|
+
}
|
|
16854
|
+
offset = tokenEnd;
|
|
16855
|
+
}
|
|
16856
|
+
return parts;
|
|
16857
|
+
};
|
|
16795
16858
|
const addMergeConflictActions = (dom, rowIndex) => {
|
|
16796
16859
|
dom.push({
|
|
16797
16860
|
childCount: mergeConflictActions.length,
|
|
@@ -16816,7 +16879,7 @@ const addMergeConflictActions = (dom, rowIndex) => {
|
|
|
16816
16879
|
}, text(label));
|
|
16817
16880
|
}
|
|
16818
16881
|
};
|
|
16819
|
-
const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1) => {
|
|
16882
|
+
const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, diagnostics = []) => {
|
|
16820
16883
|
const dom = [];
|
|
16821
16884
|
const actualViewRows = visibleViewLineIndices.length === 0 ? Array.from({
|
|
16822
16885
|
length: textInfos.length
|
|
@@ -16831,6 +16894,11 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
16831
16894
|
const difference = differences[textInfoIndex];
|
|
16832
16895
|
const rowIndex = viewRow;
|
|
16833
16896
|
const rowDecorations = endOfLineDecorations.filter(decoration => decoration.rowIndex === rowIndex);
|
|
16897
|
+
let rowTextLength = 0;
|
|
16898
|
+
for (let index = 0; index < textInfo.length; index += 2) {
|
|
16899
|
+
rowTextLength += textInfo[index].length;
|
|
16900
|
+
}
|
|
16901
|
+
const tokenParts = getTokenParts(textInfo, getUnnecessaryRanges(diagnostics, rowIndex, rowTextLength));
|
|
16834
16902
|
let className = EditorRow;
|
|
16835
16903
|
if (rowIndex === highlightedLine) {
|
|
16836
16904
|
className = mergeClassNames(className, EditorRowHighlighted);
|
|
@@ -16839,14 +16907,15 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
16839
16907
|
className = mergeClassNames(className, 'EditorProblemsHighlightedRow');
|
|
16840
16908
|
}
|
|
16841
16909
|
dom.push({
|
|
16842
|
-
childCount:
|
|
16910
|
+
childCount: tokenParts.length + rowDecorations.length,
|
|
16843
16911
|
className,
|
|
16844
16912
|
translate: difference === 0 ? '' : px(difference),
|
|
16845
16913
|
type: Div
|
|
16846
16914
|
});
|
|
16847
|
-
for (
|
|
16848
|
-
|
|
16849
|
-
|
|
16915
|
+
for (const {
|
|
16916
|
+
className,
|
|
16917
|
+
text: tokenText
|
|
16918
|
+
} of tokenParts) {
|
|
16850
16919
|
dom.push({
|
|
16851
16920
|
childCount: 1,
|
|
16852
16921
|
className,
|
|
@@ -16861,8 +16930,8 @@ const getEditorRowsVirtualDom$1 = (textInfos, differences, lineNumbers = true, h
|
|
|
16861
16930
|
return dom;
|
|
16862
16931
|
};
|
|
16863
16932
|
|
|
16864
|
-
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1) => {
|
|
16865
|
-
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow);
|
|
16933
|
+
const getEditorRowsVirtualDom = (textInfos, differences, lineNumbers = true, highlightedLine = -1, visibleLineIndices = [], endOfLineDecorations = [], visibleViewLineIndices = [], problemsHighlightedRow = -1, unnecessaryDiagnostics = []) => {
|
|
16934
|
+
const rowsDom = getEditorRowsVirtualDom$1(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics);
|
|
16866
16935
|
return [{
|
|
16867
16936
|
childCount: visibleViewLineIndices.length || textInfos.length,
|
|
16868
16937
|
className: 'EditorRows',
|
|
@@ -16959,8 +17028,8 @@ const editorLayersNode = {
|
|
|
16959
17028
|
className: 'EditorLayers',
|
|
16960
17029
|
type: Div
|
|
16961
17030
|
};
|
|
16962
|
-
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false) => {
|
|
16963
|
-
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
|
|
17031
|
+
const getEditorLayersVirtualDom = (selectionInfos, textInfos, differences, lineNumbers = true, highlightedLine = -1, cursorInfos = [], diagnostics = [], visibleLineIndices = [], endOfLineDecorations = [], bracketMatchInfos = [], focused = true, visibleViewLineIndices = [], problemsHighlightedRow = -1, roundedSelection = false, unnecessaryDiagnostics = []) => {
|
|
17032
|
+
return [editorLayersNode, ...getEditorSelectionsVirtualDom(selectionInfos, focused, roundedSelection), ...getEditorRowsVirtualDom(textInfos, differences, lineNumbers, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, problemsHighlightedRow, unnecessaryDiagnostics), ...getEditorCursorsVirtualDom(cursorInfos, focused), ...getEditorDiagnosticsVirtualDom(diagnostics, bracketMatchInfos)];
|
|
16964
17033
|
};
|
|
16965
17034
|
|
|
16966
17035
|
const getEditorScrollBarDiagnosticsVirtualDom = scrollBarDiagnostics => {
|
|
@@ -17041,13 +17110,14 @@ const getEditorContentVirtualDom = ({
|
|
|
17041
17110
|
scrollBarWidth = 0,
|
|
17042
17111
|
selectionInfos = [],
|
|
17043
17112
|
textInfos,
|
|
17113
|
+
unnecessaryDiagnostics = [],
|
|
17044
17114
|
visibleLineIndices = [],
|
|
17045
17115
|
visibleViewLineIndices = []
|
|
17046
17116
|
}) => {
|
|
17047
17117
|
return [{
|
|
17048
17118
|
...editorContentNode,
|
|
17049
17119
|
className: breadcrumbsEnabled ? 'EditorContent EditorBreadcrumbsOffset' : 'EditorContent'
|
|
17050
|
-
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
|
|
17120
|
+
}, ...getEditorInputVirtualDom(), ...getEditorLayersVirtualDom(selectionInfos, textInfos, differences, lineNumbers, highlightedLine, cursorInfos, diagnostics, visibleLineIndices, endOfLineDecorations, bracketMatchInfos, focused, visibleViewLineIndices, problemsHighlightedRow, roundedSelection, unnecessaryDiagnostics), ...getEditorScrollBarDiagnosticsVirtualDom(scrollBarDiagnostics), ...getScrollBarVirtualDom(scrollBarHeight, scrollBarWidth)];
|
|
17051
17121
|
};
|
|
17052
17122
|
|
|
17053
17123
|
const getGutterInfoVirtualDom = (gutterInfo, activeLineNumber) => {
|
|
@@ -17219,6 +17289,7 @@ const getEditorVirtualDom = ({
|
|
|
17219
17289
|
selections = new Uint32Array(),
|
|
17220
17290
|
textInfos,
|
|
17221
17291
|
uid,
|
|
17292
|
+
unnecessaryDiagnostics = [],
|
|
17222
17293
|
uri = '',
|
|
17223
17294
|
visibleLineIndices,
|
|
17224
17295
|
visibleViewLineIndices = [],
|
|
@@ -17276,6 +17347,7 @@ const getEditorVirtualDom = ({
|
|
|
17276
17347
|
scrollBarWidth,
|
|
17277
17348
|
selectionInfos,
|
|
17278
17349
|
textInfos: combineWhitespaceTokens$1 ? textInfos.map(combineWhitespaceTokens) : textInfos,
|
|
17350
|
+
unnecessaryDiagnostics,
|
|
17279
17351
|
visibleLineIndices: visibleLineIndices || [],
|
|
17280
17352
|
visibleViewLineIndices
|
|
17281
17353
|
}), ...minimapDom];
|
|
@@ -17451,7 +17523,8 @@ const getDom = state => {
|
|
|
17451
17523
|
...state,
|
|
17452
17524
|
diagnostics: visualDecorations,
|
|
17453
17525
|
scrollBarDiagnostics: getScrollBarDiagnostics(state, diagnostics),
|
|
17454
|
-
scrollBarWidth: getScrollBarSize(width, longestLineWidth, minimumSliderSize)
|
|
17526
|
+
scrollBarWidth: getScrollBarSize(width, longestLineWidth, minimumSliderSize),
|
|
17527
|
+
unnecessaryDiagnostics: diagnostics
|
|
17455
17528
|
});
|
|
17456
17529
|
};
|
|
17457
17530
|
const mergeConflictsEqual = (oldState, newState) => {
|
|
@@ -17616,6 +17689,7 @@ const renderLines = {
|
|
|
17616
17689
|
return [/* method */'setIncrementalEdits', /* incrementalEdits */incrementalEdits];
|
|
17617
17690
|
}
|
|
17618
17691
|
const {
|
|
17692
|
+
diagnostics,
|
|
17619
17693
|
differences,
|
|
17620
17694
|
endOfLineDecorations,
|
|
17621
17695
|
textInfos
|
|
@@ -17626,10 +17700,10 @@ const renderLines = {
|
|
|
17626
17700
|
visibleLineIndices,
|
|
17627
17701
|
visibleViewLineIndices
|
|
17628
17702
|
} = newState;
|
|
17629
|
-
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow);
|
|
17703
|
+
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow, diagnostics || []);
|
|
17630
17704
|
return [/* method */'setText', dom];
|
|
17631
17705
|
},
|
|
17632
|
-
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && 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.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
|
|
17706
|
+
isEqual: (oldState, newState) => oldState.lines === newState.lines && oldState.foldingRanges === newState.foldingRanges && oldState.visibleViewLineIndices === newState.visibleViewLineIndices && oldState.tokenizerId === newState.tokenizerId && oldState.minLineY === newState.minLineY && oldState.decorations === newState.decorations && oldState.embeds === newState.embeds && oldState.endOfLineDecorations === newState.endOfLineDecorations && oldState.diagnostics === newState.diagnostics && oldState.deltaX === newState.deltaX && oldState.width === newState.width && oldState.highlightedLine === newState.highlightedLine && oldState.problemsHighlightedRow === newState.problemsHighlightedRow && oldState.debugEnabled === newState.debugEnabled
|
|
17633
17707
|
};
|
|
17634
17708
|
const renderSelections = {
|
|
17635
17709
|
apply: (oldState, newState) => {
|