Commit 8e3135f
Refactor native rendering for correctness and robustness
Replaces the old viewport-based render algorithm with one that parks
the terminal at `max_offset - 1` after each pass. This lets us:
- Track scrollback correctly even when the libghostty scrollback cap
is reached, by detecting eviction from the parked offset rather
than scanning for specific escape sequences.
- Identify scrollback-clear (CSI 3J et al.) reliably via the
`offset+len==total` snap-back signal — no per-byte VT scanning.
- Use libghostty dirty flags directly to identify stale lines,
fixing a bug where promoted scrollback rows could carry outdated
content.
- Evict old scrollback rows from the Emacs buffer in lockstep with
libghostty when its ring buffer wraps.
OSC 8 hyperlink handling switches from storing URI strings on every
run to a lazy lookup via a `help-echo` function that calls
`ghostel--native-uri-at`. The Emacs buffer now always carries a
trailing newline so line-math is uniform across the codebase
(callers like evil-ghostel--reset-cursor-point that used
`line-number-at-pos` on `point-max` are switched to `count-lines`,
which is off-by-one-safe regardless of the trailing newline).
Cursor rendering is split out of the main render path.
Tests for `ghostel--cursor-on-empty-row-p` and
`ghostel--cursor-pending-wrap-p` (and the anchor-window clamp tests
that depended on them) are dropped — those helpers were removed
along with the old viewport algorithm. Docstrings and the
file-level render.zig comment block are refreshed to describe the
new algorithm; checkdoc imperative-form fixes for two new OSC 8
helpers; the unused `exact-point` argument to
`ghostel--anchor-window` is dropped along with a stale TODO in
fnUriAt.
Bug fixes folded in:
* fnCursorPosition / fnDebugState / fnDebugFeed: the viewport-
restore defer sat inside `if (term.getScrollbar()) |sb| { defer
{ ... } }`, so the defer fired the moment the if-block ended —
before the SCROLL_BOTTOM call below it. Each call left the
viewport parked at the bottom (offset+len==total), which the
next redraw mistook for a libghostty scrollback-clear and
treated as a full erase + rebuild signal. With evil-ghostel
this fired on every state transition once scrollback existed,
causing a buffer wipe + rebuild on every i/Esc. Hoist the
defer to function scope via a captured optional offset.
* fnUriAt: the heap-fallback `defer
std.heap.c_allocator.free(buf)` was scoped to the inner alloc
block, freeing the buffer before `makeString` read through the
`heap_uri` alias. Hoist the free defer to function scope and
add a SUCCESS check on the result so error returns from either
`ghostty_grid_ref_hyperlink_uri` call no longer stringify
uninitialised data. Tighten input bounds checks.
* Untabify whitespace cleanup across affected files.
Adds a regression test that anchors a marker in scrollback, calls
`ghostel--cursor-position`, redraws, and asserts the marker is
preserved — a spurious eraseBuffer collapses all markers to
point-min.1 parent 90f1f71 commit 8e3135f
7 files changed
Lines changed: 708 additions & 1214 deletions
File tree
- extensions/evil-ghostel
- lisp
- src
- test
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
88 | | - | |
| 88 | + | |
89 | 89 | | |
90 | 90 | | |
91 | 91 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
567 | 567 | | |
568 | 568 | | |
569 | 569 | | |
570 | | - | |
571 | | - | |
572 | 570 | | |
573 | 571 | | |
574 | 572 | | |
| |||
578 | 576 | | |
579 | 577 | | |
580 | 578 | | |
581 | | - | |
582 | 579 | | |
583 | 580 | | |
584 | 581 | | |
585 | 582 | | |
| 583 | + | |
586 | 584 | | |
587 | 585 | | |
588 | 586 | | |
| |||
1325 | 1323 | | |
1326 | 1324 | | |
1327 | 1325 | | |
1328 | | - | |
1329 | 1326 | | |
1330 | 1327 | | |
1331 | 1328 | | |
| |||
1570 | 1567 | | |
1571 | 1568 | | |
1572 | 1569 | | |
1573 | | - | |
1574 | 1570 | | |
1575 | 1571 | | |
1576 | 1572 | | |
| |||
1851 | 1847 | | |
1852 | 1848 | | |
1853 | 1849 | | |
| 1850 | + | |
| 1851 | + | |
| 1852 | + | |
| 1853 | + | |
| 1854 | + | |
| 1855 | + | |
| 1856 | + | |
| 1857 | + | |
| 1858 | + | |
| 1859 | + | |
| 1860 | + | |
| 1861 | + | |
| 1862 | + | |
| 1863 | + | |
| 1864 | + | |
| 1865 | + | |
| 1866 | + | |
| 1867 | + | |
| 1868 | + | |
| 1869 | + | |
| 1870 | + | |
| 1871 | + | |
| 1872 | + | |
| 1873 | + | |
1854 | 1874 | | |
1855 | 1875 | | |
1856 | 1876 | | |
| |||
1879 | 1899 | | |
1880 | 1900 | | |
1881 | 1901 | | |
1882 | | - | |
1883 | | - | |
| 1902 | + | |
1884 | 1903 | | |
1885 | 1904 | | |
1886 | 1905 | | |
1887 | 1906 | | |
1888 | | - | |
| 1907 | + | |
1889 | 1908 | | |
1890 | 1909 | | |
1891 | 1910 | | |
| |||
3156 | 3175 | | |
3157 | 3176 | | |
3158 | 3177 | | |
3159 | | - | |
3160 | | - | |
3161 | | - | |
3162 | | - | |
3163 | | - | |
3164 | | - | |
3165 | | - | |
3166 | | - | |
| 3178 | + | |
3167 | 3179 | | |
3168 | 3180 | | |
3169 | 3181 | | |
| |||
3310 | 3322 | | |
3311 | 3323 | | |
3312 | 3324 | | |
3313 | | - | |
| 3325 | + | |
3314 | 3326 | | |
3315 | 3327 | | |
3316 | | - | |
3317 | | - | |
3318 | | - | |
3319 | | - | |
3320 | | - | |
3321 | | - | |
3322 | | - | |
3323 | | - | |
3324 | | - | |
3325 | | - | |
3326 | | - | |
3327 | | - | |
3328 | | - | |
3329 | | - | |
3330 | | - | |
3331 | | - | |
3332 | | - | |
3333 | | - | |
3334 | | - | |
3335 | | - | |
3336 | | - | |
3337 | | - | |
3338 | | - | |
3339 | | - | |
3340 | | - | |
3341 | | - | |
| 3328 | + | |
3342 | 3329 | | |
3343 | 3330 | | |
3344 | | - | |
3345 | | - | |
3346 | | - | |
3347 | | - | |
3348 | | - | |
3349 | | - | |
3350 | | - | |
3351 | | - | |
3352 | | - | |
3353 | | - | |
| 3331 | + | |
3354 | 3332 | | |
3355 | 3333 | | |
3356 | 3334 | | |
| |||
3423 | 3401 | | |
3424 | 3402 | | |
3425 | 3403 | | |
3426 | | - | |
3427 | | - | |
| 3404 | + | |
3428 | 3405 | | |
3429 | 3406 | | |
3430 | 3407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
227 | 235 | | |
228 | 236 | | |
229 | 237 | | |
| |||
300 | 308 | | |
301 | 309 | | |
302 | 310 | | |
| 311 | + | |
| 312 | + | |
303 | 313 | | |
304 | 314 | | |
305 | 315 | | |
306 | 316 | | |
307 | 317 | | |
308 | 318 | | |
| 319 | + | |
309 | 320 | | |
310 | 321 | | |
311 | 322 | | |
| |||
330 | 341 | | |
331 | 342 | | |
332 | 343 | | |
333 | | - | |
| 344 | + | |
| 345 | + | |
334 | 346 | | |
335 | 347 | | |
336 | 348 | | |
| |||
0 commit comments