Repository navigation
fix: land a double-click on a README's HTML on its own line in the editor - #7315
Merged
Merged
Conversation
# Conflicts: # browser/runtime/lib/markdown.js
leaf-agent
approved these changes
Nov 26, 2026
leaf-agent
added a commit
that referenced
this pull request
Nov 27, 2026
…7336) `test_a_double_click_on_the_rendered_copy_types_at_its_line_in_the_editor` has failed on `main` since #7317, which landed ten minutes after #7315 added the test. #7317 switched a Markdown file's preview to DOMPurify's defaults, which keep the file's `<style>`. The test's README holds `<style>.Gizmo { color: red }</style>` ahead of `<strong>Gizmo</strong>`, so `word_point` took the style's text node first. That range draws no box, so the double-click pressed the window's corner. It selected the page's heading ("Notes"), and the editor never took focus. `word_point` now skips any text that draws no box and raises if no drawn copy of the word exists. The product's double-click mapping needs no change: with the press on the visible "Gizmo", every word in the test lands on its line. The test fails on `main` and passes with this change. So do the other callers of `word_point`, in `test_reading_place.py`, `test_draft_editing.py`, `test_render_files.py` and `test_threads_in_panel.py`. Refs #7334 — automated triage Co-authored-by: leaf-agent <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A double-click in a Markdown file's preview now lands on the right line when the file holds HTML. Since #7310 the preview draws a file's HTML as GitHub does, but the double-click from #7297 placed the file's tokens with
html: false, so an HTML block's words were its tags, which never appear in the preview, and a double-click inside a centred<p align="center">header or an HTML fold landed on the next Markdown block's line.Placement now parses a file the way the drawing did:
markdownSourceOffsettakes the rendering'shtmlflag, and each caller names it (the previewtrue,lf-draftfalse), which the type check enforces. An HTML block is placed whole and aligned by the words its source draws: the text outside markup (tags, comments, declarations, script and style), with character references decoded and<br>as a line break. So a word never lands in an attribute or comment that spells it, text the sanitizer drops takes no part, and a large HTML table maps in milliseconds. Text the browser's parser moves out of source order, such as foster-parented table text or a<pre>'s first newline, still sends a click in that block to the next block, and a half-glyph click beside markup that spans lines inside a blockquote, or beside a multiline comment, can take the neighbouring line. The mapping pairs words in document order rather than elements with tokens, so Markdown that a fold wraps maps as before.On 200 popular READMEs drawn through
markdownFileFragmentin Chromium, all 2,246 sampled words now map to the word's exact source position; before, 1,779 landed on a line holding the word. A lookup's p99 is 13 ms; a 160-row HTML table takes 0.7 ms, where aligning against its tags took 255 ms.Follows the parent session's request to fix the double-click for #7310's previews; reviewed in four Codex passes.
Tests: the browser double-click test's README gains a centred header with a
title, comment and<style>spelling its word, and a fold with Markdown inside; it fails without the change. A runtime case covers the same mapping, with quoted>, character references with and without semicolons, and both sides of markup that spans lines.