Skip to content

fix: hide a link's title while the link is concealed - #594

Merged
mtskf merged 3 commits into
mainfrom
fix/link-title-hidden
Dec 4, 2026
Merged

mtskf merged 3 commits into
mainfrom
fix/link-title-hidden

Conversation

@mtskf

@mtskf mtskf commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Summary

A link with a title ([text](https://e.com "My title")) showed its title as body text (see text "My title" end) while the caret was elsewhere. The title, and the whitespace around it, now hide together with the rest of the link syntax. When the caret is inside the link, the full source still shows as before.

Changes

  • link-reveal.ts: while the link is hidden, also hide the gap from the end of the destination to the closing ). This covers the "…", '…' and (…) title forms and <…> destinations.
  • The gap stays visible when it crosses a line break (the title is wrapped onto the next line, possibly after a >). The provider runs in a ViewPlugin, CodeMirror rejects a replace over a line break there, and hiding the gap would also hide the quote mark. This leftover case is logged as a LOW TODO.
  • cm-decoration-link.test.ts: pins the hidden and revealed rendering for every title form, the exact range of the hidden gap, and that no hide decoration crosses a line break.

Related

  • TODO: REV-20261203-16 (link title not hidden)

Test Plan

  • Reproduced first: before the fix, 5 new tests in cm-decoration-link.test.ts were red (hide for "…" / '…' / (…) / <…> destinations, plus the exact gap range). All 5 pass after it. The reveal tests pass both before and after, so they guard against regressions.
  • Multi-line titles: the tests check that no HIDE contains \n. Without the lineAt guard, the gap "\n" in [t](u\n"x") would be hidden and the test would fail.
  • test/webview/decorations + cm-link-*: 775 passed. Full pnpm test:unit/test:browser via parallel-checks: PASS. In the first run, cm-image-field.test.ts failed once under full-suite load; it passed when run alone and on the rerun. It does not touch link code.
  • pnpm compile and pnpm lint are green.
  • E2E not run: this is a webview-only decoration change and touches no host-side or protocol path.

mtskf added 3 commits December 4, 2026 16:03
Inline links with a title ([text](url "title")) rendered the title as prose because only the LinkMark and URL children were hidden. While hidden, the gap between the destination and the closing paren is now hidden too. A gap that crosses a line break stays visible: a replace over a line break is illegal from a ViewPlugin and would swallow a quote mark.
@mtskf
mtskf merged commit 4995150 into main Dec 4, 2026
2 checks passed
@mtskf
mtskf deleted the fix/link-title-hidden branch December 4, 2026 05:16
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