Fix rect mark mess up in unselected windows

* lisp/rect.el (rectangle--highlight-for-redisplay): Move
`save-excursion' inside `with-selected-window' to ensure it always takes
effect.  (Bug#81451)
This commit is contained in:
Michael Heerdegen 2026-07-24 04:58:58 +02:00
parent a1fa371488
commit 6534d67a1f

View file

@ -868,16 +868,16 @@ Ignores `line-move-visual'."
(eq (nth 5 rol) (point)))
rol)
(t
(save-excursion
(let* ((pt (point))
(nrol nil)
(old (if (eq 'rectangle (car-safe rol))
(nthcdr 6 rol)
(funcall redisplay-unhighlight-region-function rol)
nil)))
(cl-assert (eq (window-buffer window) (current-buffer)))
;; `rectangle--pos-cols' looks up the `selected-window's parameter!
(with-selected-window window
(let* ((pt (point))
(nrol nil)
(old (if (eq 'rectangle (car-safe rol))
(nthcdr 6 rol)
(funcall redisplay-unhighlight-region-function rol)
nil)))
(cl-assert (eq (window-buffer window) (current-buffer)))
;; `rectangle--pos-cols' looks up the `selected-window's parameter!
(with-selected-window window
(save-excursion
(let* ((cols (rectangle--pos-cols start end))
(startcol (car cols))
(endcol (cdr cols))
@ -976,12 +976,12 @@ Ignores `line-move-visual'."
(and (zerop (forward-line 1))
(bolp)
(<= (point) end-pt))))
)
)
(mapc #'delete-overlay old)
`(rectangle ,(buffer-chars-modified-tick)
,start ,end ,(rectangle--crutches) ,pt
,@nrol))))))
))
)
(mapc #'delete-overlay old)
`(rectangle ,(buffer-chars-modified-tick)
,start ,end ,(rectangle--crutches) ,pt
,@nrol)))))
(defun rectangle--unhighlight-for-redisplay (orig rol)
(if (not (eq 'rectangle (car-safe rol)))