Commit e71f5d99 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Fix the last part of bug #10464 with mouse highlight at end of line.

 src/xdisp.c (rows_from_pos_range): Handle the case where the
 highlight ends on a newline.
 (mouse_face_from_buffer_pos): Fix off-by-one error in calculating
 he end column for display of highlight that ends on a newline
 before a R2L line.
parent cc7f8e29
2012-01-11 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (rows_from_pos_range): Handle the case where the
highlight ends on a newline. (Bug#10464)
(mouse_face_from_buffer_pos): Fix off-by-one error in calculating
he end column for display of highlight that ends on a newline
before a R2L line.
2012-01-11 Glenn Morris <rgm@gnu.org>
* lread.c (init_lread): If no-site-lisp, remove site-lisp dirs
......
......@@ -25899,14 +25899,15 @@ rows_from_pos_range (struct window *w,
for ( ; row->enabled_p && MATRIX_ROW_BOTTOM_Y (row) <= last_y; row++)
{
struct glyph_row *next = row + 1;
EMACS_INT next_start = MATRIX_ROW_START_CHARPOS (next);
if (!next->enabled_p
|| next >= MATRIX_BOTTOM_TEXT_ROW (w->current_matrix, w)
/* The first row >= START whose range of displayed characters
does NOT intersect the range [START_CHARPOS..END_CHARPOS]
is the row END + 1. */
|| (start_charpos < MATRIX_ROW_START_CHARPOS (next)
&& end_charpos < MATRIX_ROW_START_CHARPOS (next))
|| (start_charpos < next_start
&& end_charpos < next_start)
|| ((start_charpos > MATRIX_ROW_END_CHARPOS (next)
|| (start_charpos == MATRIX_ROW_END_CHARPOS (next)
&& !next->ends_at_zv_p
......@@ -25925,12 +25926,26 @@ rows_from_pos_range (struct window *w,
but none of the characters it displays are in the range, it is
also END + 1. */
struct glyph *g = next->glyphs[TEXT_AREA];
struct glyph *s = g;
struct glyph *e = g + next->used[TEXT_AREA];
while (g < e)
{
if (((BUFFERP (g->object) || INTEGERP (g->object))
&& start_charpos <= g->charpos && g->charpos < end_charpos)
&& (start_charpos <= g->charpos && g->charpos < end_charpos
/* If the buffer position of the first glyph in
the row is equal to END_CHARPOS, it means
the last character to be highlighted is the
newline of ROW, and we must consider NEXT as
END, not END+1. */
|| ((!next->reversed_p && g == s
|| next->reversed_p && g == e - 1)
&& (g->charpos == end_charpos
/* Special case for when NEXT is an
empty line at ZV. */
|| (g->charpos == -1
&& !row->ends_at_zv_p
&& next_start == end_charpos)))))
/* A glyph that comes from DISP_STRING is by
definition to be highlighted. */
|| EQ (g->object, disp_string))
......@@ -25942,6 +25957,13 @@ rows_from_pos_range (struct window *w,
*end = row;
break;
}
/* The first row that ends at ZV must be the last to be
highlighted. */
else if (next->ends_at_zv_p)
{
*end = next;
break;
}
}
}
}
......@@ -26255,6 +26277,19 @@ mouse_face_from_buffer_pos (Lisp_Object window,
}
x += end->pixel_width;
}
/* If we exited the above loop because we arrived at the last
glyph of the row, and its buffer position is still not in
range, it means the last character in range is the preceding
newline. Bump the end column and x values to get past the
last glyph. */
if (end == glyph
&& BUFFERP (end->object)
&& (end->charpos < start_charpos
|| end->charpos >= end_charpos))
{
x += end->pixel_width;
++end;
}
hlinfo->mouse_face_end_x = x;
hlinfo->mouse_face_end_col = end - r2->glyphs[TEXT_AREA];
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment