Replace the grep/ack run-with-timer hack with helm-run-after-exit - #218
Merged
Conversation
`helm-projectile-grep' (and `helm-projectile-ack') deferred the actual search through `(run-with-timer 0.01 ...)' - a fixed 10ms guess so that, when the command was invoked as an action from a Helm session, the new session wouldn't start before the current one finished tearing down. This dated back to the initial commit. Route both through `helm-projectile--run-grep-or-ack', which defers via `helm-run-after-exit' when a Helm session is live (the codebase's own idiom for this, already used for the etags binding) and runs the search directly otherwise. No more arbitrary latency on the standalone commands, and the reason for the deferral is now explicit.
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #218 +/- ##
==========================================
+ Coverage 46.33% 46.60% +0.27%
==========================================
Files 1 1
Lines 559 560 +1
==========================================
+ Hits 259 261 +2
+ Misses 300 299 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
#3 on the list.
helm-projectile-grep(and the now-deprecatedhelm-projectile-ack) deferred the actual search through(run-with-timer 0.01 nil ...)- a fixed 10ms guess, present since the initial commit. The reason: when the command is invoked as an action from a Helm session (theC-sgrep action in the project/directory sources), a new Helm session must not start until the current one has torn down.That's exactly what
helm-run-after-exitis for - and the codebase already uses it (theC-c p fetags binding). This routes both commands through a smallhelm-projectile--run-grep-or-ackhelper that:helm-run-after-exitwhenhelm-alive-p(invoked from a live session), andM-x/ keybinding).So no more arbitrary 10ms latency on the standalone commands, no racy timer, and the deferral is explicit and self-documenting. Two tests cover both dispatch branches (68 specs).
Note: the interactive "grep from the project list" flow can't be exercised in batch, but in the real action paths Helm has already exited by the time the command runs (
helm-exit-and-execute-action/ action dispatch), so the direct-call branch handles them, withhelm-run-after-exitas the guard for any still-live case.M-x checkdocwarnings