Commit 4c191c3
committed
Fix wide-char pixel overflow compensation for emoji
The old guard condition (string-width > length) failed for multi-codepoint
emoji like variation selectors and ZWJ sequences, where string-width can
equal the character count. This meant compensation never ran for those
lines.
Rewrite ghostel--compensate-wide-chars to:
- Remove the broken string-width heuristic and check pixel overflow directly
- Use window-text-pixel-size for accurate measurement in the actual window
- Strip stale display properties before measuring to avoid false negatives
- Replace all trailing spaces with a single pixel-accurate stretch glyph
- Only shrink trailing spaces, never widen (prevents false-positive truncation)
- Run after every redraw from Elisp, outside inhibit-redisplay
Use explicit window and Zig-side flag for wide-char compensation
Address review feedback on the wide-char compensation:
- Use get-buffer-window for window-text-pixel-size and window-body-width
so measurements are correct when the ghostel buffer is not in the
selected window
- Replace the redundant Zig-side ghostel--compensate-wide-chars call
(which ran under inhibit-redisplay) with a ghostel--has-wide-chars
flag that the Elisp side checks after the redraw returns
- Only run compensation when the flag is set, skipping the overhead
for ASCII-only output1 parent 63f5550 commit 4c191c3
3 files changed
Lines changed: 45 additions & 36 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
608 | 608 | | |
609 | 609 | | |
610 | 610 | | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
611 | 616 | | |
612 | 617 | | |
613 | 618 | | |
| |||
1548 | 1553 | | |
1549 | 1554 | | |
1550 | 1555 | | |
1551 | | - | |
| 1556 | + | |
1552 | 1557 | | |
1553 | 1558 | | |
1554 | 1559 | | |
1555 | | - | |
1556 | | - | |
1557 | | - | |
1558 | | - | |
1559 | | - | |
1560 | | - | |
1561 | | - | |
1562 | | - | |
1563 | | - | |
1564 | | - | |
1565 | | - | |
1566 | | - | |
1567 | | - | |
1568 | | - | |
1569 | | - | |
1570 | | - | |
1571 | | - | |
1572 | | - | |
1573 | | - | |
1574 | | - | |
1575 | | - | |
1576 | | - | |
1577 | | - | |
1578 | | - | |
1579 | | - | |
1580 | | - | |
1581 | | - | |
1582 | | - | |
1583 | | - | |
1584 | | - | |
1585 | | - | |
| 1560 | + | |
| 1561 | + | |
| 1562 | + | |
| 1563 | + | |
| 1564 | + | |
| 1565 | + | |
| 1566 | + | |
| 1567 | + | |
| 1568 | + | |
| 1569 | + | |
| 1570 | + | |
| 1571 | + | |
| 1572 | + | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
| 1579 | + | |
| 1580 | + | |
| 1581 | + | |
| 1582 | + | |
| 1583 | + | |
| 1584 | + | |
| 1585 | + | |
| 1586 | + | |
| 1587 | + | |
| 1588 | + | |
1586 | 1589 | | |
1587 | 1590 | | |
1588 | 1591 | | |
| |||
2250 | 2253 | | |
2251 | 2254 | | |
2252 | 2255 | | |
| 2256 | + | |
2253 | 2257 | | |
2254 | 2258 | | |
2255 | 2259 | | |
2256 | | - | |
| 2260 | + | |
| 2261 | + | |
| 2262 | + | |
2257 | 2263 | | |
2258 | 2264 | | |
2259 | 2265 | | |
2260 | 2266 | | |
2261 | 2267 | | |
| 2268 | + | |
2262 | 2269 | | |
2263 | | - | |
| 2270 | + | |
| 2271 | + | |
| 2272 | + | |
2264 | 2273 | | |
2265 | 2274 | | |
2266 | 2275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
311 | | - | |
| 311 | + | |
312 | 312 | | |
313 | 313 | | |
314 | 314 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
856 | 856 | | |
857 | 857 | | |
858 | 858 | | |
859 | | - | |
| 859 | + | |
860 | 860 | | |
861 | 861 | | |
862 | 862 | | |
| |||
0 commit comments