From 6dd5a677dbf794eedaa8325c46d57ac041373361 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Thu, 5 Jul 2012 19:28:34 +0300 Subject: [PATCH] Avoid long futile looping on a TTY under huge values of hscroll. src/xdisp.c (display_line): Fix horizontal pixel coordinates when hscroll is larger than the line width. Fixes long and futile looping inside extend_face_to_end_of_line (on a TTY) producing glyphs that are not needed and thrown away. --- src/ChangeLog | 7 +++++++ src/xdisp.c | 17 +++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index a2cfd3029f3..1fdeee52f7f 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-07-05 Eli Zaretskii + + * xdisp.c (display_line): Fix horizontal pixel coordinates when + hscroll is larger than the line width. Fixes long and futile + looping inside extend_face_to_end_of_line (on a TTY) producing + glyphs that are not needed and thrown away. + 2012-07-05 Dmitry Antipov * marker.c (set_marker_restricted_both): Simplify by using diff --git a/src/xdisp.c b/src/xdisp.c index d24c05172b6..0c210198fc5 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -19177,9 +19177,22 @@ display_line (struct it *it) if the first glyph is partially visible or if we hit a line end. */ if (it->current_x < it->first_visible_x) { + enum move_it_result move_result; + this_line_min_pos = row->start.pos; - move_it_in_display_line_to (it, ZV, it->first_visible_x, - MOVE_TO_POS | MOVE_TO_X); + move_result = move_it_in_display_line_to (it, ZV, it->first_visible_x, + MOVE_TO_POS | MOVE_TO_X); + /* If we are under a large hscroll, move_it_in_display_line_to + could hit the end of the line without reaching + it->first_visible_x. Pretend that we did reach it. This is + especially important on a TTY, where we will call + extend_face_to_end_of_line, which needs to know how many + blank glyphs to produce. */ + if (it->current_x < it->first_visible_x + && (move_result == MOVE_NEWLINE_OR_CR + || move_result == MOVE_POS_MATCH_OR_ZV)) + it->current_x = it->first_visible_x; + /* Record the smallest positions seen while we moved over display elements that are not visible. This is needed by redisplay_internal for optimizing the case where the cursor -- 2.39.2