CodeEditSourceEditor
CodeEditSourceEditor copied to clipboard
Async and Faster Folding Calculation
Description
Updates line folding to happen asynchronously off the main thread, and to work while editing text. It now remembers folded ranges and correctly handles nested folds.
Sorry for this huge commit log, it's terrible! Thankfully it'll be squashed when merged.
The meat of the changes here are in LineFoldCalculator, LineFoldModel, and LineFoldStorage. I've moved some files, resulting in the large diff and I'm sorry for that for reviewers I know that makes it hard.
- Refactors the folding model to use a new
LineFoldCalculatortype.- This type accepts an async stream of edit notifications, and produces a stream of the new
LineFoldStoragetype. - Asynchronously accesses text on the main thread for safety.
- This type accepts an async stream of edit notifications, and produces a stream of the new
- Adds a new
LineFoldStoragetype.- Internally uses the
RangeStoretype to quickly store fold ranges as spans in a text document. - Has methods for querying text ranges, collapsing ranges, and updating using new values from the
LineFoldCalculatorstream. - Is
Sendableto work easily with async streams.
- Internally uses the
- Updates the drawing code to handle new behaviors of the fold model.
Related Issues
- #43
Checklist
- [x] I read and understood the contributing guide as well as the code of conduct
- [x] The issues this PR addresses are related to each other
- [x] My changes generate no new warnings
- [x] My code builds and runs on my machine
- [x] My changes are all related to the related issue above
- [x] I documented my code
Screenshots
https://github.com/user-attachments/assets/bc1d5bd1-bf87-45ba-ad0f-53655b2542fc