From 7b7e2c18a64fe2de45d80dfc6f48645f3e126440 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 23 Oct 2010 14:28:28 +0200 Subject: [PATCH] Tested with L2R rows and mouse highlight on a single line. xdisp.c (mouse_face_from_string_pos): Initialize the `found' flag to zero, and exit the outer loop when it's non-zero. Bail our early if no row in the window belongs to the highlighted string. Always back up after exiting the second loop. --- src/ChangeLog | 7 +++++++ src/xdisp.c | 11 ++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 04861f77082..0cd77348d12 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2010-10-23 Eli Zaretskii + + * xdisp.c (mouse_face_from_string_pos): Initialize the `found' + flag to zero, and exit the outer loop when it's non-zero. Bail + our early if no row in the window belongs to the highlighted + string. Always back up after exiting the second loop. + 2010-10-16 Eli Zaretskii * xdisp.c (fast_find_string_pos): #ifdef away, not used anymore. diff --git a/src/xdisp.c b/src/xdisp.c index 9b58e70176d..5a7ba32b678 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -24422,7 +24422,7 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo, struct glyph_row *r; struct glyph *g, *e; int gx; - int found; + int found = 0; /* Find the glyph row with at least one position in the range [STARTPOS..ENDPOS), and the leftmost glyph in that row whose @@ -24451,10 +24451,16 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo, dpyinfo->mouse_face_end_col = g - r->glyphs[TEXT_AREA]; dpyinfo->mouse_face_end_x = gx; } + found = 1; break; } + if (found) + break; } + if (!found) + return; + /* Starting with the next row, look for the first row which does NOT include any glyphs whose positions are in the range. */ for (++r; r->enabled_p && r->y < yb; ++r) @@ -24472,9 +24478,8 @@ mouse_face_from_string_pos (struct window *w, Display_Info *dpyinfo, if (!found) break; } + r--; - if (!found) - r--; dpyinfo->mouse_face_end_row = r - w->current_matrix->rows; dpyinfo->mouse_face_end_y = r->y; -- 2.39.5