From bb094973b16ed6ba58ffb0eff58a6276e3413b1b Mon Sep 17 00:00:00 2001 From: Lars Andersen Date: Mon, 17 Aug 2015 09:44:58 +0200 Subject: [PATCH] [Fix #1252] Fix breakage in cider-repl-clear-buffer After running cider-repl-clear-buffer and then loading a file creating output (e.g. because it contains println statements) the output would appear in the wrong place, causing the prompt to disappear. The problem was in the function responsible for putting POINT in the right place before emitting evaluation results into the repl buffer. When the prompt was the first line in the buffer, cider-repl--end-of-line-before-input-start didn't move point at all. There's now a special case in place to handle this situation. I initially considered solving this problem by making sure that the prompt wasn't the first line in the buffer, after noticing that he banner was being deleted by cider-repl-clear-buffer. While I think the banner should be preserved by this function, the banner itself is optional so this was a non-solution. --- CHANGELOG.md | 2 +- cider-repl.el | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5810c562f..3f231cdc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,7 +39,7 @@ * Renamed `cider-repl-output-face` to `cider-repl-stdout-face` and `cider-repl-err-output-face` to `cider-repl-stderr-face`. ### Bugs fixed - +* [#1252](https://github.com/clojure-emacs/cider/issues/1252) `cider-repl-clear-buffer` stops working in certain circumstances. * [#1164](https://github.com/clojure-emacs/cider/pull/1164): Fix an error in `cider-browse-ns--doc-at-point`. * [#1189](https://github.com/clojure-emacs/cider/issues/1189): Don't show result from automatic ns form evaluation. * [#1079](https://github.com/clojure-emacs/cider/issues/1079): Don't try to font-lock very long results. The maximum font-lockable result length is controlled by `cider-font-lock-max-length`. diff --git a/cider-repl.el b/cider-repl.el index 461211762..941c3758f 100644 --- a/cider-repl.el +++ b/cider-repl.el @@ -688,10 +688,10 @@ text property `cider-old-input'." "Return the position of the end of the line preceding the beginning of input." (save-excursion (goto-char cider-repl-input-start-mark) - ;; do not use `previous-line', but `line-move' with noerror - ;; moving up from the first line should not throw error - (line-move -1 t nil nil) - (line-end-position))) + (if (= (line-number-at-pos) 1) + (goto-char (point-min)) + (line-move -1) + (line-end-position)))) (defun cider-repl-clear-output () "Delete the output inserted since the last input."