diff --git a/Cargo.lock b/Cargo.lock index ac73f4f..4993cd6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2581,7 +2581,7 @@ dependencies = [ [[package]] name = "rustpad" -version = "0.2.44" +version = "0.2.45" dependencies = [ "argon2", "aws-config", diff --git a/Cargo.toml b/Cargo.toml index a533243..b810024 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "rustpad" -version = "0.2.44" +version = "0.2.45" edition = "2024" rust-version = "1.94" description = "Collaborative Markdown notepad built with Axum, WebSockets and SQLite, PostgreSQL and MySQL" diff --git a/static/js/note-editor.js b/static/js/note-editor.js index eea5745..da20742 100644 --- a/static/js/note-editor.js +++ b/static/js/note-editor.js @@ -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);