Skip to content
This repository was archived by the owner on Mar 3, 2023. It is now read-only.

Fix measuring lines in presence of pending autoscroll requests - #15270

Merged
nathansobo merged 1 commit into
masterfrom
as-fix-extra-lines-rendering
Aug 12, 2017
Merged

nathansobo merged 1 commit into
masterfrom
as-fix-extra-lines-rendering

Conversation

@as-cii

@as-cii as-cii commented Aug 12, 2017 •

Copy link
Copy Markdown
Contributor

Fixes #15168.

Calling pixelPositionForScreenPosition was sometimes throwing an error indicating that the requested position was not rendered and that, as such, could not be measured.

This was caused by trying to measure a line that was visible at the moment of the call while also having a pending autoscroll request that would cause that line to go off-screen. Due to how the code was structured, we would mistakenly detect that line as visible, autoscroll to a different location, re-render a different region of the buffer and then try to measure the now invisible line.

This commit fixes this issue by restructuring and simplifying the logic for rendering invisible lines in order to measure them. Now, every line for which a measurement has been requested is stored in a linesToMeasure map. During the first phase of the update process (after honoring autoscroll requests), we detect which of these lines are currently visible and if some of them are not, we store them into the extraRenderedScreenLines map, which is then used to render lines that are invisible but need measurement.

@Ben3eeE @ungb: I am unable to reproduce the issue after this pull-request. Can you help me ensure this fixes all the reports we've got for this issue so far? They seem to be generated by slightly different reproduction steps, although I think they can all be traced back to the root cause described above.

/cc: @nathansobo for 👀

Calling `pixelPositionForScreenPosition` was sometimes throwing an error
indicating that the requested position was not rendered and that, as
such, could not be measured.

This was caused by trying to measure a line that was visible at the
moment of the call while also having a pending autoscroll request that
would cause that line to go off-screen. Due to how the code was
structured, we would mistakenly detect that line as visible, autoscroll
to a different location, re-render a different region of the buffer and
then try to measure the now invisible line.

This commit fixes this issue by restructuring and simplifying the logic
for rendering extra lines in order to measure them. Now, every line for
which a measurement has been requested is stored in a `linesToMeasure`
map. During the first phase of the update process (after honoring
autoscroll requests), we detect which of these lines are currently
visible and if they're not, store them into the
`extraRenderedScreenLines` map, which is then used to render lines that
are invisible but need to be measured.
@Ben3eeE

Ben3eeE commented Aug 12, 2017

Copy link
Copy Markdown
Contributor

@as-cii I tested both to scroll while alternating holding page up and page down and to scroll by pasting text and it looks good to me. I am unable to reproduce the issue after this pull-request.

@nathansobo

Copy link
Copy Markdown
Contributor

Awesome work @as-cii!

@nathansobo
nathansobo merged commit 3c66a1e into master Aug 12, 2017
@nathansobo
nathansobo deleted the as-fix-extra-lines-rendering branch August 12, 2017 19:22
nathansobo pushed a commit that referenced this pull request Aug 12, 2017
Fix measuring lines in presence of pending autoscroll requests
nathansobo pushed a commit that referenced this pull request Aug 12, 2017
Fix measuring lines in presence of pending autoscroll requests
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Uncaught TypeError: Cannot read property 'id' of null

3 participants