@lvce-editor/editor-worker 19.70.0 → 19.70.1
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 +83 -13
- 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,
|
|
@@ -17616,6 +17685,7 @@ const renderLines = {
|
|
|
17616
17685
|
return [/* method */'setIncrementalEdits', /* incrementalEdits */incrementalEdits];
|
|
17617
17686
|
}
|
|
17618
17687
|
const {
|
|
17688
|
+
diagnostics,
|
|
17619
17689
|
differences,
|
|
17620
17690
|
endOfLineDecorations,
|
|
17621
17691
|
textInfos
|
|
@@ -17626,7 +17696,7 @@ const renderLines = {
|
|
|
17626
17696
|
visibleLineIndices,
|
|
17627
17697
|
visibleViewLineIndices
|
|
17628
17698
|
} = newState;
|
|
17629
|
-
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow);
|
|
17699
|
+
const dom = getEditorRowsVirtualDom$1(textInfos, differences, true, highlightedLine, visibleLineIndices, endOfLineDecorations, visibleViewLineIndices, newState.problemsHighlightedRow, diagnostics || []);
|
|
17630
17700
|
return [/* method */'setText', dom];
|
|
17631
17701
|
},
|
|
17632
17702
|
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
|