From 4f5412ca4cce3e5a225f5e73879941d753f85973 Mon Sep 17 00:00:00 2001 From: Martin Rudalics Date: Mon, 19 May 2025 09:14:15 +0200 Subject: [PATCH] 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) --- lisp/window.el | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) 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) -- 2.39.5