Skip to content

editor: Improve colorize_bracket highlight performance#49803

Merged
Veykril merged 1 commit intomainfrom
push-yrkzkuluqmnk
Feb 21, 2026
Merged

editor: Improve colorize_bracket highlight performance#49803
Veykril merged 1 commit intomainfrom
push-yrkzkuluqmnk

Conversation

@Veykril
Copy link
Member

@Veykril Veykril commented Feb 21, 2026

The binary search insertion scheme in highlight_text works fine for small numbers of elements but does not handle large amounts of ranges well, as that will cause constant memcpying of the latter half of the vec. Bracket colorization tends to have a huge amount of entries though, so this can cause massive lags on the foreground thread. The better approach here is to just collect all elements and re-sort them once.

Release Notes:

  • Reduced mini-stutters occuring due to large amount of bracket colorization in big buffers and agent diffs

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Feb 21, 2026
@Veykril Veykril enabled auto-merge (squash) February 21, 2026 14:00
@Veykril
Copy link
Member Author

Veykril commented Feb 21, 2026

/cherry-pick preview

@zed-community-bot zed-community-bot bot added the staff Pull requests authored by a current member of Zed staff label Feb 21, 2026
The binary search scheme in `highlight_text` does not handle large amounts of ranges well, so a more efficient approach is to just collect all elements and resort afterwards as that avoids constant memcpying
@Veykril Veykril merged commit 5e3efc6 into main Feb 21, 2026
41 of 43 checks passed
@Veykril Veykril deleted the push-yrkzkuluqmnk branch February 21, 2026 14:41
github-actions bot pushed a commit that referenced this pull request Feb 21, 2026
The binary search insertion scheme in `highlight_text` works fine for
small numbers of elements but does not handle large amounts of ranges
well, as that will cause constant memcpying of the latter half of the
vec. Bracket colorization tends to have a huge amount of entries though,
so this can cause massive lags on the foreground thread. The better
approach here is to just collect all elements and re-sort them once.

Release Notes:

- Reduced mini-stutters occuring due to large amount of bracket
colorization in big buffers and agent diffs
zed-zippy bot added a commit that referenced this pull request Feb 21, 2026
…erry-pick to preview) (#49808)

Cherry-pick of #49803 to preview

----
The binary search insertion scheme in `highlight_text` works fine for
small numbers of elements but does not handle large amounts of ranges
well, as that will cause constant memcpying of the latter half of the
vec. Bracket colorization tends to have a huge amount of entries though,
so this can cause massive lags on the foreground thread. The better
approach here is to just collect all elements and re-sort them once.

Release Notes:

- Reduced mini-stutters occuring due to large amount of bracket
colorization in big buffers and agent diffs

Co-authored-by: Lukas Wirth <lukas@zed.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-signed The user has signed the Contributor License Agreement staff Pull requests authored by a current member of Zed staff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant