@lvce-editor/editor-worker 19.55.1 → 19.55.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.
@@ -5750,10 +5750,14 @@ const diff = (oldState, newState) => {
5750
5750
  };
5751
5751
 
5752
5752
  const diff2 = uid => {
5753
+ const editor = get$8(uid);
5754
+ if (!editor) {
5755
+ return [];
5756
+ }
5753
5757
  const {
5754
5758
  newState,
5755
5759
  oldState
5756
- } = get$8(uid);
5760
+ } = editor;
5757
5761
  const result = diff(oldState, newState);
5758
5762
  return result;
5759
5763
  };
@@ -6443,6 +6447,10 @@ const getNewEditor = async editor => {
6443
6447
  return editor;
6444
6448
  };
6445
6449
 
6450
+ const isReadonlyFile = async uri => {
6451
+ return invoke$a('FileSystem.isReadonly', uri);
6452
+ };
6453
+
6446
6454
  const isUntitledFile = uri => {
6447
6455
  return uri.startsWith('untitled:');
6448
6456
  };
@@ -6505,6 +6513,9 @@ const save = async editor => {
6505
6513
  platform,
6506
6514
  uri
6507
6515
  } = editor;
6516
+ if (!isUntitledFile(uri) && (await isReadonlyFile(uri))) {
6517
+ return editor;
6518
+ }
6508
6519
  const newEditor = await getNewEditor(editor);
6509
6520
  const content = applyLineEndings(getText$1(newEditor), newEditor.endOfLine);
6510
6521
  if (isUntitledFile(uri)) {
@@ -15762,10 +15773,14 @@ const applyRender = (oldState, newState, diffResult) => {
15762
15773
  };
15763
15774
 
15764
15775
  const render2 = (uid, diffResult) => {
15776
+ const editor = get$8(uid);
15777
+ if (!editor) {
15778
+ return [];
15779
+ }
15765
15780
  const {
15766
15781
  newState,
15767
15782
  oldState
15768
- } = get$8(uid);
15783
+ } = editor;
15769
15784
  set$8(uid, newState, newState);
15770
15785
  const commands = applyRender(oldState, newState, diffResult);
15771
15786
  return commands;
@@ -16143,17 +16158,22 @@ const updateDiagnostics = async editor => {
16143
16158
  try {
16144
16159
  const diagnostics = await getDiagnostics(editor);
16145
16160
  const latest = get$8(editor.id);
16146
- if (!latest) {
16161
+ if (!latest || !latest.newState.diagnosticsEnabled || latest.newState.lines !== editor.lines || latest.newState.uri !== editor.uri) {
16147
16162
  return editor;
16148
16163
  }
16149
16164
  const newEditor = await addDiagnostics(latest.newState, diagnostics);
16150
16165
  set$8(editor.id, latest.oldState, newEditor);
16166
+ await invoke$7('Editor.renderPending', newEditor.id);
16151
16167
  await notifyDiagnosticsChange(newEditor.uri);
16152
16168
  return newEditor;
16153
16169
  } catch (error) {
16154
16170
  return handleError(error, editor);
16155
16171
  }
16156
16172
  };
16173
+ const requestDiagnostics = editor => {
16174
+ void updateDiagnostics(editor);
16175
+ return editor;
16176
+ };
16157
16177
  const updateDiagnosticsAll = async () => {
16158
16178
  for (const key of getKeys$2()) {
16159
16179
  const editor = get$8(Number(key))?.newState;
@@ -16217,6 +16237,9 @@ const saveAfterDelay = async (uid, token) => {
16217
16237
 
16218
16238
  const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...args) => {
16219
16239
  const initialInstance = get$8(uid);
16240
+ if (!initialInstance) {
16241
+ return undefined;
16242
+ }
16220
16243
  const queueKey = initialInstance?.newState.uri || uid;
16221
16244
  const previous = queues[queueKey];
16222
16245
  const {
@@ -16229,6 +16252,9 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
16229
16252
  }
16230
16253
  try {
16231
16254
  const oldInstance = get$8(uid);
16255
+ if (!oldInstance) {
16256
+ return undefined;
16257
+ }
16232
16258
  const state = oldInstance.newState;
16233
16259
  const {
16234
16260
  cursorUndoStack,
@@ -16265,14 +16291,10 @@ const wrapCommand = (fn, preservesTypingCoalescing = false) => async (uid, ...ar
16265
16291
  }
16266
16292
  const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
16267
16293
  set$8(uid, state, newEditorWithDerivedState);
16268
- let finalEditor = newEditorWithDerivedState;
16269
16294
  if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
16270
- finalEditor = await editorDiagnosticEffect.apply(newEditorWithDerivedState);
16271
- if (!get$8(uid)) {
16272
- return finalEditor;
16273
- }
16274
- set$8(uid, state, finalEditor);
16295
+ void editorDiagnosticEffect.apply(newEditorWithDerivedState);
16275
16296
  }
16297
+ const finalEditor = newEditorWithDerivedState;
16276
16298
  await notifyEditorStatusChange(state, finalEditor);
16277
16299
  if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
16278
16300
  for (const key of getKeys$2()) {
@@ -16536,7 +16558,7 @@ const commandMap = {
16536
16558
  'Editor.unIndent': wrapCommand(editorUnindent),
16537
16559
  'Editor.updateColorPickerValue': wrapCommand(updateColorPickerValue$1),
16538
16560
  'Editor.updateDebugInfo': updateDebugInfo,
16539
- 'Editor.updateDiagnostics': wrapCommand(updateDiagnostics),
16561
+ 'Editor.updateDiagnostics': wrapCommand(requestDiagnostics),
16540
16562
  'Editor.updateDiagnosticsAll': updateDiagnosticsAll,
16541
16563
  'EditorCompletion.close': close$3,
16542
16564
  'EditorCompletion.closeDetails': closeDetails$1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/editor-worker",
3
- "version": "19.55.1",
3
+ "version": "19.55.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:lvce-editor/editor-worker.git"