@lvce-editor/editor-worker 19.26.1 → 19.26.3

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.
@@ -11078,7 +11078,7 @@ const getSourceActions = async editorUid => {
11078
11078
  const actions = await getEditorSourceActions(editorUid);
11079
11079
  return actions;
11080
11080
  };
11081
- const getDiagnostics$2 = async editorUid => {
11081
+ const getDiagnostics$1 = async editorUid => {
11082
11082
  const editor = getEditor(editorUid);
11083
11083
  const {
11084
11084
  diagnostics
@@ -11566,54 +11566,14 @@ const getMenuIds = () => {
11566
11566
  return [Editor$1];
11567
11567
  };
11568
11568
 
11569
- const getTextDocument = editor => {
11570
- return {
11571
- documentId: editor.id || editor.uid,
11572
- languageId: editor.languageId,
11573
- text: getText$1(editor),
11574
- uri: editor.uri
11575
- };
11576
- };
11577
- const executeIsolatedDiagnosticProvider = async editor => {
11578
- const textDocument = getTextDocument(editor);
11579
- return invoke$e('Extensions.executeDiagnosticProvider', textDocument);
11580
- };
11581
- const executeDiagnosticProvider = async editor => {
11582
- const isolatedDiagnostics = await executeIsolatedDiagnosticProvider(editor);
11583
- if (isolatedDiagnostics.length > 0) {
11584
- return isolatedDiagnostics;
11585
- }
11586
- const {
11587
- assetDir,
11588
- platform
11589
- } = editor;
11590
- return execute({
11591
- args: [],
11592
- assetDir,
11593
- editor,
11594
- event: OnDiagnostic,
11595
- method: 'ExtensionHost.executeDiagnosticProvider',
11596
- noProviderFoundMessage: 'no diagnostic provider found',
11597
- platform
11598
- });
11599
- };
11600
-
11601
- const getDiagnostics$1 = editor => {
11602
- return executeDiagnosticProvider(editor);
11603
- };
11604
11569
  const getProblems = async () => {
11605
- // TODO maybe combine querying diagnostics for problems view with diagnostics for editor
11606
- // or query the diagnostics for the problems view directtly from the extension host worker
11607
11570
  const keys = getKeys$2();
11608
- const editors = keys.map(key => {
11571
+ const diagnostics = keys.flatMap(key => {
11609
11572
  const numericKey = Number(key);
11610
11573
  const editor = get$7(numericKey);
11611
- return editor;
11574
+ return editor.newState.diagnostics;
11612
11575
  });
11613
- const newEditors = editors.map(editor => editor.newState);
11614
- const diagnostics = await Promise.all(newEditors.map(getDiagnostics$1));
11615
- const flatDiagnostics = diagnostics.flat();
11616
- return flatDiagnostics;
11576
+ return diagnostics;
11617
11577
  };
11618
11578
 
11619
11579
  const getQuickPickMenuEntries = () => {
@@ -13227,6 +13187,38 @@ const updateDebugInfo = async debugId => {
13227
13187
  await invoke$b('Editor.rerender', key);
13228
13188
  };
13229
13189
 
13190
+ const getTextDocument = editor => {
13191
+ return {
13192
+ documentId: editor.id || editor.uid,
13193
+ languageId: editor.languageId,
13194
+ text: getText$1(editor),
13195
+ uri: editor.uri
13196
+ };
13197
+ };
13198
+ const executeIsolatedDiagnosticProvider = async editor => {
13199
+ const textDocument = getTextDocument(editor);
13200
+ return invoke$e('Extensions.executeDiagnosticProvider', textDocument);
13201
+ };
13202
+ const executeDiagnosticProvider = async editor => {
13203
+ const isolatedDiagnostics = await executeIsolatedDiagnosticProvider(editor);
13204
+ if (isolatedDiagnostics.length > 0) {
13205
+ return isolatedDiagnostics;
13206
+ }
13207
+ const {
13208
+ assetDir,
13209
+ platform
13210
+ } = editor;
13211
+ return execute({
13212
+ args: [],
13213
+ assetDir,
13214
+ editor,
13215
+ event: OnDiagnostic,
13216
+ method: 'ExtensionHost.executeDiagnosticProvider',
13217
+ noProviderFoundMessage: 'no diagnostic provider found',
13218
+ platform
13219
+ });
13220
+ };
13221
+
13230
13222
  const getDiagnosticType = diagnostic => {
13231
13223
  return diagnostic.type;
13232
13224
  };
@@ -13346,6 +13338,15 @@ const updateDiagnostics = async editor => {
13346
13338
  }
13347
13339
  };
13348
13340
 
13341
+ const editorDiagnosticEffect = {
13342
+ // TODO set effects delay / diagnostic delay
13343
+ apply(editor) {
13344
+ return updateDiagnostics(editor);
13345
+ },
13346
+ // TODO avoid slow comparison
13347
+ isActive: (oldEditor, newEditor) => newEditor.diagnosticsEnabled && JSON.stringify(oldEditor.lines) !== JSON.stringify(newEditor.lines)
13348
+ };
13349
+
13349
13350
  const queues = [];
13350
13351
 
13351
13352
  // TODO wrap commands globally, not per editor
@@ -13370,7 +13371,15 @@ const wrapCommand = fn => async (uid, ...args) => {
13370
13371
  }
13371
13372
  const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
13372
13373
  set$9(uid, state, newEditorWithDerivedState);
13373
- return newEditorWithDerivedState;
13374
+ if (!editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
13375
+ return newEditorWithDerivedState;
13376
+ }
13377
+ const newEditorWithDiagnostics = await editorDiagnosticEffect.apply(newEditorWithDerivedState);
13378
+ if (!get$7(uid)) {
13379
+ return newEditorWithDiagnostics;
13380
+ }
13381
+ set$9(uid, state, newEditorWithDiagnostics);
13382
+ return newEditorWithDiagnostics;
13374
13383
  } finally {
13375
13384
  resolve();
13376
13385
  if (queues[uid] === next) {
@@ -13445,7 +13454,7 @@ const commandMap = {
13445
13454
  'Editor.fold': wrapCommand(fold$1),
13446
13455
  'Editor.format': wrapCommand(format),
13447
13456
  'Editor.getCommandIds': getCommandIds,
13448
- 'Editor.getDiagnostics': getDiagnostics$2,
13457
+ 'Editor.getDiagnostics': getDiagnostics$1,
13449
13458
  'Editor.getKeyBindings': getKeyBindings,
13450
13459
  'Editor.getKeys': getKeys$1,
13451
13460
  'Editor.getLanguageId': getLanguageId,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.26.1",
3
+ "version": "19.26.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"