Skip to content

fix: pasting a URL over a selected URL replaces it instead of nesting#229

Open
PathGao wants to merge 1 commit into
alecdotdev:masterfrom
PathGao:fix/paste-url-over-url
Open

fix: pasting a URL over a selected URL replaces it instead of nesting#229
PathGao wants to merge 1 commit into
alecdotdev:masterfrom
PathGao:fix/paste-url-over-url

Conversation

@PathGao

@PathGao PathGao commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Paste-as-link wraps the selection unconditionally as [selected](pasted). When the selection is itself a URL — the natural gesture for swapping a link target, including inside image syntax — this produces broken nesting:

  1. Have ![](https://old-url) in the document.
  2. Select https://old-url, paste https://new-url.
  3. Result: ![]([https://old-url](https://new-url) — unbalanced and no longer an image.

Change: when the selected text is already a URL (reusing the existing urlRegex), plain-replace it with the pasted URL instead of wrapping. Same convention as VS Code's markdown paste. Wrapping behavior for non-URL selections is unchanged.

npm run check: 0 errors, 0 warnings.

🤖 Generated with Claude Code

Paste-as-link wraps the selection unconditionally: [selected](pasted).
When the selection is itself a URL — the natural gesture for swapping a
link target, including inside image syntax — this produces broken nesting
like ![]([old](new). Follow the editor convention (VS Code does the same)
and plain-replace when the selected text is already a URL.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant