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
Generated
+1 -1
View File
@@ -2581,7 +2581,7 @@ dependencies = [
[[package]] [[package]]
name = "rustpad" name = "rustpad"
version = "0.2.44" version = "0.2.45"
dependencies = [ dependencies = [
"argon2", "argon2",
"aws-config", "aws-config",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "rustpad" name = "rustpad"
version = "0.2.44" version = "0.2.45"
edition = "2024" edition = "2024"
rust-version = "1.94" rust-version = "1.94"
description = "Collaborative Markdown notepad built with Axum, WebSockets and SQLite, PostgreSQL and MySQL" description = "Collaborative Markdown notepad built with Axum, WebSockets and SQLite, PostgreSQL and MySQL"
+6 -3
View File
@@ -1226,19 +1226,22 @@ export function startNoteEditor(adapter) {
} }
const previewSnapshot = previewEditSnapshot(); const previewSnapshot = previewEditSnapshot();
const previous = editor.value, start = editor.selectionStart, end = editor.selectionEnd, direction = editor.selectionDirection, scrollTop = editor.scrollTop, scrollLeft = editor.scrollLeft; 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; applyingRemote = true;
editor.value = content; editor.value = content;
authorship = adoptCurrentOwnerAliases(parseAuthorship(content, ownerMap), content.length); authorship = adoptCurrentOwnerAliases(parseAuthorship(content, ownerMap), content.length);
previousContent = content; previousContent = content;
editor.setSelectionRange(mapped.start, mapped.end, direction); editor.setSelectionRange(mapped.start, mapped.end, direction);
editor.scrollTop = scrollTop; editor.scrollTop = initialLoad ? 0 : scrollTop;
editor.scrollLeft = scrollLeft; editor.scrollLeft = scrollLeft;
applyingRemote = false; applyingRemote = false;
if (resetHistory) editHistory.reset(); if (resetHistory) editHistory.reset();
else editHistory.syncCurrent(); else editHistory.syncCurrent();
render(); render();
editor.scrollTop = scrollTop; editor.scrollTop = initialLoad ? 0 : scrollTop;
editor.scrollLeft = scrollLeft; editor.scrollLeft = scrollLeft;
syncEditorLayers(); syncEditorLayers();
restorePreviewEdit(previewSnapshot); restorePreviewEdit(previewSnapshot);