@lvce-editor/editor-worker 19.73.0 → 19.73.1
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 +40 -3
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -7189,6 +7189,43 @@ const {
|
|
|
7189
7189
|
setFactory
|
|
7190
7190
|
} = createLazyRpc(CompletionWorker);
|
|
7191
7191
|
|
|
7192
|
+
// These commits preserve the document, selection, layout, widgets and lifecycle.
|
|
7193
|
+
const diagnosticFields = new Set(['decorations', 'diagnostics', 'lightBulbRowIndex', 'visualDecorations']);
|
|
7194
|
+
const isCurrent$1 = (snapshot, current) => {
|
|
7195
|
+
if (!current || current.lifecycle?.disposed) {
|
|
7196
|
+
return false;
|
|
7197
|
+
}
|
|
7198
|
+
if (snapshot === current) {
|
|
7199
|
+
return true;
|
|
7200
|
+
}
|
|
7201
|
+
const keys = new Set([...Object.keys(snapshot), ...Object.keys(current)]);
|
|
7202
|
+
for (const key of keys) {
|
|
7203
|
+
if (diagnosticFields.has(key)) {
|
|
7204
|
+
continue;
|
|
7205
|
+
}
|
|
7206
|
+
const field = key;
|
|
7207
|
+
if (Object.hasOwn(snapshot, field) !== Object.hasOwn(current, field) || snapshot[field] !== current[field]) {
|
|
7208
|
+
return false;
|
|
7209
|
+
}
|
|
7210
|
+
}
|
|
7211
|
+
return true;
|
|
7212
|
+
};
|
|
7213
|
+
const merge = (current, snapshot, result) => {
|
|
7214
|
+
if (!isCurrent$1(snapshot, current) || result === snapshot || result === current) {
|
|
7215
|
+
return current;
|
|
7216
|
+
}
|
|
7217
|
+
if (current === snapshot) {
|
|
7218
|
+
return result;
|
|
7219
|
+
}
|
|
7220
|
+
return {
|
|
7221
|
+
...result,
|
|
7222
|
+
decorations: current.decorations,
|
|
7223
|
+
diagnostics: current.diagnostics,
|
|
7224
|
+
lightBulbRowIndex: current.lightBulbRowIndex,
|
|
7225
|
+
visualDecorations: current.visualDecorations
|
|
7226
|
+
};
|
|
7227
|
+
};
|
|
7228
|
+
|
|
7192
7229
|
const updateWidget = (editor, widgetId, newState) => {
|
|
7193
7230
|
// TODO avoid closure
|
|
7194
7231
|
const isWidget = widget => {
|
|
@@ -7255,7 +7292,7 @@ const openCompletion = async (editor, automatic = false) => {
|
|
|
7255
7292
|
uid
|
|
7256
7293
|
} = widget.newState;
|
|
7257
7294
|
await invoke$4('Completions.loadContent', uid, automatic);
|
|
7258
|
-
if (get$8(editor.uid)?.newState
|
|
7295
|
+
if (!isCurrent$1(editor, get$8(editor.uid)?.newState)) {
|
|
7259
7296
|
return get$8(editor.uid)?.newState || editor;
|
|
7260
7297
|
}
|
|
7261
7298
|
if (automatic && !(await invoke$4('Completions.hasItems', uid))) {
|
|
@@ -7289,7 +7326,7 @@ const openCompletion = async (editor, automatic = false) => {
|
|
|
7289
7326
|
const result = await addWidgetToEditor(Completion, EditorCompletion, editor, create$7, generateState, fullFocus);
|
|
7290
7327
|
const wasAdded = (result?.widgets || []).some(widget => widget.id === Completion && widget.newState.uid === completionUid);
|
|
7291
7328
|
const currentEditor = get$8(editor.uid)?.newState;
|
|
7292
|
-
if (created && (!wasAdded || currentEditor
|
|
7329
|
+
if (created && (!wasAdded || !isCurrent$1(editor, currentEditor))) {
|
|
7293
7330
|
await disposeCompletion(completionUid);
|
|
7294
7331
|
}
|
|
7295
7332
|
return result;
|
|
@@ -8563,7 +8600,7 @@ const wrapFocusCommand$1 = (fn, returnState = true) => {
|
|
|
8563
8600
|
|
|
8564
8601
|
// Optional provider work must not hold the editing queue while another worker responds.
|
|
8565
8602
|
const wrapDeferredCommand$1 = (fn, returnState = true) => {
|
|
8566
|
-
const apply = wrapCommand$1((editor, snapshot, result) => editor
|
|
8603
|
+
const apply = wrapCommand$1((editor, snapshot, result) => merge(editor, snapshot, result), false, returnState);
|
|
8567
8604
|
return async (uid, ...args) => {
|
|
8568
8605
|
const snapshot = await enqueue(uid, async () => get$8(uid)?.newState);
|
|
8569
8606
|
if (!snapshot) {
|