summaryrefslogtreecommitdiff
path: root/cider-repl.el
diff options
context:
space:
mode:
authorVitalie Spinu <spinuvit@gmail.com>2018-11-22 14:29:49 +0100
committerBozhidar Batsov <bozhidar.batsov@gmail.com>2018-11-23 15:37:10 +0000
commit6813fe93141556cc716498ecffcff33c364e3b9c (patch)
tree9a8216724596bb81b34f6094a5cc9e3d20045494 /cider-repl.el
parent1fd1275a5621096bb3320498e032db3764d09f56 (diff)
[Fix #2474] Fix end-of-output detection
Diffstat (limited to 'cider-repl.el')
-rw-r--r--cider-repl.el18
1 files changed, 11 insertions, 7 deletions
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)