fix(eval): overlay position

Fix: #7732
Close: #7734
Co-authored-by: pysnow530 <pysnow530@users.noreply.github.com>
This commit is contained in:
Henrik Lissner 2024-03-18 20:45:11 -04:00
parent e8897421b1
commit b6e7bbbe07
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -24,6 +24,7 @@
(defun +eval-display-results-in-overlay (output &optional source-buffer)
"Display OUTPUT in a floating overlay next to the cursor."
(require 'eros)
(with-current-buffer (or source-buffer (current-buffer))
(let* ((this-command #'+eval/buffer-or-region)
(prefix eros-eval-result-prefix)
(lines (split-string output "\n"))
@ -33,25 +34,23 @@
(col (- (current-column) (window-hscroll)))
(next-line? (or (cdr lines)
(< (- (window-width)
(save-excursion (goto-char (point-at-eol))
(save-excursion (goto-char (line-end-position))
(- (current-column)
(window-hscroll))))
len)))
(pad (if next-line?
(+ (window-hscroll) prefixlen)
0))
(where (if next-line?
(line-beginning-position 2)
(line-end-position)))
eros-eval-result-prefix
eros-overlays-use-font-lock)
(with-current-buffer (or source-buffer (current-buffer))
(eros--make-result-overlay
(concat (make-string (max 0 (- pad prefixlen)) ?\s)
prefix
(string-join lines (concat "\n" (make-string pad ?\s))))
:where where
:duration eros-eval-result-duration))))
(string-join lines (concat hard-newline (make-string pad ?\s))))
:where (if next-line?
(line-beginning-position 2)
(line-end-position))
:duration eros-eval-result-duration
:format "%s"))))
;;;###autoload
(defun +eval-display-results (output &optional source-buffer)