# Preserve Markdown emphasis delimiters when joining lines \(\#61298\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/9ca3f21adabaab93cb75a99ef2e8c3b3840c49e7)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 9ca3f21adabaab93cb75a99ef2e8c3b3840c49e7

Requested commit: 9ca3f21adabaab93cb75a99ef2e8c3b3840c49e7

Commit: 9ca3f21adabaab93cb75a99ef2e8c3b3840c49e7

Tree: 017fa249ac5fda96a3e3423eeaaded698a3e3100

Author: Xin Zhao

Committer: GitHub

## Message

```
Preserve Markdown emphasis delimiters when joining lines (#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.
```

## Parents

- [f14fea9bf3c93797d5161f7440ed418655bc6c57](https://git.cafe/gitcafe/zed/commit/f14fea9bf3c93797d5161f7440ed418655bc6c57?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/9ca3f21adabaab93cb75a99ef2e8c3b3840c49e7?format=markdown)
