Don't try to scroll if editor isn't visible #1350
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
If someone calls
scrollTo()
, and then hides the editor before the scroll event is processed, CodeMirror will try to process the scroll while it's hidden, which seems to end up scrolling to (0,0). (I didn't dig into why that happens, but it's plausible to me that the scrolling management stuff would get confused if it's called while the editor is invisible.)This patch makes it so CM doesn't try to process scrolls while hidden. Since the scroll position is saved in the doc state, it appears that the scroll position gets correctly reset to the
scrollTo()
position when CM becomes visible again anyway (I didn't trace through to fully verify this, but that appears to be the behavior I'm seeing).This is somewhat similar to, but different from, the issue and fix for #1236--there, the issue was that a bogus value was explicitly calculated during
endOperation()
while the editor was hidden. Here, the editor is actually still visible in theendOperation()
of thescrollTo()
--the problem is that it becomes hidden before the resulting scroll event is asynchronously processed.