Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Edits To Visible Range #173

Merged
merged 1 commit into from
Apr 4, 2023

Conversation

thecoolwinter
Copy link
Collaborator

Description

This change adds all positive edits to the visible range. The assumption is that any edits the user may make are going to be visible at some point in time. If the cursor is not already on the page, it will be scrolled to and if it extends beyond the viewport it will be scrolled to be visible as well. In both of those cases the added range will be overridden immediately due to the scroll. So this fixes the case where characters are being inserted at the end of a file, but aren't being scrolled to. This is apparent in the attached screen recordings.

Alternatives considered:

  • Re-calculating the visible set: Decided against due to the extra work that would need to be done potentially every keystroke to calculate a new visible range.
  • Update the visible set only if the edit is actually visible: Decided against due to the reasons previously mentioned. Any edit will eventually be included in the visible set if it is not already in it when the edit occurs.

Related Issues

Checklist

  • I read and understood the contributing guide as well as the code of conduct
  • The issues this PR addresses are related to each other
  • My changes generate no new warnings
  • My code builds and runs on my machine
  • My changes are all related to the related issue above
  • I documented my code

Screenshots

Before fix. Edits applied to the end of the file are never sent to tree-sitter for highlighting as they are out of the range of the visible set. They are only updated when the document is scrolled and visibleSet is recalculated.

bad-example.mov

After fix. Edits with positive deltas are always included in the visibleSet.

good-example.mov

Copy link
Member

@lukepistrol lukepistrol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🐞 Syntax highlights not applied to end of file
3 participants