@lvce-editor/editor-worker 19.72.3 → 19.72.4
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 +77 -6
- package/package.json +1 -1
package/dist/editorWorkerMain.js
CHANGED
|
@@ -5445,7 +5445,7 @@ const mergeConflictsEqual$1 = (oldState, newState) => {
|
|
|
5445
5445
|
return conflict.startRowIndex === other.startRowIndex && conflict.endRowIndex === other.endRowIndex;
|
|
5446
5446
|
});
|
|
5447
5447
|
};
|
|
5448
|
-
const updateDerivedState = async (oldState, newState) => {
|
|
5448
|
+
const updateDerivedState = async (oldState, newState, deferGutterDecorations = false) => {
|
|
5449
5449
|
const horizontalState = oldState.initial || oldState.lines !== newState.lines || oldState.width !== newState.width || oldState.charWidth !== newState.charWidth || oldState.fontFamily !== newState.fontFamily || oldState.fontSize !== newState.fontSize || oldState.fontWeight !== newState.fontWeight || oldState.isMonospaceFont !== newState.isMonospaceFont || oldState.letterSpacing !== newState.letterSpacing || oldState.tabSize !== newState.tabSize || oldState.lineNumbers !== newState.lineNumbers || oldState.breakPoints !== newState.breakPoints || oldState.gutterDecorations !== newState.gutterDecorations || oldState.lightBulbRowIndex !== newState.lightBulbRowIndex ? await updateHorizontalLayout(newState) : newState;
|
|
5450
5450
|
const layoutState = oldState.lines !== newState.lines && 'foldingRanges' in newState ? updateLayout(horizontalState, []) : horizontalState;
|
|
5451
5451
|
const nextState = mergeConflictsEqual$1(oldState, layoutState) ? layoutState : {
|
|
@@ -5513,7 +5513,7 @@ const updateDerivedState = async (oldState, newState) => {
|
|
|
5513
5513
|
lightBulbRowIndex: await getLightBulbRowIndex(finalState)
|
|
5514
5514
|
};
|
|
5515
5515
|
}
|
|
5516
|
-
if (oldState.lines !== nextState.lines || oldState.uri !== nextState.uri) {
|
|
5516
|
+
if (!deferGutterDecorations && (oldState.lines !== nextState.lines || oldState.uri !== nextState.uri)) {
|
|
5517
5517
|
finalState = {
|
|
5518
5518
|
...finalState,
|
|
5519
5519
|
gutterDecorations: await getEditorGutterDecorations(finalState)
|
|
@@ -6259,7 +6259,7 @@ const run = async (uid, token, save) => {
|
|
|
6259
6259
|
}
|
|
6260
6260
|
await save(token);
|
|
6261
6261
|
};
|
|
6262
|
-
const schedule = (uid, save) => {
|
|
6262
|
+
const schedule$1 = (uid, save) => {
|
|
6263
6263
|
dispose$4(uid);
|
|
6264
6264
|
const token = ++state$7.nextToken;
|
|
6265
6265
|
const timeout = setTimeout(run, autoSaveDelay, uid, token, save);
|
|
@@ -7900,6 +7900,70 @@ const editorDiagnosticEffect = {
|
|
|
7900
7900
|
isActive: (oldEditor, newEditor) => !oldEditor.initial && !newEditor.loadError && newEditor.diagnosticsEnabled && (oldEditor.lines !== newEditor.lines || oldEditor.languageId !== newEditor.languageId)
|
|
7901
7901
|
};
|
|
7902
7902
|
|
|
7903
|
+
const refreshes = new WeakMap();
|
|
7904
|
+
const isCurrent = (editor, snapshot) => Boolean(editor && editor.lifecycle === snapshot.lifecycle && !editor.lifecycle?.disposed && editor.lines === snapshot.lines && editor.gutterDecorations === snapshot.gutterDecorations && editor.uri === snapshot.uri && editor.languageId === snapshot.languageId && editor.applicationId === snapshot.applicationId);
|
|
7905
|
+
const refresh = async request => {
|
|
7906
|
+
try {
|
|
7907
|
+
while (request.pending) {
|
|
7908
|
+
const snapshot = request.pending;
|
|
7909
|
+
request.pending = undefined;
|
|
7910
|
+
if (snapshot.lifecycle?.disposed) {
|
|
7911
|
+
continue;
|
|
7912
|
+
}
|
|
7913
|
+
const gutterDecorations = await getEditorGutterDecorations(snapshot);
|
|
7914
|
+
const changed = await enqueue(snapshot.uid, async () => {
|
|
7915
|
+
const current = get$8(snapshot.uid)?.newState;
|
|
7916
|
+
if (!isCurrent(current, snapshot) || current.gutterDecorations.length === gutterDecorations.length && gutterDecorations.every((item, index) => item.rowIndex === current.gutterDecorations[index].rowIndex && item.type === current.gutterDecorations[index].type)) {
|
|
7917
|
+
return false;
|
|
7918
|
+
}
|
|
7919
|
+
const next = await updateDerivedState(current, {
|
|
7920
|
+
...current,
|
|
7921
|
+
gutterDecorations
|
|
7922
|
+
});
|
|
7923
|
+
// Derived state may await layout RPCs while an asynchronous render consumes the baseline.
|
|
7924
|
+
const latest = get$8(snapshot.uid);
|
|
7925
|
+
if (!isCurrent(latest?.newState, snapshot)) {
|
|
7926
|
+
return false;
|
|
7927
|
+
}
|
|
7928
|
+
set$a(snapshot.uid, latest.oldState, next);
|
|
7929
|
+
return true;
|
|
7930
|
+
});
|
|
7931
|
+
if (changed) {
|
|
7932
|
+
await invoke$d('Editor.renderPending', snapshot.uid);
|
|
7933
|
+
}
|
|
7934
|
+
}
|
|
7935
|
+
} catch (error) {
|
|
7936
|
+
console.warn('Failed to refresh gutter decorations:', error);
|
|
7937
|
+
} finally {
|
|
7938
|
+
request.running = false;
|
|
7939
|
+
if (request.pending) {
|
|
7940
|
+
request.running = true;
|
|
7941
|
+
void refresh(request);
|
|
7942
|
+
}
|
|
7943
|
+
}
|
|
7944
|
+
};
|
|
7945
|
+
const schedule = editor => {
|
|
7946
|
+
const {
|
|
7947
|
+
lifecycle
|
|
7948
|
+
} = editor;
|
|
7949
|
+
if (!lifecycle || lifecycle.disposed) {
|
|
7950
|
+
return;
|
|
7951
|
+
}
|
|
7952
|
+
let request = refreshes.get(lifecycle);
|
|
7953
|
+
if (!request) {
|
|
7954
|
+
request = {
|
|
7955
|
+
pending: undefined,
|
|
7956
|
+
running: false
|
|
7957
|
+
};
|
|
7958
|
+
refreshes.set(lifecycle, request);
|
|
7959
|
+
}
|
|
7960
|
+
request.pending = editor;
|
|
7961
|
+
if (!request.running) {
|
|
7962
|
+
request.running = true;
|
|
7963
|
+
void refresh(request);
|
|
7964
|
+
}
|
|
7965
|
+
};
|
|
7966
|
+
|
|
7903
7967
|
const cursorUndoLimit = 100;
|
|
7904
7968
|
const selectionsEqual = (left, right) => {
|
|
7905
7969
|
if (left === right) {
|
|
@@ -7983,7 +8047,8 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
7983
8047
|
if (state === newEditor) {
|
|
7984
8048
|
return returnState ? newEditor : undefined;
|
|
7985
8049
|
}
|
|
7986
|
-
const
|
|
8050
|
+
const deferGutterDecorations = !initial && uri === newEditor.uri && lines !== newEditor.lines && Boolean(newEditor.lifecycle);
|
|
8051
|
+
const newEditorWithDerivedState = await updateDerivedState(state, newEditor, deferGutterDecorations);
|
|
7987
8052
|
// Another command can commit before the renderer consumes this edit.
|
|
7988
8053
|
// Keep its last rendered baseline, including renders completed while we awaited derived state.
|
|
7989
8054
|
const renderedState = get$8(uid)?.oldState ?? oldInstance.oldState;
|
|
@@ -7993,6 +8058,9 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
7993
8058
|
void editorDiagnosticEffect.apply(newEditorWithDerivedState);
|
|
7994
8059
|
}
|
|
7995
8060
|
const finalEditor = newEditorWithDerivedState;
|
|
8061
|
+
if (deferGutterDecorations) {
|
|
8062
|
+
schedule(finalEditor);
|
|
8063
|
+
}
|
|
7996
8064
|
await notifyEditorStatusChange(state, finalEditor);
|
|
7997
8065
|
if (!initial && uri === finalEditor.uri && (endOfLine !== finalEditor.endOfLine || insertSpaces !== finalEditor.insertSpaces || lines !== finalEditor.lines || modified !== finalEditor.modified || redoStack !== finalEditor.redoStack || undoStack !== finalEditor.undoStack)) {
|
|
7998
8066
|
for (const key of getKeys$2()) {
|
|
@@ -8015,15 +8083,18 @@ const wrapCommand$1 = (fn, preservesTypingCoalescing = false, returnState = true
|
|
|
8015
8083
|
redoStack: finalEditor.redoStack,
|
|
8016
8084
|
undoStack: finalEditor.undoStack,
|
|
8017
8085
|
visualDecorations: finalEditor.visualDecorations
|
|
8018
|
-
});
|
|
8086
|
+
}, deferGutterDecorations);
|
|
8019
8087
|
set$a(otherUid, instance.oldState, synchronizedEditor);
|
|
8088
|
+
if (deferGutterDecorations) {
|
|
8089
|
+
schedule(synchronizedEditor);
|
|
8090
|
+
}
|
|
8020
8091
|
if (editorDiagnosticEffect.isActive(editor, synchronizedEditor)) {
|
|
8021
8092
|
void editorDiagnosticEffect.apply(synchronizedEditor);
|
|
8022
8093
|
}
|
|
8023
8094
|
}
|
|
8024
8095
|
}
|
|
8025
8096
|
if (lines !== finalEditor.lines && !isUntitledFile(finalEditor.uri)) {
|
|
8026
|
-
schedule(uid, token => saveAfterDelay(uid, token));
|
|
8097
|
+
schedule$1(uid, token => saveAfterDelay(uid, token));
|
|
8027
8098
|
} else if (modified && !finalEditor.modified) {
|
|
8028
8099
|
dispose$4(uid);
|
|
8029
8100
|
}
|