Skip to content

Commit 2e213f9

Browse files
committed
[Fix #3219] Speed up printing output in the REPL buffer
I've opted to disable by default forcing the display of output when the REPL prompt is at the first line of the of the REPL window. This behavior is desirable, but very slow and rarely needed. It can be re-enabled by setting `cider-repl-display-output-before-window-boundaries` to `t`.
1 parent 1ed5163 commit 2e213f9

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
- Allow using `npx nbb` as `cider-nbb-command`.
1616
- [#3281](https://github.com/clojure-emacs/cider/pull/3281): Replace newline chars with actual newlines in `*cider-test-report*` buffer, for prettier error messages.
1717
- Bump the injected `cider-nrepl` to 0.30.
18+
- [#3219](https://github.com/clojure-emacs/cider/issues/3219): Disable by default forcing the display of output when the REPL prompt is at the first line of the of the REPL window. This behavior is desirable, but very slow and rarely needed. It can be re-enabled by setting `cider-repl-display-output-before-window-boundaries` to `t`.
1819

1920
## 1.6.0 (2022-12-21)
2021

cider-repl.el

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,19 @@ Will be evaluated with bindings for set!-able vars in place."
168168
:type 'boolean
169169
:package-version '(cider . "0.11.0"))
170170

171+
;; See https://github.com/clojure-emacs/cider/issues/3219 for more details
172+
(defcustom cider-repl-display-output-before-window-boundaries nil
173+
"Controls whether to display output emitted before the REPL window boundaries.
174+
175+
If the prompt is on the first line of the window, then scroll the window
176+
down by a single line to make the emitted output visible.
177+
178+
That behavior is desirable, but rarely needed and it slows down printing
179+
output a lot (e.g. 10x) that's why it's disable by default starting with
180+
CIDER 1.7."
181+
:type 'boolean
182+
:package-version '(cider . "1.7.0"))
183+
171184

172185
;;;; REPL buffer local variables
173186
(defvar-local cider-repl-input-start-mark nil)
@@ -778,14 +791,16 @@ Before inserting, run `cider-repl-preoutput-hook' on STRING."
778791
(not (bolp)))
779792
(insert-before-markers "\n")
780793
(set-marker cider-repl-output-end (1- (point))))))
781-
(when-let* ((window (get-buffer-window buffer t)))
782-
;; If the prompt is on the first line of the window, then scroll the window
783-
;; down by a single line to make the emitted output visible.
784-
(when (and (pos-visible-in-window-p cider-repl-prompt-start-mark window)
785-
(< 1 cider-repl-prompt-start-mark)
786-
(not (pos-visible-in-window-p (1- cider-repl-prompt-start-mark) window)))
787-
(with-selected-window window
788-
(scroll-down 1)))))
794+
(when cider-repl-display-output-before-window-boundaries
795+
;; FIXME: The code below is super slow, that's why it's disabled by default.
796+
(when-let* ((window (get-buffer-window buffer t)))
797+
;; If the prompt is on the first line of the window, then scroll the window
798+
;; down by a single line to make the emitted output visible.
799+
(when (and (pos-visible-in-window-p cider-repl-prompt-start-mark window)
800+
(< 1 cider-repl-prompt-start-mark)
801+
(not (pos-visible-in-window-p (1- cider-repl-prompt-start-mark) window)))
802+
(with-selected-window window
803+
(scroll-down 1))))))
789804

790805
(defun cider-repl--emit-interactive-output (string face)
791806
"Emit STRING as interactive output using FACE."

0 commit comments

Comments
 (0)