Fix highlight worker event ordering
What does this MR do and why?
Fixes a bug caused by incorrect event order.
Some context:
We use a web worker to handle the task of highlighting source code on the frontend. To improve perceived performance we ask the worker to highlight the first 70 lines immediately while we highlight the entire file in the background.
Example:
- Task 1: Highlight lines 0-70
- Task 2: highlight lines 0-500
Sometimes these two events finish in the incorrect order (i.e. Task 1 finishes after Task 2) which results in only the first 70 line being rendered. This is especially visible for smaller files where the highlighting tasks are so fast that it can mess up the order.
To prevent this we can ensure that we only render the content if the content length is larger than the current content length.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Before | After |
---|---|
Only lines 0-70 are rendered | All lines are rendered |
![]() |
![]() |
How to set up and validate locally
- Open a source code file via the repository files browser
- The file should render as expected