-
Notifications
You must be signed in to change notification settings - Fork 114
When scrolling to symbol, center it in the buffer #136
When scrolling to symbol, center it in the buffer #136
Conversation
This actually doesn't solve the full issue - underneath the covers It seems like there's a bigger issue where sequential scroll requests override each other. For example, adding another call to It looks like the sequential method calls are both updating the I'm updating this to the following, which looks like it is doing the right thing, even though it relies on the the call to moveToPosition: (position, beginningOfLine=true) ->
if editor = atom.workspace.getActiveTextEditor()
editor.setCursorBufferPosition(position, autoscroll: false)
editor.moveToFirstCharacterOfLine() if beginningOfLine
# Override scrolling in above line to center editor, see issue #132
editor.scrollToCursorPosition(center: true) |
3024ef8
to
179be6c
Compare
👍 for this feature. |
Is there anyway to apply this as a patch pending it being merged? |
@jwhitmarsh Yes, clone the repository and then run |
907c7cf
to
17fbb19
Compare
Added `autoscroll:false` to `setCursorBufferPosition`, which was thrashing the call to `scrollToBufferPosition` avove it. Underneath the covers moveToFirstCharacterInLine also requests an autoscroll underneath the covers. There isn't a way to turn this off through any of the Cursor methods, including the one TextEditor proxies for moveToFirstCharacterInLine. It seems like there's a bigger issue where sequential scroll requests override each other. For example, adding another call to scrollToBufferPosition after moveToFirstCharacterOfLine actually corrects the scrolling behavior to center on the variable. It looks like the sequential method calls are both updating the text-editor-presenter @State before getState is called as a result of the events in the next animation frame. Updating cursor position and then scrolling to it *looks* like it is doing the right thing, even though it relies on the the call to scrollToCursorPosition to override the previous, implicit autoscroll in moveToFirstCharacerOfLine(). This will have the desired behavior of centering the editor on the symbol where possible.
17fbb19
to
e59dc01
Compare
@mshenfield Would you be willing to create an issue on atom/atom detailing your findings? |
setCursorBufferPosition on L91 is thrashing scrollToBufferPosition on L90.
Passing autoscroll: false in the options for setCursorBufferPosition fixes
this.
Fixes #132