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
test_a_text_document_update_keeps_a_selection_it_carries_into_another_run[browser]: a drawn line number no longer matches its line #5916
tests/browser/widgets/test_code_and_documents.py::test_a_text_document_update_keeps_a_selection_it_carries_into_another_run[browser] (Chromium only) has failed in every ci push run on main from 43172505092 (b3387f111) through 43305728764 (fa76e28e3), 7 of 7. The Firefox case passes.
It fails at line 1063, on the line-number check after the selected row is scrolled into view:
assert all(text == str(line) for line, text in drawn), drawn
AssertionError: [(1, '1'), (2, '2'), (3, '3'), (4, '4'), (5, '5'), (6, '6'), ...]
So some drawn row number no longer matches its line. The truncated list doesn't show which one. The test's docstring describes an earlier bug where numbering restarted at 1 in each run of rows. The onset range is d5f181825..b3387f111. Its runtime changes are #5844 (c774f469b, focus-move restyling in Chromium), #5845 (c5739b847, key hints, including "give a diff's line numbers no Go-to chip") and #5865 (286ce93e8, Leaf class names). Bisecting over that range, or printing the full drawn list, should settle which one it is. I didn't run it locally.
Reproduced locally (Chromium 158.0.8127.18, Playwright's build). The bug is in Chromium, and #5844 uncovered it rather than causing it. I don't have a fix I can defend, so this needs a decision on which cost to accept. I've assigned @max-sixty.
What fails. At the first update (one line added at the top, 279 lines in all), the rows numbered 258 and up show 1, 2, 3, … The DOM is correct: the third run holds 24 rows, its --lf-lines-before is 256, and its first row is line 256. Row 257 is the one reconcileRuns moved in with moveBefore, from the end of the second run to the start of the third. Its ::before has no layout box at all. Without that box its counter-reset never takes effect, so the rows after it start a new count from 1.
What triggers it. Chromium skips building that box when a row is moved with moveBefore into a run that content-visibility: auto is skipping, and that row is the run's new :first-child and carries the counter reset. It stays missing after the run scrolls into view. Things that don't trigger it:
the same move with prepend/insertBefore
the same moveBefore while the run is on screen
the same move with plain ::before content instead of a counter
Writing a style on the moved row afterwards (an inline counter-reset) doesn't rebuild the box. A forced style pass does.
Why #5844. The test passes at d5f181825. It fails at c774f469b (#5844) and at each later suspect (286ce93e8, c5739b847). On current main, restoring any one of #5844's four CSS files makes it pass again. Each of the old rules restyled the whole page whenever a focus mark changed (the cost #5844 removed), and that restyle happened to rebuild the moved row's box. #5844 is correct, so reverting it isn't the fix.
Repairs tried, each with a cost:
Flip content-visibility: visible on the runs that received a row, then read their computed style. This fixes it with a style pass only, no layout. But adding one line at the top moves a row into every run, so on a long document this styles every run, which is what runs exist to avoid.
Flip display: none on just the rows that changed run, with one batched getComputedStyle. This fixes it at a cost per moved row, and the test passes in both engines. The suite's write guard then fails it at teardown with unchanged write: style on div in div.lf-text-document-run, because the flip leaves no net change. So this needs either an exception to that guard or a different mechanism.
Not using moveBefore for these rows. This loses the selection the test protects, for a row that moves while it holds the selection.
So the choice is between a guarded per-row restyle in reconcileRuns (similar to the forced style pass sizeRuns already does for Chromium/Firefox heights), another way of numbering rows that doesn't depend on a reset on the first row, or leaving the Chromium case open and reporting it upstream. Once one is picked, the fix is small and the existing test already proves it.
Standalone reproduction (Playwright, Chromium)
Three runs of 40 rows, the same CSS shape as text-document.css. Each run is drawn once, the page goes back to the top, and then a line is "added" the way reconcileRuns does it.
fromplaywright.sync_apiimportsync_playwrightcss= (".run{content-visibility:auto;contain-intrinsic-block-size:auto 40lh}"".run>*{counter-increment:n}.run>:first-child{counter-reset:n var(--b)}"".run>*::before{content:counter(n)}")
withsync_playwright() asp:
b=p.chromium.launch(); pg=b.new_page(viewport={"width": 600, "height": 400})
html=f"<style>{css}</style>"+"".join(
f'<div class=run style="--b:{r*40}">'+"".join(f"<div>L{r*40+i+1}</div>"foriinrange(40)) +"</div>"forrinrange(3))
pg.set_content(html); pg.wait_for_timeout(150)
pg.evaluate("() => document.querySelectorAll('.run')[2].scrollIntoView()"); pg.wait_for_timeout(150)
pg.evaluate("() => scrollTo(0, 0)"); pg.wait_for_timeout(150)
pg.evaluate("""() => { const runs = [...document.querySelectorAll('.run')]; for (let i = runs.length - 1; i > 0; i--) runs[i].moveBefore(runs[i-1].lastElementChild, runs[i].firstChild); const d = document.createElement('div'); d.textContent = 'L0'; runs[0].prepend(d); }""")
pg.wait_for_timeout(150)
pg.evaluate("() => document.querySelectorAll('.run')[2].children[3].scrollIntoView({block: 'center'})")
pg.wait_for_timeout(250)
# Read the drawn ::before text with DOMSnapshot.captureSnapshot, as the test's drawn_numbers does.
Drawn numbers around the third run: 79, 80, (none), 1, 2, 3, …. With prepend in place of moveBefore, or with the move made while the run is on screen, they run on correctly.
Activity
leaf-agent commentedon Nov 13, 2026
Reproduced locally (Chromium 158.0.8127.18, Playwright's build). The bug is in Chromium, and #5844 uncovered it rather than causing it. I don't have a fix I can defend, so this needs a decision on which cost to accept. I've assigned @max-sixty.
What fails. At the first update (one line added at the top, 279 lines in all), the rows numbered 258 and up show 1, 2, 3, … The DOM is correct: the third run holds 24 rows, its
--lf-lines-beforeis256, and its first row isline 256. Row 257 is the onereconcileRunsmoved in withmoveBefore, from the end of the second run to the start of the third. Its::beforehas no layout box at all. Without that box itscounter-resetnever takes effect, so the rows after it start a new count from 1.What triggers it. Chromium skips building that box when a row is moved with
moveBeforeinto a run thatcontent-visibility: autois skipping, and that row is the run's new:first-childand carries the counter reset. It stays missing after the run scrolls into view. Things that don't trigger it:prepend/insertBeforemoveBeforewhile the run is on screen::beforecontent instead of a counterWriting a style on the moved row afterwards (an inline
counter-reset) doesn't rebuild the box. A forced style pass does.Why #5844. The test passes at
d5f181825. It fails atc774f469b(#5844) and at each later suspect (286ce93e8,c5739b847). On current main, restoring any one of #5844's four CSS files makes it pass again. Each of the old rules restyled the whole page whenever a focus mark changed (the cost #5844 removed), and that restyle happened to rebuild the moved row's box. #5844 is correct, so reverting it isn't the fix.Repairs tried, each with a cost:
content-visibility: visibleon the runs that received a row, then read their computed style. This fixes it with a style pass only, no layout. But adding one line at the top moves a row into every run, so on a long document this styles every run, which is what runs exist to avoid.display: noneon just the rows that changed run, with one batchedgetComputedStyle. This fixes it at a cost per moved row, and the test passes in both engines. The suite's write guard then fails it at teardown withunchanged write: style on div in div.lf-text-document-run, because the flip leaves no net change. So this needs either an exception to that guard or a different mechanism.moveBeforefor these rows. This loses the selection the test protects, for a row that moves while it holds the selection.So the choice is between a guarded per-row restyle in
reconcileRuns(similar to the forced style passsizeRunsalready does for Chromium/Firefox heights), another way of numbering rows that doesn't depend on a reset on the first row, or leaving the Chromium case open and reporting it upstream. Once one is picked, the fix is small and the existing test already proves it.Standalone reproduction (Playwright, Chromium)
Three runs of 40 rows, the same CSS shape as
text-document.css. Each run is drawn once, the page goes back to the top, and then a line is "added" the wayreconcileRunsdoes it.Drawn numbers around the third run:
79, 80, (none), 1, 2, 3, …. Withprependin place ofmoveBefore, or with the move made while the run is on screen, they run on correctly.Keep a selection past the walk's cap, colour a reopened tab's rows in…