Commit 20cce42
committed
Fix OSC 51;E eval crashing process filter
`ghostel--osc51-eval` is dispatched synchronously from the native VT
parser inside `fnWriteInput`, so anything the callback does — or any
error it signals — unwinds back through `ghostel--write-input` into
whatever caller drove the flush: the process filter on the
immediate-redraw path, or `ghostel--delayed-redraw` on the bulk-timer
path. Three distinct regressions from #82 all stem from that:
1. `find-file-other-window` / `dired-other-window` call `select-window`
on the newly-popped window, which flips `current-buffer` as a side
effect. When control returns to `ghostel--delayed-redraw`, its
`with-current-buffer` has already entered its body, and the
remaining statements read `ghostel--term` from the *new* file
buffer, where the buffer-local is nil. The native module then
receives nil and Emacs signals `Wrong type argument: user-ptrp,
nil` — attributed to `ghostel--delayed-redraw` on the timer path
and to the process filter on the immediate path.
Fix: wrap the `ghostel--write-input` call in
`ghostel--flush-pending-output` with `save-current-buffer`. Done
at the flush site so every caller — delayed-redraw, the filter's
color-query fast path, `ghostel-clear`, `ghostel-clear-scrollback`,
and the sentinel — is protected in one place. The user-visible
window selection still sticks because `save-current-buffer`
restores only the elisp current buffer, not `selected-window`.
2. `dow` with no arguments called `dired-other-window` with zero
arguments, which signals `Wrong number of arguments`. That error
propagates up the same path and again trips the filter.
Fix: wrap the `apply` in `ghostel--osc51-eval` with
`condition-case`, so any error a whitelisted function signals is
reported via `message` instead of crashing the pipeline. Also
update the README's `dow()` example to default to `$PWD` so the
bare invocation does the sensible thing.
3. After `find-file-other-window` deselected the ghostel window, the
subsequent native redraw updated `buffer-point` but not
`window-point` for any window showing the ghostel buffer (Emacs
only keeps them in sync for the *selected* window). When the
user reselected the ghostel window the terminal cursor appeared
at a stale position.
Fix: after the native redraw in `ghostel--delayed-redraw`, push
the new `(point)` into every window displaying the buffer via
`set-window-point`.
Tests: `ghostel-test-flush-pending-output-preserves-buffer` stubs
`ghostel--write-input` to simulate the `select-window` side effect and
asserts the flush restores the ghostel buffer;
`ghostel-test-osc51-eval-catches-errors` dispatches a whitelisted
lambda that raises and asserts the error is messaged rather than
propagated. Both run under `ghostel-test-run-elisp` — no native
module required.
Fixes #821 parent c851d48 commit 20cce42
3 files changed
Lines changed: 72 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
358 | 358 | | |
359 | 359 | | |
360 | 360 | | |
361 | | - | |
362 | | - | |
| 361 | + | |
| 362 | + | |
363 | 363 | | |
364 | 364 | | |
365 | 365 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1705 | 1705 | | |
1706 | 1706 | | |
1707 | 1707 | | |
1708 | | - | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
| 1715 | + | |
| 1716 | + | |
1709 | 1717 | | |
1710 | 1718 | | |
1711 | 1719 | | |
| |||
2269 | 2277 | | |
2270 | 2278 | | |
2271 | 2279 | | |
2272 | | - | |
| 2280 | + | |
| 2281 | + | |
| 2282 | + | |
| 2283 | + | |
| 2284 | + | |
| 2285 | + | |
| 2286 | + | |
2273 | 2287 | | |
2274 | 2288 | | |
2275 | 2289 | | |
| |||
2289 | 2303 | | |
2290 | 2304 | | |
2291 | 2305 | | |
2292 | | - | |
| 2306 | + | |
| 2307 | + | |
| 2308 | + | |
| 2309 | + | |
| 2310 | + | |
| 2311 | + | |
| 2312 | + | |
| 2313 | + | |
| 2314 | + | |
| 2315 | + | |
2293 | 2316 | | |
2294 | 2317 | | |
2295 | 2318 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1454 | 1454 | | |
1455 | 1455 | | |
1456 | 1456 | | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
| 1492 | + | |
| 1493 | + | |
| 1494 | + | |
| 1495 | + | |
| 1496 | + | |
| 1497 | + | |
| 1498 | + | |
1457 | 1499 | | |
1458 | 1500 | | |
1459 | 1501 | | |
| |||
2496 | 2538 | | |
2497 | 2539 | | |
2498 | 2540 | | |
| 2541 | + | |
| 2542 | + | |
2499 | 2543 | | |
2500 | 2544 | | |
2501 | 2545 | | |
| |||
0 commit comments