Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How do I scroll the editor to a position, not just a line? #2739

Closed
STRd6 opened this issue Oct 30, 2015 · 4 comments
Closed

How do I scroll the editor to a position, not just a line? #2739

STRd6 opened this issue Oct 30, 2015 · 4 comments

Comments

@STRd6
Copy link

STRd6 commented Oct 30, 2015

I'm using Ace for a collaborative editing experience and I want to be able to scroll to another user's cursor position.

I see that there are editor.scrollToRow(), and editor.scrollToLine() methods, but I can't seem to find any method that works with a cursor object that has position and selectionEnd properties.

What I'd like is to be able to scroll to a position, not just a line. Or if there is a way to convert a position to a line that would be helpful too.

Thanks!

@nightwing
Copy link
Member

Position is an object like {row, column} so getting a line from it is easy by using position.row.
You can also use
editor.renderer.scrollCursorIntoView({row: 50, column: 1}, 0.5) (0.5 centers the line on screen use 1 for bottom 0 for top)

@STRd6
Copy link
Author

STRd6 commented Oct 31, 2015

I guess I'm on an older version where the position is just the character position, but that will be nice when I can upgrade.

@nightwing
Copy link
Member

Must be something else, that code didn't change much from the very beginning.
If you have chracter index in value string editor.session.doc.indexToPosition(index) can help you to get {row, column} but that is a relatively slow function.

@STRd6
Copy link
Author

STRd6 commented Oct 31, 2015

Thanks for the response! You're right about the Ace cursor API. I now think it has to do with my Firepad plugin doing something else weird with it, so there's nothing wrong on the Ace side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants