From: Martin Rudalics Date: Mon, 19 May 2025 07:14:15 +0000 (+0200) Subject: Fix thinko in 'fit-frame-to-buffer-1' (Bug#78418) X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=4f5412ca4cce3e5a225f5e73879941d753f85973;p=emacs.git Fix thinko in 'fit-frame-to-buffer-1' (Bug#78418) * lisp/window.el (fit-frame-to-buffer-1): Don't add extra line when character sizes evenly divide decorations sizes (Bug#78418). (cherry picked from commit 0de59ded25aa9f1751edb7170c51a98be70b7edf) --- diff --git a/lisp/window.el b/lisp/window.el index 052547de7df..60ccc4c839d 100644 --- a/lisp/window.el +++ b/lisp/window.el @@ -10111,14 +10111,14 @@ for `fit-frame-to-buffer'." ;; this may cause lines getting wrapped. To avoid that, round ;; sizes up here which will, however, leave a blank space at the ;; end of the longest line(s). - (setq text-minus-body-width - (+ text-minus-body-width - (- char-width - (% text-minus-body-width char-width)))) - (setq text-minus-body-height - (+ text-minus-body-height - (- char-height - (% text-minus-body-height char-height))))) + (let ((remainder (% text-minus-body-width char-width))) + (unless (zerop remainder) + (setq text-minus-body-width + (+ text-minus-body-width (- char-width remainder))))) + (let ((remainder (% text-minus-body-height char-height))) + (unless (zerop remainder) + (setq text-minus-body-height + (+ text-minus-body-height(- char-height remainder)))))) (setq text-width (if width (+ width text-minus-body-width)