Repository navigation
Erase only the OSC 66 block a write touches, not every block sharing its span - #189
Conversation
JohnCampionJr
left a comment
There was a problem hiding this comment.
Pre-merge review (Codex), for the PR author
One should-fix finding: overwriting the continuation of a narrow s=2/w=0 block can preserve half of that erased block in SizedRuns; the leftover span still occupies the row beneath and displaces later output.
Checked explicit-width boundaries, variable-width blocks, print/erase/resize call ordering, and the control's per-cell coverage use. The combined core PRs passed 212 filtered tests and the combined view PRs passed 71 filtered tests. Two focused regression assertions reproduce the leftover span and the displaced output. No performance benchmark was run.
8f613db to
f391fec
Compare
JohnCampionJr
left a comment
There was a problem hiding this comment.
Pre-merge review follow-up (Codex), for the PR author
Rechecked the post-review delta at current head f391fec (the pushed form of the cited e5d6a67 fix). Resolved: both retained reproductions pass; the remaining span is [0,2), [4,6), and Y lands in the intended column below. The changed boundary rule and regression test look sound. No new findings in this delta. The combined filtered core run passed 231 tests.
Fixes tomlm/Iciclecreek.Avalonia.Terminal#211
Cause
BufferLine.NoteSizedRunjoins adjacent OSC 66 blocks that share a sizing into one span, so three separatew=2blocks at[0,2),[2,4),[4,6)are stored as one span[0,6). When a later write overlapped any part of that span,EraseSizedRunsOverremoved the whole span and blanked all of its cells, which took the untouched neighbouring blocks with it. OpenCode prints each CJK character as its ownw=2block, so pressing Backspace (two spaces over the last character) blanked the whole line. Withw=1the same thing happens:ABCbecomes empty.Fix
Spans are still joined, so
SizedRunsand every reader of it see the same shape as before. Erasure now works on the blocks inside a span:EraseSizedRunsOverwidens the erased range only to the edges of the blocks it touches. It blanks just those blocks and puts the rest of the span back as up to two runs, in place, so the list stays left to right.BlockStartAt/BlockEndAt):w: every block in the span iss * wcolumns, because they share a sizing, so the edges are arithmetic.w=0: each grapheme is its own block ofstimes its width, so the edges are read from the cells outside the written range. A block's first cell carries its full width and the rest are zero-width.RepairAround) has already turned the other half of a two-column cell into a one-column space. So a cell whose width isn't a multiple ofsis not taken as a block start. Ats=1withw=0(a fractional-only sizing) such a space can't be told apart from a block, and it stays in the span as a one-column blank. It is blank either way.A partial overwrite of one multicell block still erases that whole block, as before.
Tests
New
TextSizingBlockBoundaryTests(23 tests). 15 of them failed before the fix; the 7 that passed are the controls and single-block cases.w=2blocks甲乙丙, thenCSI 1;5Hand two spaces, leaves甲乙. Threew=1blocksABCleaveAB.甲乙中文测.EL,ECHandDCHfrom inside the span.w=0scaled blocks from one sequence, including blocks of different widths (s=2a甲b).s=2block erases only the block above that column.SizedRunsstays left to right,TryGetSizedRunAtanswers per piece, and a new block written at the end joins the span again.BS BS EL,CUB 2+EL/ECH 2/DCH 2, two spaces) still leave甲乙.Results:
TextSizing,ReflowandLineExitedViewporttests pass (134).TextSizingtests: 10 of 10 mutants killed. They covered reverting either edge to the whole span, dropping the rounding in either arithmetic edge, trusting a repaired cell on either side, ignoring whether the block reaches the column, dropping either surviving piece, and blanking to the span's end.SizedTextRendering,Clipping,FaintOpacity,WindowGeometryReport,LineCacheTearing,FrameCoherence,RendererViewport).Performance
There is no change on the print path. The new work runs only inside
EraseSizedRunsOver, for a run the write actually overlaps, which already removed that run and rewrote its cells. Per overlapped run it adds:w), or a scan of at most one block's width of cells (w=0);List.Insertcalls into a line's handful of runs.Spans stay joined on purpose. Renderers call
TryGetSizedRunAtper cell, linearly over a line's runs, so storing one run per block would make a long line of OSC 66 blocks quadratic to draw. I reasoned this through and did not run the bench.🤖 Generated with Claude Code