Skip to content

Preserve Markdown emphasis delimiters when joining lines - #61298

Merged
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
lingyaochu:markdown
Jul 20, 2026
Merged

Preserve Markdown emphasis delimiters when joining lines#61298
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
lingyaochu:markdown

Conversation

@lingyaochu

Copy link
Copy Markdown
Collaborator

Objective

When joining lines, Zed checks the next line and strips comment, documentation-comment, and unordered-list delimiters. The logic trims whitespace from these delimiters, then checks whether the next line starts with the trimmed delimiter. If it does, Zed removes the delimiter before joining the lines.

This works for comment and documentation-comment delimiters, where trailing whitespace does not affect their meaning. However, it causes unexpected behavior for unordered-list delimiters, which, as far as I know, are unique to Markdown.

In Markdown, * is an unordered-list marker, while * is also used as an emphasis delimiter, such as *italics* and **bold**. The current logic strips the leading * from these emphasis cases, which it should not.

Solution

For unordered-list delimiters, Zed should strip the exact delimiter, such as * , rather than the trimmed *. It should strip a bare * only when the next line contains only *.

Testing

Tested locally and new GPUI tests were added.

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 markdown emphasis delimiters being removed when joining lines.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jul 19, 2026
@zed-community-bot zed-community-bot Bot added community champion Issues filed by our amazing community champions! 🫶 guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions labels Jul 19, 2026
@lingyaochu lingyaochu changed the title Preserve Makedown emphasis delimiters when joining lines Preserve Markdown emphasis delimiters when joining lines Jul 19, 2026
@ChristopherBiscardi ChristopherBiscardi self-assigned this Jul 20, 2026

@ChristopherBiscardi ChristopherBiscardi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@ChristopherBiscardi ChristopherBiscardi added area:preview/markdown Feedback for Zed's Markdown preview area:languages/markdown Markdown markup support and removed area:preview/markdown Feedback for Zed's Markdown preview labels Jul 20, 2026
@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue Jul 20, 2026
Merged via the queue into zed-industries:main with commit 9ca3f21 Jul 20, 2026
82 checks passed
@lingyaochu

Copy link
Copy Markdown
Collaborator Author

Apologies, I forgot to reference the issue in the PR description before merging 😅 . This PR was intended to fix #56358, so that issue can now be closed. Thanks!

@lingyaochu
lingyaochu deleted the markdown branch July 20, 2026 04:53
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…ies#61298)

# Objective

When joining lines, Zed checks the next line and strips comment,
documentation-comment, and unordered-list delimiters. The logic trims
whitespace from these delimiters, then checks whether the next line
starts with the trimmed delimiter. If it does, Zed removes the delimiter
before joining the lines.

This works for comment and documentation-comment delimiters, where
trailing whitespace does not affect their meaning. However, it causes
unexpected behavior for unordered-list delimiters, which, as far as I
know, are unique to Markdown.

In Markdown, `* ` is an unordered-list marker, while `*` is also used as
an emphasis delimiter, such as `*italics*` and `**bold**`. The current
logic strips the leading `*` from these emphasis cases, which it should
not.

## Solution

For unordered-list delimiters, Zed should strip the exact delimiter,
such as `* `, rather than the trimmed `*`. It should strip a bare `*`
only when the next line contains only `*`.

## Testing

Tested locally and new GPUI tests were added.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed markdown emphasis delimiters being removed when joining lines.
playdohface pushed a commit to playdohface/zed that referenced this pull request Aug 29, 2026
…ies#61298)

# Objective

When joining lines, Zed checks the next line and strips comment,
documentation-comment, and unordered-list delimiters. The logic trims
whitespace from these delimiters, then checks whether the next line
starts with the trimmed delimiter. If it does, Zed removes the delimiter
before joining the lines.

This works for comment and documentation-comment delimiters, where
trailing whitespace does not affect their meaning. However, it causes
unexpected behavior for unordered-list delimiters, which, as far as I
know, are unique to Markdown.

In Markdown, `* ` is an unordered-list marker, while `*` is also used as
an emphasis delimiter, such as `*italics*` and `**bold**`. The current
logic strips the leading `*` from these emphasis cases, which it should
not.

## Solution

For unordered-list delimiters, Zed should strip the exact delimiter,
such as `* `, rather than the trimmed `*`. It should strip a bare `*`
only when the next line contains only `*`.

## Testing

Tested locally and new GPUI tests were added.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed markdown emphasis delimiters being removed when joining lines.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:languages/markdown Markdown markup support cla-signed The user has signed the Contributor License Agreement community champion Issues filed by our amazing community champions! 🫶 guild Pull requests by someone in Zed Guild. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants