cursor focus

This commit is contained in:
Mateusz Gruszczyński
2026-08-06 00:21:21 +02:00
parent a7329f5535
commit 1e80fb2bcb
3 changed files with 8 additions and 5 deletions
+6 -3
View File
@@ -1226,19 +1226,22 @@ export function startNoteEditor(adapter) {
}
const previewSnapshot = previewEditSnapshot();
const previous = editor.value, start = editor.selectionStart, end = editor.selectionEnd, direction = editor.selectionDirection, scrollTop = editor.scrollTop, scrollLeft = editor.scrollLeft;
const mapped = mapSelectionThroughEdit(previous, content, start, end);
const initialLoad = editHistory.index < 0;
const mapped = initialLoad
? { start: 0, end: 0 }
: mapSelectionThroughEdit(previous, content, start, end);
applyingRemote = true;
editor.value = content;
authorship = adoptCurrentOwnerAliases(parseAuthorship(content, ownerMap), content.length);
previousContent = content;
editor.setSelectionRange(mapped.start, mapped.end, direction);
editor.scrollTop = scrollTop;
editor.scrollTop = initialLoad ? 0 : scrollTop;
editor.scrollLeft = scrollLeft;
applyingRemote = false;
if (resetHistory) editHistory.reset();
else editHistory.syncCurrent();
render();
editor.scrollTop = scrollTop;
editor.scrollTop = initialLoad ? 0 : scrollTop;
editor.scrollLeft = scrollLeft;
syncEditorLayers();
restorePreviewEdit(previewSnapshot);