From 2d5f7ad47019b54fa1c2ef08cafb9b25f82a4ecc Mon Sep 17 00:00:00 2001 From: Hsieh Chin Fan Date: Wed, 9 Oct 2024 15:06:11 +0800 Subject: fix: proper timing to adjust scroll of HTML contents --- src/editor.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/editor.mjs b/src/editor.mjs index 55c6267..e39d97c 100644 --- a/src/editor.mjs +++ b/src/editor.mjs @@ -487,6 +487,8 @@ cm.on('focus', () => { }) cm.on('beforeChange', (_, change) => { + textArea.dataset.scrollLine = cm.getCursor().line + // Don't allow more content after YAML doc separator if (change.origin && change.origin.match(/^(\+input|paste)$/)) { const line = change.to.line @@ -830,7 +832,6 @@ const addSuggestions = (anchor, suggestions) => { cm.on('cursorActivity', _ => { menu.style.display = 'none' const anchor = cm.getCursor() - textArea.dataset.scrollLine = anchor.line if (insideCodeblockForMap(anchor)) { handleTypingInCodeBlock(anchor) -- cgit v1.2.3-70-g09d2