Skip to content

Show the character a projected reference names beside its source #308

Description

@Azganoth

Summary

A projected character reference replaces the character it names, so while the source is open the author reads © and no longer sees what it renders. For a reference the point of reading the source is to tell one form from another, and the character it produces is the thing being identified, so hiding it removes the answer the projection was opened to get. This is most acute for a reference naming something invisible:   and ​ render as whitespace the author cannot otherwise confirm.

Typora shows both, drawing the rendered character followed by its source in a muted marker colour, and treats the character and the reference's opening & as one unit for deletion and character move.

Expected behavior

While a character reference is projected, the character it names is shown beside its source in the marker colour the projection already uses for syntax. The preview is presentation only: it is not document text, it takes no caret, it is not selected, copied, or saved, and every offset between the document and the file is unchanged by its presence.

The rule holds wherever a reference is projected, so the reference's own projection, a marked fragment holding one, and a link label holding one all present it the same way.

Related context

Done when

  • A projected character reference shows the character it names beside its source, styled as a marker.
  • The preview appears in the reference's own projection, in a marked fragment holding one, and in a link label holding one.
  • The preview is never selected, copied, or saved, and no document or source offset shifts because of it.
  • Regression coverage asserts the preview's presence and that a round trip through the projection is unchanged by it.
  • docs/specification.md Inline Content records the display rule, which currently states the opposite.

Notes

Implementation direction

createProjectionDecorations already builds a DecorationSet from the spans an adapter returns, all of which are Decoration.inline. A Decoration.widget holding the decoded character rides in the same set and touches neither the projected text nor the source maps, which is what keeps every offset intact. SourceProjectionPresentation carries only spans today and needs a way to express a widget.

Deciding this on the display side matters: were the character document text instead, a projected run would hold characters the file does not, and an edit would have to guess whether the author meant the preview or the source.

Out of scope

  • Typora's deletion behaviour, where removing the character removes the reference's opening &. Deletion is worth its own decision and depends on this landing first.
  • Any change to what a projection commits or saves.
  • A preview shown before the caret arrives, which is a marker-presentation concern rather than a projection one.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

FeatureNew feature or request

Projects

  • Status
    Ready

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions