@lvce-editor/editor-worker 19.56.1 → 19.57.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.
@@ -15996,17 +15996,55 @@ const notifyDiagnosticsChange = async uri => {
15996
15996
  // Older renderer workers do not support diagnostics change listeners.
15997
15997
  }
15998
15998
  };
15999
+ const diagnosticsEqual = (left, right) => {
16000
+ if (left === right) {
16001
+ return true;
16002
+ }
16003
+ if ((left?.length ?? 0) !== right.length) {
16004
+ return false;
16005
+ }
16006
+ return right.every((diagnostic, index) => {
16007
+ const other = left[index];
16008
+ 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;
16009
+ });
16010
+ };
16011
+ 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;
16012
+ const isApplicable = (latest, editor) => latest && latest.newState.diagnosticsEnabled && latest.newState.lines === editor.lines && latest.newState.uri === editor.uri;
16013
+ const mergeDiagnostics = (editor, editorWithDiagnostics) => ({
16014
+ ...editor,
16015
+ decorations: editorWithDiagnostics.decorations,
16016
+ diagnostics: editorWithDiagnostics.diagnostics,
16017
+ lightBulbRowIndex: editorWithDiagnostics.lightBulbRowIndex,
16018
+ visualDecorations: editorWithDiagnostics.visualDecorations
16019
+ });
15999
16020
  const updateDiagnostics = async editor => {
16000
16021
  if (!editor.diagnosticsEnabled) {
16001
16022
  return editor;
16002
16023
  }
16003
16024
  try {
16004
16025
  const diagnostics = await getDiagnostics(editor);
16005
- const latest = get$8(editor.id);
16006
- if (!latest || !latest.newState.diagnosticsEnabled || latest.newState.lines !== editor.lines || latest.newState.uri !== editor.uri) {
16026
+ let latest = get$8(editor.id);
16027
+ if (!isApplicable(latest, editor)) {
16028
+ return editor;
16029
+ }
16030
+ if (diagnosticsEqual(latest.newState.diagnostics, diagnostics)) {
16031
+ return latest.newState;
16032
+ }
16033
+ let calculationState = latest.newState;
16034
+ let editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
16035
+ latest = get$8(editor.id);
16036
+ while (isApplicable(latest, editor) && !diagnosticLayoutEqual(calculationState, latest.newState)) {
16037
+ calculationState = latest.newState;
16038
+ editorWithDiagnostics = await addDiagnostics(calculationState, diagnostics);
16039
+ latest = get$8(editor.id);
16040
+ }
16041
+ if (!isApplicable(latest, editor)) {
16007
16042
  return editor;
16008
16043
  }
16009
- const newEditor = await addDiagnostics(latest.newState, diagnostics);
16044
+ if (diagnosticsEqual(latest.newState.diagnostics, diagnostics)) {
16045
+ return latest.newState;
16046
+ }
16047
+ const newEditor = mergeDiagnostics(latest.newState, editorWithDiagnostics);
16010
16048
  set$8(editor.id, latest.oldState, newEditor);
16011
16049
  await invoke$7('Editor.renderPending', newEditor.id);
16012
16050
  await notifyDiagnosticsChange(newEditor.uri);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.56.1",
3
+ "version": "19.57.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"