Reuse the old preview buffer/window such that display-buffer behaves

Before, the buffer is killed and then recreated. This causes wrong
behavior for display-buffer when display-buffer-reuse-window and
display-buffer-same-window is used: the first one fails so the same
window is used where the diagram source is situated.

Instead, reuse the buffer and its window, so don't kill the buffer,
erase it instead.
This commit is contained in:
Bram Schoenmakers 2022-09-08 07:05:43 +02:00
parent ea45a13707
commit 2134815c6c
1 changed files with 4 additions and 2 deletions

View File

@ -404,7 +404,8 @@ Window is selected according to PREFIX:
(when imagep
(with-current-buffer buf
(image-mode)
(set-buffer-multibyte t)))))
(set-buffer-multibyte t)))
(set-window-point (get-buffer-window buf 'visible) (point-min))))
(defun plantuml-jar-preview-string (prefix string buf)
"Preview the diagram from STRING by running the PlantUML JAR.
@ -484,7 +485,8 @@ Put the result into buffer BUF, selecting the window according to PREFIX:
to choose where to display it."
(let ((b (get-buffer plantuml-preview-buffer)))
(when b
(kill-buffer b)))
(with-current-buffer b
(erase-buffer))))
(let* ((imagep (and (display-images-p)
(plantuml-is-image-output-p)))