summaryrefslogtreecommitdiff
path: root/src/xdisp.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2021-02-24 17:43:08 +0200
committerEli Zaretskii <eliz@gnu.org>2021-02-24 17:43:08 +0200
commiteef185dfc82330198b77b46cf7e48f8142c55ea2 (patch)
treece9ea28800d94f0713ea74a1ff0d5320a7060e68 /src/xdisp.c
parent91b37381eaa8db64965249b5a3a377c51d0afa1b (diff)
downloademacs-eef185dfc82330198b77b46cf7e48f8142c55ea2.tar.gz
emacs-eef185dfc82330198b77b46cf7e48f8142c55ea2.tar.bz2
emacs-eef185dfc82330198b77b46cf7e48f8142c55ea2.zip
Better support for 'truncate-line' non-nil in the mini-window
* src/xdisp.c (resize_mini_window): Resize the mini-window when multi-line text is displayed under truncate-lines non-nil in the minibuffer. (Bug#46718)
Diffstat (limited to 'src/xdisp.c')
-rw-r--r--src/xdisp.c31
1 files changed, 20 insertions, 11 deletions
diff --git a/src/xdisp.c b/src/xdisp.c
index f86d3527b3d..cd3455aefcf 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -11857,18 +11857,27 @@ resize_mini_window (struct window *w, bool exact_p)
max_height = clip_to_bounds (unit, max_height, windows_height);
/* Find out the height of the text in the window. */
- if (it.line_wrap == TRUNCATE)
- height = unit;
- else
- {
- last_height = 0;
- move_it_to (&it, ZV, -1, -1, -1, MOVE_TO_POS);
- if (it.max_ascent == 0 && it.max_descent == 0)
- height = it.current_y + last_height;
- else
- height = it.current_y + it.max_ascent + it.max_descent;
- height -= min (it.extra_line_spacing, it.max_extra_line_spacing);
+ last_height = 0;
+ move_it_to (&it, ZV, -1, -1, -1, MOVE_TO_POS);
+ /* If move_it_to moved to the next visible line after EOB,
+ account for the height of the last full line. */
+ if (it.max_ascent == 0 && it.max_descent == 0)
+ {
+ height = it.current_y;
+ /* Don't add the last line's height if lines are truncated
+ and the text doesn't end in a newline.
+ FIXME: if the text ends in a newline from a display
+ property or an overlay string, they lose: the mini-window
+ might not show the last empty line. */
+ if (!(it.line_wrap == TRUNCATE
+ && it.current_x <= it.first_visible_x
+ && ZV_BYTE > 1
+ && FETCH_BYTE (ZV_BYTE - 1) != '\n'))
+ height += last_height;
}
+ else
+ height = it.current_y + it.max_ascent + it.max_descent;
+ height -= min (it.extra_line_spacing, it.max_extra_line_spacing);
/* Compute a suitable window start. */
if (height > max_height)