Repository navigation
Run cljr-rename-file-or-dir asynchronously - #597
Merged
Merged
Conversation
Renaming a file rewrites references to it across the whole project, which can take a while. It used a blocking cljr--call-middleware-sync, freezing Emacs until the middleware responded. It now fires the request through a new cljr--call-middleware-async-collect helper and does the rest - the completion message, ast-cache warming, revisiting affected buffers - in the callback, so Emacs stays responsive. cljr--call-middleware-async-collect is the non-blocking counterpart to cljr--call-middleware-sync: it accumulates the response messages, and on done reports any middleware error to the user (rather than letting it escape the nREPL process filter) and hands the result to the callback. A generous safety-net timeout keeps a hung request from waiting forever. Validated live against a real refactor-nrepl connection: the command returns immediately, then renames the file, updates its ns, and rewrites a requiring file's :require once the middleware responds.
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.
First of the async conversions from the command audit. Renaming a file updates references to it across the whole project, which can be slow, and until now it blocked Emacs on a synchronous middleware round-trip. It now returns immediately and finishes (the completion message, ast-cache warming, revisiting the affected buffers) in a callback once the middleware responds.
The reusable bit is
cljr--call-middleware-async-collect- the non-blocking counterpart tocljr--call-middleware-sync: it accumulates the response messages, and when the request is done reports any middleware error to the user (instead of letting it escape the nREPL process filter) and hands the result to the callback. There's a generous safety-net timeout so a hung request or dropped connection doesn't leave a command waiting forever.Validated live against a real refactor-nrepl connection: the command returns immediately, then renames the file, updates its ns, and rewrites a requiring file's
:requirewhen the middleware responds. Buttercup covers the accumulation helper (split value/done messages, value+done together, not firing before done).Note on scope: after mapping the remaining synchronous calls, this is the cleanest high-value async target. Most of the others are either fast/cached (not worth it), act at point (async would jump the user's cursor), or are entangled with the just-added preview flow (would mean re-restructuring fresh code) - so I stopped here rather than sweep them all. The helper is in place if we want to convert more later.