# HG changeset patch # User Miles Bader # Date 975658276 0 # Node ID 6316cacc1e16fda9b1728dbd628f5a7e540125b9 # Parent ebb2d5e5973e0b4ffb4e389a1a79d66c9ee9ed90 (fit-window-to-buffer): Handle non-nil `truncate-lines'. diff -r ebb2d5e5973e -r 6316cacc1e16 lisp/window.el --- a/lisp/window.el Fri Dec 01 06:20:04 2000 +0000 +++ b/lisp/window.el Fri Dec 01 08:11:16 2000 +0000 @@ -508,9 +508,17 @@ (let ((end (with-current-buffer buf (save-excursion (goto-char (point-max)) - (if (and (bolp) (not (bobp))) - (1- (point)) - (point)))))) + (when (and (bolp) (not (bobp))) + ;; Don't include final newline + (backward-char 1)) + (when truncate-lines + ;; If line-wrapping is turned off, test the + ;; beginning of the last line for visibility + ;; instead of the end, as the end of the line + ;; could be invisible by virtue of extending past + ;; the edge of the window. + (forward-line 0)) + (point))))) (set-window-vscroll window 0) (while (and (< desired-height max-height) (= desired-height (window-height window))