fix(eval): overlay position
Fix: #7732 Close: #7734 Co-authored-by: pysnow530 <pysnow530@users.noreply.github.com>
This commit is contained in:
parent
e8897421b1
commit
b6e7bbbe07
1 changed files with 24 additions and 25 deletions
|
@ -24,34 +24,33 @@
|
||||||
(defun +eval-display-results-in-overlay (output &optional source-buffer)
|
(defun +eval-display-results-in-overlay (output &optional source-buffer)
|
||||||
"Display OUTPUT in a floating overlay next to the cursor."
|
"Display OUTPUT in a floating overlay next to the cursor."
|
||||||
(require 'eros)
|
(require 'eros)
|
||||||
(let* ((this-command #'+eval/buffer-or-region)
|
(with-current-buffer (or source-buffer (current-buffer))
|
||||||
(prefix eros-eval-result-prefix)
|
(let* ((this-command #'+eval/buffer-or-region)
|
||||||
(lines (split-string output "\n"))
|
(prefix eros-eval-result-prefix)
|
||||||
(prefixlen (length prefix))
|
(lines (split-string output "\n"))
|
||||||
(len (+ (apply #'max (mapcar #'length lines))
|
(prefixlen (length prefix))
|
||||||
prefixlen))
|
(len (+ (apply #'max (mapcar #'length lines))
|
||||||
(col (- (current-column) (window-hscroll)))
|
prefixlen))
|
||||||
(next-line? (or (cdr lines)
|
(col (- (current-column) (window-hscroll)))
|
||||||
(< (- (window-width)
|
(next-line? (or (cdr lines)
|
||||||
(save-excursion (goto-char (point-at-eol))
|
(< (- (window-width)
|
||||||
(- (current-column)
|
(save-excursion (goto-char (line-end-position))
|
||||||
(window-hscroll))))
|
(- (current-column)
|
||||||
len)))
|
(window-hscroll))))
|
||||||
(pad (if next-line?
|
len)))
|
||||||
(+ (window-hscroll) prefixlen)
|
(pad (if next-line?
|
||||||
0))
|
(+ (window-hscroll) prefixlen)
|
||||||
(where (if next-line?
|
0))
|
||||||
(line-beginning-position 2)
|
eros-overlays-use-font-lock)
|
||||||
(line-end-position)))
|
|
||||||
eros-eval-result-prefix
|
|
||||||
eros-overlays-use-font-lock)
|
|
||||||
(with-current-buffer (or source-buffer (current-buffer))
|
|
||||||
(eros--make-result-overlay
|
(eros--make-result-overlay
|
||||||
(concat (make-string (max 0 (- pad prefixlen)) ?\s)
|
(concat (make-string (max 0 (- pad prefixlen)) ?\s)
|
||||||
prefix
|
prefix
|
||||||
(string-join lines (concat "\n" (make-string pad ?\s))))
|
(string-join lines (concat hard-newline (make-string pad ?\s))))
|
||||||
:where where
|
:where (if next-line?
|
||||||
:duration eros-eval-result-duration))))
|
(line-beginning-position 2)
|
||||||
|
(line-end-position))
|
||||||
|
:duration eros-eval-result-duration
|
||||||
|
:format "%s"))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
(defun +eval-display-results (output &optional source-buffer)
|
(defun +eval-display-results (output &optional source-buffer)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue