-
-
Notifications
You must be signed in to change notification settings - Fork 472
scrollIntoView possibly off-by-1 line #53
Copy link
Copy link
Closed
Description
Greetings,
I'm working on a demo where you can switch between views, and your previous cursor position should be scrolled into view. The scrollIntoView transaction does scroll the view, but it scrolls to the line above the line that should be scrolled into view.
For example if the cursor is on line 70, it scrolls the viewport such that the line on the bottom is line 69.
This is the snippet of code I'm using to dispatch the transaction (inspired by test-builtin-commands.ts):
const cursorPosition = view.state.selection.primary.anchor;
view.dispatch(view.state.transaction
.setSelection(view.state.selection.constructor.single(cursorPosition))
.scrollIntoView());It also seems to do the same thing if I omit that second line:
view.dispatch(view.state.transaction.scrollIntoView());To reproduce, run the demo found here in this branch: vizhub-studio/codemirror-6-experiments#20
- Switch to
index.js - Put your cursor somewhere scrolled down
- Switch to another file
- Switch back to
index.js - Observe it has scrolled into view the line one less than the desired line.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
