I have a ScrollView which contains a TextEditorView as a subview, as follows:
@content: -> # ... @subview 'editorView', new TextEditorView
I want to have the view scroll to the cursor position when the cursor within the texteditorview goes off the edge of the scrollview. I have tried subscribing to the onDidChangeCursorBufferPosition of the texteditorview, as follows:
@editorView.getModel().onDidChangeCursorBufferPosition() (cursorEvent) => # ... atom.workspaceView.trigger 'editor:scroll-to-cursor' # doesn't work @editorView.getModel().scrollToCursorPosition() # doesn't work @editorView.element.scrollToCursorPosition() # undefined
'editor:scroll-to-cursor' manually from the command palette does what I want, I thought this would work, even if it is a bit of a hack. Didn’t scroll, and neither did the TextEditor class’s
scrollToCursorPosition. I grepped through the source and found in
text-editor-element.coffee:297: 'editor:scroll-to-cursor': -> @scrollToCursorPosition()
But as shown, the text editor element does not appear to have a
scrollToCursorPosition() method defined.
What is next? How might I get the cursor to stay in view in the scrollview? I’m somewhat stumped. code here, if interested.