]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix thinko in 'fit-frame-to-buffer-1' (Bug#78418)
authorMartin Rudalics <rudalics@gmx.at>
Mon, 19 May 2025 07:14:15 +0000 (09:14 +0200)
committerEshel Yaron <me@eshelyaron.com>
Wed, 21 May 2025 06:12:32 +0000 (08:12 +0200)
* 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)

lisp/window.el

index 052547de7df79b9c5ff86c1f280b2c1966f77464..60ccc4c839da965169e792cda691ee6c1cd3b843 100644 (file)
@@ -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)