From: Eli Zaretskii Date: Mon, 23 Sep 2013 09:18:38 +0000 (+0300) Subject: Fix bug #15437 with mouse highlight on overlay strings. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~1470 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=f03eddbff64da3a9304b2c654b6f46b58f318787;p=emacs.git Fix bug #15437 with mouse highlight on overlay strings. src/xdisp.c (mouse_face_from_string_pos): Fix off-by-one error in computing the end column of mouse-highlight that comes from display or overlay strings. --- diff --git a/src/ChangeLog b/src/ChangeLog index 093368568c2..8483bdc6216 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,9 @@ 2013-09-23 Eli Zaretskii + * xdisp.c (mouse_face_from_string_pos): Fix off-by-one error in + computing the end column of mouse-highlight that comes from + display or overlay strings. (Bug#15437) + * conf_post.h (__has_builtin): Define to zero, if undefined, on all platforms, not just for clang. diff --git a/src/xdisp.c b/src/xdisp.c index bfd86758a1e..0575c7b3282 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -27381,7 +27381,7 @@ fast_find_string_pos (struct window *w, ptrdiff_t pos, Lisp_Object object, #endif /* not used */ /* Find the positions of the first and the last glyphs in window W's - current matrix that occlude positions [STARTPOS..ENDPOS] in OBJECT + current matrix that occlude positions [STARTPOS..ENDPOS) in OBJECT (assumed to be a string), and return in HLINFO's mouse_face_* members the pixel and column/row coordinates of those glyphs. */ @@ -27397,7 +27397,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo, int found = 0; /* Find the glyph row with at least one position in the range - [STARTPOS..ENDPOS], and the first glyph in that row whose + [STARTPOS..ENDPOS), and the first glyph in that row whose position belongs to that range. */ for (r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); r->enabled_p && r->y < yb; @@ -27409,7 +27409,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo, e = g + r->used[TEXT_AREA]; for (gx = r->x; g < e; gx += g->pixel_width, ++g) if (EQ (g->object, object) - && startpos <= g->charpos && g->charpos <= endpos) + && startpos <= g->charpos && g->charpos < endpos) { hlinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (r, w->current_matrix); @@ -27427,7 +27427,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo, g = e + r->used[TEXT_AREA]; for ( ; g > e; --g) if (EQ ((g-1)->object, object) - && startpos <= (g-1)->charpos && (g-1)->charpos <= endpos) + && startpos <= (g-1)->charpos && (g-1)->charpos < endpos) { hlinfo->mouse_face_beg_row = MATRIX_ROW_VPOS (r, w->current_matrix); @@ -27455,7 +27455,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo, found = 0; for ( ; g < e; ++g) if (EQ (g->object, object) - && startpos <= g->charpos && g->charpos <= endpos) + && startpos <= g->charpos && g->charpos < endpos) { found = 1; break; @@ -27478,7 +27478,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo, e = g + r->used[TEXT_AREA]; for ( ; e > g; --e) if (EQ ((e-1)->object, object) - && startpos <= (e-1)->charpos && (e-1)->charpos <= endpos) + && startpos <= (e-1)->charpos && (e-1)->charpos < endpos) break; hlinfo->mouse_face_end_col = e - g; @@ -27493,7 +27493,7 @@ mouse_face_from_string_pos (struct window *w, Mouse_HLInfo *hlinfo, for (gx = r->x ; e < g; ++e) { if (EQ (e->object, object) - && startpos <= e->charpos && e->charpos <= endpos) + && startpos <= e->charpos && e->charpos < endpos) break; gx += e->pixel_width; }