Repository navigation
Commit a317a45
committed
fix(diagrams): #104 review — an emoji is measured as wide as it was meant to be; a dead store goes
Two findings from the code-quality review. Both are right.
theme.js, charEm() — "the condition c > 0xffff is always false". The width
estimate used where there is no canvas asked "CJK and other full-width scripts"
(U+2E80 and up, 1.0 em) before "emoji / astral" (above U+FFFF, 1.1 em). Every
code point above U+FFFF is above U+2E80 too, so the second question was never
reached and an emoji was measured at 1.0 em. The estimate is meant to err wide
— the failure that matters is text overflowing its box — so the questions are
now asked the other way round.
Nothing on screen changes. The chat measures with the real font, and no fixture
contains a character beyond the basic plane, so no snapshot moves. What changes
is the fallback when the canvas refuses the font, and the estimates made in
Node.
layout.js — "the value assigned to span here is unused". When several
connectors share a side too short for them, the node grows to hold exactly what
they need; span was recomputed afterwards and never read. The recompute is
gone and span is a const. it.cs, set on the same line, IS read later, and
stays. 6,000 random layouts and the nine gallery diagrams are byte-identical to
the code before.
diagramLayout gains a test for the estimate's classes: narrow, ordinary and
wide letters, digits and capitals, a CJK character at a full em, an emoji at
1.1 em and counted as one character. It fails on the old order, on exactly the
condition the review named.
62 suite files pass on macOS and in a Linux container.1 parent db68f68 commit a317a45
4 files changed
Lines changed: 17 additions & 4 deletions
File tree
- docs
- extensions/levelcode-ai
- diagram
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
391 | 391 | | |
392 | 392 | | |
393 | 393 | | |
394 | | - | |
| 394 | + | |
395 | 395 | | |
396 | 396 | | |
397 | 397 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
384 | | - | |
| 384 | + | |
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | 391 | | |
392 | | - | |
| 392 | + | |
393 | 393 | | |
394 | 394 | | |
395 | 395 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
178 | 178 | | |
179 | 179 | | |
180 | 180 | | |
| 181 | + | |
181 | 182 | | |
182 | | - | |
183 | 183 | | |
184 | 184 | | |
185 | 185 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
308 | 321 | | |
309 | 322 | | |
310 | 323 | | |
| |||
0 commit comments