@lvce-editor/editor-worker 19.30.1 → 19.30.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 +56 -46
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -8054,6 +8054,55 @@ const requestAnimationFrame = fn => {
|
|
|
8054
8054
|
globalThis.requestAnimationFrame(fn);
|
|
8055
8055
|
};
|
|
8056
8056
|
|
|
8057
|
+
const getDiagnosticType = diagnostic => {
|
|
8058
|
+
return diagnostic.type;
|
|
8059
|
+
};
|
|
8060
|
+
|
|
8061
|
+
const getY = (row, minLineY, rowHeight) => {
|
|
8062
|
+
return (row - minLineY) * rowHeight;
|
|
8063
|
+
};
|
|
8064
|
+
|
|
8065
|
+
const getVisibleDiagnostics = async (editor, diagnostics) => {
|
|
8066
|
+
const visibleDiagnostics = [];
|
|
8067
|
+
const {
|
|
8068
|
+
charWidth,
|
|
8069
|
+
fontFamily,
|
|
8070
|
+
fontSize,
|
|
8071
|
+
fontWeight,
|
|
8072
|
+
isMonospaceFont,
|
|
8073
|
+
letterSpacing,
|
|
8074
|
+
lines,
|
|
8075
|
+
minLineY,
|
|
8076
|
+
rowHeight,
|
|
8077
|
+
tabSize,
|
|
8078
|
+
width
|
|
8079
|
+
} = editor;
|
|
8080
|
+
for (const diagnostic of diagnostics) {
|
|
8081
|
+
const {
|
|
8082
|
+
columnIndex,
|
|
8083
|
+
endColumnIndex,
|
|
8084
|
+
rowIndex
|
|
8085
|
+
} = diagnostic;
|
|
8086
|
+
const columnDelta = endColumnIndex - columnIndex;
|
|
8087
|
+
const diagnosticWidth = columnDelta * charWidth;
|
|
8088
|
+
const endLineDifference = 0;
|
|
8089
|
+
const halfCursorWidth = 0;
|
|
8090
|
+
const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
|
|
8091
|
+
const y = getY(rowIndex, minLineY, rowHeight);
|
|
8092
|
+
visibleDiagnostics.push({
|
|
8093
|
+
height: rowHeight,
|
|
8094
|
+
type: getDiagnosticType(diagnostic),
|
|
8095
|
+
width: diagnosticWidth,
|
|
8096
|
+
x,
|
|
8097
|
+
y
|
|
8098
|
+
});
|
|
8099
|
+
}
|
|
8100
|
+
return visibleDiagnostics;
|
|
8101
|
+
};
|
|
8102
|
+
|
|
8103
|
+
const shouldUpdateDiagnosticData = (oldState, newState) => {
|
|
8104
|
+
return oldState.diagnostics !== newState.diagnostics || (newState.diagnostics?.length ?? 0) > 0 && (oldState.minLineY !== newState.minLineY || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width);
|
|
8105
|
+
};
|
|
8057
8106
|
const shouldUpdateSelectionData = (oldState, newState) => {
|
|
8058
8107
|
return oldState.selections !== newState.selections || oldState.focused !== newState.focused || oldState.minLineY !== newState.minLineY || oldState.maxLineY !== newState.maxLineY || oldState.foldingRanges !== newState.foldingRanges || oldState.differences !== newState.differences || oldState.charWidth !== newState.charWidth || oldState.cursorWidth !== newState.cursorWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.lines !== newState.lines || oldState.rowHeight !== newState.rowHeight || oldState.tabSize !== newState.tabSize || oldState.width !== newState.width;
|
|
8059
8108
|
};
|
|
@@ -8078,6 +8127,13 @@ const updateDerivedState = async (oldState, newState) => {
|
|
|
8078
8127
|
textInfos
|
|
8079
8128
|
};
|
|
8080
8129
|
}
|
|
8130
|
+
if (shouldUpdateDiagnosticData(oldState, nextState)) {
|
|
8131
|
+
const visualDecorations = await getVisibleDiagnostics(finalState, finalState.diagnostics ?? []);
|
|
8132
|
+
finalState = {
|
|
8133
|
+
...finalState,
|
|
8134
|
+
visualDecorations
|
|
8135
|
+
};
|
|
8136
|
+
}
|
|
8081
8137
|
if (!shouldUpdateSelectionData(oldState, nextState)) {
|
|
8082
8138
|
return finalState;
|
|
8083
8139
|
}
|
|
@@ -13713,52 +13769,6 @@ const executeDiagnosticProvider = async editor => {
|
|
|
13713
13769
|
return executeIsolatedDiagnosticProvider(editor);
|
|
13714
13770
|
};
|
|
13715
13771
|
|
|
13716
|
-
const getDiagnosticType = diagnostic => {
|
|
13717
|
-
return diagnostic.type;
|
|
13718
|
-
};
|
|
13719
|
-
|
|
13720
|
-
const getY = (row, minLineY, rowHeight) => {
|
|
13721
|
-
return (row - minLineY) * rowHeight;
|
|
13722
|
-
};
|
|
13723
|
-
|
|
13724
|
-
const getVisibleDiagnostics = async (editor, diagnostics) => {
|
|
13725
|
-
const visibleDiagnostics = [];
|
|
13726
|
-
const {
|
|
13727
|
-
charWidth,
|
|
13728
|
-
fontFamily,
|
|
13729
|
-
fontSize,
|
|
13730
|
-
fontWeight,
|
|
13731
|
-
isMonospaceFont,
|
|
13732
|
-
letterSpacing,
|
|
13733
|
-
lines,
|
|
13734
|
-
minLineY,
|
|
13735
|
-
rowHeight,
|
|
13736
|
-
tabSize,
|
|
13737
|
-
width
|
|
13738
|
-
} = editor;
|
|
13739
|
-
for (const diagnostic of diagnostics) {
|
|
13740
|
-
const {
|
|
13741
|
-
columnIndex,
|
|
13742
|
-
endColumnIndex,
|
|
13743
|
-
rowIndex
|
|
13744
|
-
} = diagnostic;
|
|
13745
|
-
const columnDelta = endColumnIndex - columnIndex;
|
|
13746
|
-
const diagnosticWidth = columnDelta * charWidth;
|
|
13747
|
-
const endLineDifference = 0;
|
|
13748
|
-
const halfCursorWidth = 0;
|
|
13749
|
-
const x = await getX(lines[rowIndex], columnIndex, fontWeight, fontSize, fontFamily, isMonospaceFont, letterSpacing, tabSize, halfCursorWidth, width, charWidth, endLineDifference);
|
|
13750
|
-
const y = getY(rowIndex, minLineY, rowHeight);
|
|
13751
|
-
visibleDiagnostics.push({
|
|
13752
|
-
height: rowHeight,
|
|
13753
|
-
type: getDiagnosticType(diagnostic),
|
|
13754
|
-
width: diagnosticWidth,
|
|
13755
|
-
x,
|
|
13756
|
-
y
|
|
13757
|
-
});
|
|
13758
|
-
}
|
|
13759
|
-
return visibleDiagnostics;
|
|
13760
|
-
};
|
|
13761
|
-
|
|
13762
13772
|
/**
|
|
13763
13773
|
* Merges link decorations with diagnostic decorations
|
|
13764
13774
|
* Links should always be present, but we also need to include any diagnostic decorations
|