mchakravarty / CodeEditorView

SwiftUI code editor view for iOS, visionOS, and macOS
Apache License 2.0
697 stars 63 forks source link

Custom view for the minimap #92

Open mchakravarty opened 10 months ago

mchakravarty commented 10 months ago

The current setup for the minimap (where the minimap is a separate text view using a smaller font, but sharing an NSTextStorage with the main code view) has the inherent disadvantage that layout happens twice. This implies twice the work (where layout is the main performance bottleneck already anyway) and it means that we need to carefully set things up, such that the two layouts coincide (especially wrt to line breaks), which turns out to be a rather fragile affair.

A better code architecture would share the layout of the code view with the minimap. This requires the minimap to use a custom view (instead of being a subclass of {NS|UI}TextView). To this end, we need to do the following:

Two challenges are the following: