Skip to content

Commit 436c8e3

Browse files
committed
Mark the clojuredocs lookup request completed on done
`cider-clojuredocs--lookup-async' was the only accumulate-then-done request handler that didn't call `nrepl--mark-id-completed' (unlike the analogous handlers in cider-compilation and cider-test), so its handler lingered in the pending table and a late "done" message would re-fire the callback. Mark it completed, matching the others.
1 parent cbcbf78 commit 436c8e3

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

lisp/cider-clojuredocs.el

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@ the symbol has no ClojureDocs entry, or the middleware is unavailable)."
6060
(cider-nrepl-send-request
6161
`("op" "cider/clojuredocs-lookup" "ns" ,ns "sym" ,sym)
6262
(lambda (response)
63-
(nrepl-dbind-response response (clojuredocs status)
63+
(nrepl-dbind-response response (clojuredocs status id)
6464
(when clojuredocs
6565
(setq result clojuredocs))
6666
(when (member "done" status)
67+
(nrepl--mark-id-completed id)
6768
(funcall callback result)))))))
6869

6970
(defun cider-clojuredocs-replace-special (name)

test/cider-clojuredocs-tests.el

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,16 @@
6060
(it "leaves unqualified symbols unchanged"
6161
(expect (cider-clojuredocs--strip-ns "/") :to-equal "/")
6262
(expect (cider-clojuredocs--strip-ns "subs") :to-equal "subs")))
63+
64+
(describe "cider-clojuredocs--lookup-async"
65+
(it "marks the request completed and invokes the callback with the result on done"
66+
(let (handler cb-result)
67+
(spy-on 'cider-nrepl-send-request :and-call-fake
68+
(lambda (_request callback) (setq handler callback)))
69+
(spy-on 'nrepl--mark-id-completed)
70+
(cider-clojuredocs--lookup-async "clojure.core" "map"
71+
(lambda (r) (setq cb-result r)))
72+
(funcall handler (nrepl-dict "id" "7" "clojuredocs" (nrepl-dict "name" "map")))
73+
(funcall handler (nrepl-dict "id" "7" "status" '("done")))
74+
(expect 'nrepl--mark-id-completed :to-have-been-called-with "7")
75+
(expect cb-result :to-equal (nrepl-dict "name" "map")))))

0 commit comments

Comments
 (0)