Dispatch OSC 51;E elisp synchronously from the process filter#213
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adjusts ghostel’s PTY process filter so OSC 51;E (whitelisted elisp dispatch via ghostel-eval-cmds) is flushed/handled synchronously, preventing races where callers delete temporary directories/files before find-file (etc.) actually runs.
Changes:
- Extend the process-filter “immediate flush” detection to include OSC 51;E (in addition to OSC 4/10/11 color queries).
- Add an ERT regression test ensuring OSC 51;E dispatch happens before
ghostel--filterreturns, while OSC 51;A remains deferred.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
lisp/ghostel.el |
Flush pending output immediately when an OSC 51;E sequence is observed in filter output. |
test/ghostel-test.el |
Add regression test covering synchronous OSC 51;E dispatch and non-flushing OSC 51;A behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
12da965 to
ac26f8f
Compare
OSC 51;E callbacks were getting batched along with normal terminal
output and only dispatched when the redraw timer fired. Callers like
`b4 prep --edit-cover' write the OSC and then race ahead — by the time
`find-file' ran, the temp directory had already been cleaned up by the
caller's `with tempfile.TemporaryDirectory' block, producing
ghostel: error calling find-file: Setting current directory: \
No such file or directory, /tmp/b4-editorXXXX/
Extend the existing OSC color-query immediate-flush in `ghostel--filter'
to also cover OSC 51;E. This matches vterm's behavior, where the elisp
queued by `osc_callback' runs synchronously inside `term_redraw' on the
process filter's stack. OSC 51;A (directory tracking) is left deferred
since it has no such race.
Fixes #209
cb715e0 to
3f8846c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ghostel-eval-cmds) were piggy-backing on the redraw-timer flush ofghostel--pending-output, sofind-fileand friends ran tens of ms after the writer had already moved on.b4 prep --edit-coverwrite the OSC inside awith tempfile.TemporaryDirectory(...)block and then continue immediately. The temp directory was being cleaned up before the deferred dispatch ran, surfacing asghostel: error calling find-file: Setting current directory: No such file or directory, /tmp/b4-editorXXXX/.ghostel--filter(already used for OSC 4/10/11 color queries) to also cover OSC 51;E. This matches vterm, which runs OSC 51;E elisp synchronously insideterm_redrawon the process-filter stack. OSC 51;A (directory tracking) intentionally stays deferred since it has no such race.Fixes #209.
Test plan
make -j4 all(zig + elisp + native + lint) passesmake test-evilpassesghostel-test-osc51-eval-filter-flushcovers both the positive case (51;E flushes synchronously) and the negative case (51;A stays pending)b4 prep --edit-cover)