Skip to content

Commit

Permalink
[Fix clojure-emacs#597] Don't process incomplete messages unless sure
Browse files Browse the repository at this point in the history
  Probably also fixes the related clojure-emacs#583 and clojure-emacs#586.
  • Loading branch information
vspinu committed Jun 11, 2014
1 parent e6bfe3b commit 468b5cd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ for presenting fontified documentation, including Javadoc.
* `cider-select` can now switch to the `*cider-error*` buffer (bound to `x`).

### Changes

* [#597](https://github.com/clojure-emacs/cider/issues/597) Don't process reple
messages unless the whole message has been received.
* [#603](https://github.com/clojure-emacs/cider/pull/603) New variable
`cider-show-error-buffer` to control the behavior of the error buffer. Obsoletes
`cider-popup-on-error`, `cider-popup-stacktraces` and
Expand Down
13 changes: 10 additions & 3 deletions nrepl-client.el
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,22 @@ Assume that any error during decoding indicates an incomplete message."
(with-demoted-errors
(while (> (buffer-size) 1)
(let ((responses (nrepl-net-decode)))
(dolist (response responses)
(nrepl-dispatch response))))))))
(dolist (r responses)
(nrepl-dispatch r))))))))

(defvar cider-wait-before-processing 0.01
"Seconds to wait before processing nrepl output.")

(defun nrepl-net-filter (process string)
"Decode the message(s) from PROCESS contained in STRING and dispatch."
(with-current-buffer (process-buffer process)
(goto-char (point-max))
(insert string))
(nrepl-net-process-input process))
;; end of the dict maybe?
(when (eq ?e (aref string (1- (length string))))
;; wait a bit to make sure we are at the real end
(unless (accept-process-output process cider-wait-before-processing)
(nrepl-net-process-input process))))

(defun nrepl-sentinel (process message)
"Handle sentinel events from PROCESS.
Expand Down

0 comments on commit 468b5cd

Please sign in to comment.