Skip to content

language: Preserve adjacent HTML ranges while editing Markdown - #62370

Open
mTvare6 wants to merge 1 commit into
zed-industries:mainfrom
mTvare6:fix/adjacent-html-ranges
Open

language: Preserve adjacent HTML ranges while editing Markdown#62370
mTvare6 wants to merge 1 commit into
zed-industries:mainfrom
mTvare6:fix/adjacent-html-ranges

Conversation

@mTvare6

@mTvare6 mTvare6 commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

Closes #62127

Objective

Fixes inline HTML highlighting disappearing while editing Markdown.

While updating the ranges parsed as HTML, a newly added range could replace the range immediately before it when the two touched at the same boundary number. This caused the opening tag to be dropped from the parser range until the syntax state was rebuilt.

Solution

When there are still new ranges after the changed ranges have been handled, only replace ranges that actually overlap.
This keeps adjacent HTML ranges separate instead of removing the previous one.

Testing

Added a regression for the with range like from #62127 and test testing against that.

Also verified that the incrementally parsed HTML matches a new parse and the function is source of error.

Self-Review Checklist:

  • I've reviewed my own diff for quality, security, and reliability
  • Unsafe blocks (if any) have justifying comments
  • The content adheres to Zed's UI standards (UX/UI and icon guidelines)
  • Tests cover the new/changed behavior
  • Performance impact has been considered and is acceptable

Release Notes:

  • Fixed inline HTML highlighting disappearing when not separated while editing Markdown.

When updating embedded HTML ranges, a newly added range could replace an adjacent existing one if their boundaries touched. Preserve adjacent ranges and only replace ranges that actually overlap. Only replace overlapping included ranges when inserting ranges left after changed ranges have been consumed.
[x, y) [y, z) != [x, z) in `splice_included_ranges`
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Aug 8, 2026
@dinocosta dinocosta added area:languages/markdown Markdown markup support area:languages/html HTML markup support area:tree-sitter Syntax highlighting and tree-sitter labels Aug 11, 2026
@Artin0123

Copy link
Copy Markdown
Contributor

For context when reviewing or assigning, here is a comparison with #62437 and some advice on it: #62437 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:languages/html HTML markup support area:languages/markdown Markdown markup support area:tree-sitter Syntax highlighting and tree-sitter cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug on highlighting HTML-like tags in Markdown.

3 participants