Queue all modifications to the line heights and apply all of them only when reading from the data structure#296963
Queue all modifications to the line heights and apply all of them only when reading from the data structure#296963
Conversation
…y when reading from the data structure
There was a problem hiding this comment.
Pull request overview
This PR refactors the LineHeightsManager to implement lazy commit semantics: modifications are queued and automatically applied when data is read, eliminating the need for explicit commit() calls while maintaining backward compatibility.
Changes:
- Introduced a queue-based change tracking system with auto-commit on read
- Refactored commit logic to handle interleaved decoration and structural changes correctly
- Simplified test setup by removing explicit commit() calls where no longer needed
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/editor/common/viewLayout/lineHeights.ts | Implemented pending changes queue with PendingChange discriminated union, refactored commit logic into _commitPendingChanges with proper staging for decoration changes, made commit() a no-op, added _commitIfNeeded() calls to read methods |
| src/vs/editor/test/common/viewLayout/lineHeights.test.ts | Simplified existing test to use range-based decoration, added comprehensive auto-commit test suite with 20 new tests covering edge cases and interleaved operations |
|
On a file with 700 lines: File/*---------------------------------------------------------------------------------------------
import '../../services/markerDecorations.js'; /**
If you copy paste the above code until you get 50'000 lines, when inserting a new line on the first CodeEditorWidget instance:
It would seem overall like the optimized implementation is slightly quicker. The optimized implementation has a total average time of 8.5 ms. The initial implementation had a total average time of 9.2 ms. So it would seem that the optimized implementation is around 10% faster. Trace-20260223T173431.json.gz |
No description provided.