diff options
author | Vitalie Spinu <spinuvit@gmail.com> | 2018-11-22 14:29:49 +0100 |
---|---|---|
committer | Bozhidar Batsov <bozhidar.batsov@gmail.com> | 2018-11-23 15:37:10 +0000 |
commit | 6813fe93141556cc716498ecffcff33c364e3b9c (patch) | |
tree | 9a8216724596bb81b34f6094a5cc9e3d20045494 | |
parent | 1fd1275a5621096bb3320498e032db3764d09f56 (diff) |
[Fix #2474] Fix end-of-output detection
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | cider-repl.el | 18 |
2 files changed, 12 insertions, 7 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 270b063b..18fe9989 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ ### Bug fixes +* [#2474](https://github.com/clojure-emacs/cider/issues/2474): Fix incorrect detection of output and out-of-order printing. * [#2514](https://github.com/clojure-emacs/cider/issues/2514): Don't auto-jump to warnings when `cider-auto-jump-to-error` is set to 'errors-only. * [#2453](https://github.com/clojure-emacs/cider/issues/2453): Make it possible to debug deftype methods by direct insertion of #dbg and #break readers into the deftype methods. * [#1869](https://github.com/clojure-emacs/cider/issues/1869),[cider-nrepl#460](https://github.com/clojure-emacs/cider-nrepl/issues/460): Fix `continue` debugger command which was stopping entering debugger on repeated invocations. diff --git a/cider-repl.el b/cider-repl.el index 261b5bbb..8cb444f2 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -677,8 +677,7 @@ If BOL is non-nil insert at the beginning of line. Run (defun cider-repl--emit-interactive-output (string face) "Emit STRING as interactive output using FACE." (with-current-buffer (cider-current-repl) - (let ((pos (cider-repl--end-of-line-before-input-start)) - (string (replace-regexp-in-string "\n\\'" "" string))) + (let ((pos (cider-repl--end-of-output))) (cider-repl--emit-output-at-pos (current-buffer) string face pos t)))) (defun cider-repl-emit-interactive-stdout (string) @@ -1055,10 +1054,15 @@ See also the related commands `cider-repl-clear-output' and (recenter t)) (run-hooks 'cider-repl-clear-buffer-hook)) -(defun cider-repl--end-of-line-before-input-start () - "Return the position of the end of the line preceding the beginning of input." - (1- (previous-single-property-change cider-repl-input-start-mark 'field nil - (1+ (point-min))))) +(defun cider-repl--end-of-output () + "Return the position at the end of the previous REPL output." + (if (eq (get-text-property (1- cider-repl-input-start-mark) 'field) + 'cider-repl-prompt) + ;; if after prompt, return eol before prompt + (previous-single-property-change cider-repl-input-start-mark + 'field nil (point-min)) + ;; else, input mark because there is no prompt (yet) + cider-repl-input-start-mark)) (defun cider-repl-clear-output (&optional clear-repl) "Delete the output inserted since the last input. @@ -1071,7 +1075,7 @@ With a prefix argument CLEAR-REPL it will clear the entire REPL buffer instead." (ignore-errors (forward-sexp)) (forward-line) (point))) - (end (cider-repl--end-of-line-before-input-start))) + (end (cider-repl--end-of-output))) (when (< start end) (let ((inhibit-read-only t)) (cider-repl--clear-region start end) |