@lvce-editor/editor-worker 19.27.1 → 19.27.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 +61 -15
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -12182,9 +12182,19 @@ const loadContent = async (state, savedState) => {
|
|
|
12182
12182
|
tabSize,
|
|
12183
12183
|
tokenizerId: newTokenizerId
|
|
12184
12184
|
};
|
|
12185
|
-
let
|
|
12185
|
+
let existingEditor;
|
|
12186
|
+
for (const key of getKeys$2()) {
|
|
12187
|
+
const editor = get$7(Number(key))?.newState;
|
|
12188
|
+
if (editor && editor.id !== id && !editor.initial && editor.uri === uri) {
|
|
12189
|
+
existingEditor = editor;
|
|
12190
|
+
break;
|
|
12191
|
+
}
|
|
12192
|
+
}
|
|
12193
|
+
let content = existingEditor ? getText$1(existingEditor) : '';
|
|
12186
12194
|
try {
|
|
12187
|
-
|
|
12195
|
+
if (!existingEditor) {
|
|
12196
|
+
content = await readFile(uri);
|
|
12197
|
+
}
|
|
12188
12198
|
} catch (error) {
|
|
12189
12199
|
const newEditor1 = setBounds(newEditor0, x, y, width, height, 9);
|
|
12190
12200
|
return {
|
|
@@ -12231,7 +12241,10 @@ const loadContent = async (state, savedState) => {
|
|
|
12231
12241
|
const newEditor5 = {
|
|
12232
12242
|
...newEditor4,
|
|
12233
12243
|
completionsOnType,
|
|
12234
|
-
initial: false
|
|
12244
|
+
initial: false,
|
|
12245
|
+
modified: existingEditor?.modified || false,
|
|
12246
|
+
redoStack: existingEditor?.redoStack || [],
|
|
12247
|
+
undoStack: existingEditor?.undoStack || []
|
|
12235
12248
|
};
|
|
12236
12249
|
return newEditor5;
|
|
12237
12250
|
};
|
|
@@ -13463,18 +13476,20 @@ const editorDiagnosticEffect = {
|
|
|
13463
13476
|
isActive: (oldEditor, newEditor) => newEditor.diagnosticsEnabled && JSON.stringify(oldEditor.lines) !== JSON.stringify(newEditor.lines)
|
|
13464
13477
|
};
|
|
13465
13478
|
|
|
13466
|
-
const queues =
|
|
13479
|
+
const queues = {};
|
|
13467
13480
|
|
|
13468
13481
|
// TODO wrap commands globally, not per editor
|
|
13469
13482
|
// TODO only store editor state in editor worker, not in renderer worker also
|
|
13470
13483
|
|
|
13471
13484
|
const wrapCommand = fn => async (uid, ...args) => {
|
|
13472
|
-
const
|
|
13485
|
+
const initialInstance = get$7(uid);
|
|
13486
|
+
const queueKey = initialInstance?.newState.uri || uid;
|
|
13487
|
+
const previous = queues[queueKey];
|
|
13473
13488
|
const {
|
|
13474
13489
|
promise: next,
|
|
13475
13490
|
resolve
|
|
13476
13491
|
} = Promise.withResolvers();
|
|
13477
|
-
queues[
|
|
13492
|
+
queues[queueKey] = next;
|
|
13478
13493
|
if (previous) {
|
|
13479
13494
|
await previous;
|
|
13480
13495
|
}
|
|
@@ -13487,19 +13502,50 @@ const wrapCommand = fn => async (uid, ...args) => {
|
|
|
13487
13502
|
}
|
|
13488
13503
|
const newEditorWithDerivedState = await updateDerivedState(state, newEditor);
|
|
13489
13504
|
set$9(uid, state, newEditorWithDerivedState);
|
|
13490
|
-
|
|
13491
|
-
|
|
13505
|
+
let finalEditor = newEditorWithDerivedState;
|
|
13506
|
+
if (editorDiagnosticEffect.isActive(state, newEditorWithDerivedState)) {
|
|
13507
|
+
finalEditor = await editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
13508
|
+
if (!get$7(uid)) {
|
|
13509
|
+
return finalEditor;
|
|
13510
|
+
}
|
|
13511
|
+
set$9(uid, state, finalEditor);
|
|
13492
13512
|
}
|
|
13493
|
-
const
|
|
13494
|
-
|
|
13495
|
-
|
|
13513
|
+
const {
|
|
13514
|
+
initial,
|
|
13515
|
+
lines,
|
|
13516
|
+
modified,
|
|
13517
|
+
redoStack,
|
|
13518
|
+
undoStack,
|
|
13519
|
+
uri
|
|
13520
|
+
} = state;
|
|
13521
|
+
if (!initial && uri === finalEditor.uri && (lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
13522
|
+
for (const key of getKeys$2()) {
|
|
13523
|
+
const otherUid = Number(key);
|
|
13524
|
+
const instance = get$7(otherUid);
|
|
13525
|
+
const editor = instance?.newState;
|
|
13526
|
+
if (otherUid === uid || !instance || !editor || editor.initial || editor.uri !== finalEditor.uri) {
|
|
13527
|
+
continue;
|
|
13528
|
+
}
|
|
13529
|
+
const synchronizedEditor = await updateDerivedState(editor, {
|
|
13530
|
+
...editor,
|
|
13531
|
+
decorations: finalEditor.decorations,
|
|
13532
|
+
diagnostics: finalEditor.diagnostics,
|
|
13533
|
+
incrementalEdits: emptyIncrementalEdits,
|
|
13534
|
+
invalidStartIndex: Math.min(editor.invalidStartIndex, finalEditor.invalidStartIndex),
|
|
13535
|
+
lines: finalEditor.lines,
|
|
13536
|
+
modified: finalEditor.modified,
|
|
13537
|
+
redoStack: finalEditor.redoStack,
|
|
13538
|
+
undoStack: finalEditor.undoStack,
|
|
13539
|
+
visualDecorations: finalEditor.visualDecorations
|
|
13540
|
+
});
|
|
13541
|
+
set$9(otherUid, instance.oldState, synchronizedEditor);
|
|
13542
|
+
}
|
|
13496
13543
|
}
|
|
13497
|
-
|
|
13498
|
-
return newEditorWithDiagnostics;
|
|
13544
|
+
return finalEditor;
|
|
13499
13545
|
} finally {
|
|
13500
13546
|
resolve();
|
|
13501
|
-
if (queues[
|
|
13502
|
-
queues[
|
|
13547
|
+
if (queues[queueKey] === next) {
|
|
13548
|
+
delete queues[queueKey];
|
|
13503
13549
|
}
|
|
13504
13550
|
}
|
|
13505
13551
|
};
|