Skip to content

editor: Don't treat scheme-prefixed text as a URL when pasting in Markdown - #59071

Merged
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
TomPlanche:fix/59070-markdown-paste-scheme-like-prefix
Jun 11, 2026
Merged

editor: Don't treat scheme-prefixed text as a URL when pasting in Markdown#59071
ChristopherBiscardi merged 1 commit into
zed-industries:mainfrom
TomPlanche:fix/59070-markdown-paste-scheme-like-prefix

Conversation

@TomPlanche

Copy link
Copy Markdown
Contributor

Pasting text that merely starts with a scheme-like prefix (for example a commit message like editor: Fix crash in project panel) over a selection in a Markdown buffer would wrap the selection in a Markdown link, because url::Url::parse accepts editor: as a valid URL scheme.

Paste now only treats clipboard text as a URL when the whole text is a single standalone URL, using linkify (already a workspace dependency) instead of url::Url::parse. Added a regression test covering the scheme-like prefix case.

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

Closes #59070

Release Notes:

  • Fixed pasting text starting with a scheme-like prefix (such as editor: ...) over a selection in a Markdown buffer incorrectly creating a Markdown link.

@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Jun 10, 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.

looks good to me, and matches what github does generally afaict

@ChristopherBiscardi ChristopherBiscardi added the area:editor Feedback for code editing, formatting, editor iterations, etc label Jun 11, 2026
@ChristopherBiscardi ChristopherBiscardi self-assigned this Jun 11, 2026
@ChristopherBiscardi
ChristopherBiscardi added this pull request to the merge queue Jun 11, 2026
Merged via the queue into zed-industries:main with commit 053ea47 Jun 11, 2026
44 checks passed
This was referenced Jun 18, 2026
jonx pushed a commit to jonx/zed-aros that referenced this pull request Jul 17, 2026
…kdown (zed-industries#59071)

Pasting text that merely starts with a scheme-like prefix (for example a
commit message like `editor: Fix crash in project panel`) over a
selection in a Markdown buffer would wrap the selection in a Markdown
link, because `url::Url::parse` accepts `editor:` as a valid URL scheme.

Paste now only treats clipboard text as a URL when the whole text is a
single standalone URL, using `linkify` (already a workspace dependency)
instead of `url::Url::parse`. Added a regression test covering the
scheme-like prefix case.

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

Closes zed-industries#59070

Release Notes:

- Fixed pasting text starting with a scheme-like prefix (such as
`editor: ...`) over a selection in a Markdown buffer incorrectly
creating a Markdown link.
jolutz pushed a commit to jolutz/zed that referenced this pull request Aug 8, 2026
…kdown (zed-industries#59071)

Pasting text that merely starts with a scheme-like prefix (for example a
commit message like `editor: Fix crash in project panel`) over a
selection in a Markdown buffer would wrap the selection in a Markdown
link, because `url::Url::parse` accepts `editor:` as a valid URL scheme.

Paste now only treats clipboard text as a URL when the whole text is a
single standalone URL, using `linkify` (already a workspace dependency)
instead of `url::Url::parse`. Added a regression test covering the
scheme-like prefix case.

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

Closes zed-industries#59070

Release Notes:

- Fixed pasting text starting with a scheme-like prefix (such as
`editor: ...`) over a selection in a Markdown buffer incorrectly
creating a Markdown link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:editor Feedback for code editing, formatting, editor iterations, etc cla-signed The user has signed the Contributor License Agreement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Markdown: pasting non-URL text over a selection creates a link when the clipboard looks like a scheme: (e.g. commit messages)

2 participants