You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Visual editor: "RangeError: Position N out of range" when toggling from Source, when document ends with a link and contains an image wrapped in a link #19588
- RStudio 2026.10.1+239, Windows 11 (10.0.26200, x64), R 4.2.2
Quarto .qmd, editor: visual, CRLF line endings, UTF-8
Steps to reproduce the problem
Open the attached `visual_editor_rangeerror_repro.qmd.txt and edit extension to qmd as GitHub does not seem to accept .qmd as valid extension.
Toggle between Source and Visual.
Describe the problem in detail
Actual: When switching between Source and Visual, an error dialog shows RangeError: Position 9007 out of range (the number was from my full 10.8 KB document; it is near the end of the file). What triggers it
The document's last paragraph ends with an inline link, with nothing after it: See [ProPublica web-based article](https://www.propublica.org/article/east-orange-va-hospital-veterans-decline-new-jersey).
The body also contains an image wrapped in a link: [](https://...pdf).
With both present, the toggle fails. The attached visual_editor_rangeerror_control_passes.qmd.txt (again, remove the .txt extension) differs only by removing the linked-image paragraph, and it works.
Other observations
Both elements are needed. The link at the end of the file with no linked image in the file does not fail, and the linked image alone does not fail either.
Adding a space or a period after the final link does not fix it. Adding several words after the link does.
Other links earlier in the document work normally.
A minimal file I wrote (heading, one image-in-link, final link) did not reproduce the error, so the failure may depend on something else in the document, such as its length or position offsets.
Failing file contents: headings, hard line breaks, a pipe table, bold text and curly quotes.
Workaround: Add several words of text after the final link, or make the screenshot a plain image with the link as separate text.
Activity
fix: don't double-map positions in the visual editor's sync-heading-l…