Skip to content

Commit typed link source to a link when the caret leaves it #239

Description

@Azganoth

Summary

Typing [a](b), https://example.com, or <https://example.com> leaves literal text, while pasting the same characters creates a link immediately. The editor presents a state that disagrees with plain-text paste and, for bare URLs, with what the file can hold.

Expected behavior

When the caret leaves a run of text that is exactly valid link source, that run becomes the link it describes, for inline links, autolink literals, and URI autolinks. Because projection re-shows the raw source whenever the caret is inside, the visible text does not change as a result of the conversion.

Text that is not exactly valid link source is unaffected. \[a](b) stays literal.

Related context

Done when

  • Typed inline-link, autolink-literal, and URI-autolink source commits to a link on caret-leave.
  • Enter and Shift+Enter commit it through the existing projection finalization path.
  • Backslash-escaped source stays literal.
  • Typing and plain-text paste of the same source produce the same document.
  • docs/specification.md describes the rule.

Notes

Implementation direction

Reuse projection's existing validity check and commit trigger rather than adding an input rule. The commit path for an edited projected link already turns valid source into a link; this extends the same rule to a run that was never a link.

Out of scope

  • An eager commit on a boundary character. Caret-leave is the uniform trigger; revisit only if it feels sluggish in use.

Metadata

Metadata

Assignees

Labels

FeatureNew feature or request

Projects

Status
Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions