adobe/CodeMirror2 — pull request #62 by njx (2012-06-13 22:41:08+00:00)
Title: Update display immediately in scrollIntoView()

@gruehle

Fixes adobe/brackets#1030.

Peter found another case where the scroll position can get out of sync. It seems like the general rule needs to be that whenever you set the scroll position manually from code, you should `updateDisplay([])` right away in order to make sure the mover position is in sync with the scroll position--otherwise, other code that calls coordinate mapping functions (`localCoords()` or `charCoords()`) before the scroll event is handled will be out of sync. (Basically, we should only have onScroll() handle user scrolling cases, not programmatic scrolling.)

I don't think this will cause performance issues, since `updateDisplay()` won't do any extra work if the scrolled-to lines are already rendered--it will just call through to `updateVerticalScroll()`. If new lines do need to be rendered, then we'd have to render them eventually anyway. So the only case where this would cause extra work is if there were some operation that scrolled multiple times within a single operation, which doesn't seem to happen anywhere in the existing code, and seems like a bad idea regardless.