summaryrefslogtreecommitdiff
path: root/cider-overlays.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2016-04-03 15:46:36 -0300
committerArtur Malabarba <bruce.connor.am@gmail.com>2016-04-03 15:48:32 -0300
commit0c07030259916e4425d4f726b1693b57b5959641 (patch)
treecd6a712bc4403767c6daf435f90dda71d0d54aab /cider-overlays.el
parent6f2fbb2e473c5a1dfe2777059f15d0480b328061 (diff)
Display multi-line eval overlays at the start of the following line
It looked weird that these overlays started on the middle of a line, but then folded onto the start of following lines.
Diffstat (limited to 'cider-overlays.el')
-rw-r--r--cider-overlays.el10
1 files changed, 9 insertions, 1 deletions
diff --git a/cider-overlays.el b/cider-overlays.el
index 2e845491..56720152 100644
--- a/cider-overlays.el
+++ b/cider-overlays.el
@@ -168,13 +168,21 @@ overlay."
(display-string (format format value))
(o nil))
(remove-overlays beg end 'cider-type type)
- (put-text-property 0 1 'cursor 0 display-string)
(funcall (if cider-overlays-use-font-lock
#'font-lock-prepend-text-property
#'put-text-property)
0 (length display-string)
'face prepend-face
display-string)
+ ;; If the display spans multiple lines or is very long, display it at
+ ;; the beginning of the next line.
+ (when (or (string-match "\n." display-string)
+ (> (string-width display-string)
+ (- (window-width) (current-column))))
+ (setq display-string (concat " \n" display-string)))
+ ;; Put the cursor property only once we're done manipulating the
+ ;; string, since we want it to be at the first char.
+ (put-text-property 0 1 'cursor 0 display-string)
(setq o (apply #'cider--make-overlay
beg end type
'after-string display-string