CodeEditApp / CodeEditSourceEditor

A code editor view written in Swift powered by tree-sitter.
https://codeeditapp.github.io/CodeEditSourceEditor/documentation/codeeditsourceeditor
MIT License
504 stars 74 forks source link

Add Edits To Visible Range #173

Closed thecoolwinter closed 1 year ago

thecoolwinter commented 1 year ago

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:

Related Issues

Checklist

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.

https://user-images.githubusercontent.com/35942988/229874599-e2714b72-d51f-4748-89e1-b80ee51bddda.mov

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

https://user-images.githubusercontent.com/35942988/229875515-36e96921-71c0-48aa-a62c-75cbd91c52fb.mov