Commit 54cc6a83 authored by Eli Zaretskii's avatar Eli Zaretskii
Browse files

Fix bug #6349 with cursor positioning in truncated lines.

 xdisp.c (set_cursor_from_row): When the row is truncated and
 point is outside the range of displayed characters, position the
 cursor inside the scroll margin.
parent 82b9f9f5
2010-10-01 Eli Zaretskii <eliz@gnu.org>
* xdisp.c (set_cursor_from_row): When the row is truncated and
point is outside the range of displayed characters, position the
cursor inside the scroll margin. (Bug#6349)
2010-10-01 Dan Nicolaescu <dann@ics.uci.edu> 2010-10-01 Dan Nicolaescu <dann@ics.uci.edu>
   
Do not include stdlib.h and string.h, config.h does it. Do not include stdlib.h and string.h, config.h does it.
......
...@@ -12494,8 +12494,10 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, ...@@ -12494,8 +12494,10 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
/* Non-zero means we've seen at least one glyph that came from a /* Non-zero means we've seen at least one glyph that came from a
display string. */ display string. */
int string_seen = 0; int string_seen = 0;
/* Largest buffer position seen so far during scan of glyph row. */ /* Largest and smalles buffer positions seen so far during scan of
EMACS_INT bpos_max = last_pos; glyph row. */
EMACS_INT bpos_max = pos_before;
EMACS_INT bpos_min = pos_after;
/* Last buffer position covered by an overlay string with an integer /* Last buffer position covered by an overlay string with an integer
`cursor' property. */ `cursor' property. */
EMACS_INT bpos_covered = 0; EMACS_INT bpos_covered = 0;
...@@ -12585,6 +12587,8 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, ...@@ -12585,6 +12587,8 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
   
if (glyph->charpos > bpos_max) if (glyph->charpos > bpos_max)
bpos_max = glyph->charpos; bpos_max = glyph->charpos;
if (glyph->charpos < bpos_min)
bpos_min = glyph->charpos;
if (!glyph->avoid_cursor_p) if (!glyph->avoid_cursor_p)
{ {
/* If we hit point, we've found the glyph on which to /* If we hit point, we've found the glyph on which to
...@@ -12659,6 +12663,8 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, ...@@ -12659,6 +12663,8 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
   
if (glyph->charpos > bpos_max) if (glyph->charpos > bpos_max)
bpos_max = glyph->charpos; bpos_max = glyph->charpos;
if (glyph->charpos < bpos_min)
bpos_min = glyph->charpos;
if (!glyph->avoid_cursor_p) if (!glyph->avoid_cursor_p)
{ {
if (dpos == 0) if (dpos == 0)
...@@ -12745,7 +12751,13 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, ...@@ -12745,7 +12751,13 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
} }
} }
else if (match_with_avoid_cursor else if (match_with_avoid_cursor
/* zero-width characters produce no glyphs */ /* A truncated row may not include PT among its
character positions. Setting the cursor inside the
scroll margin will trigger recalculation of hscroll
in hscroll_window_tree. */
|| (row->truncated_on_left_p && pt_old < bpos_min)
|| (row->truncated_on_right_p && pt_old > bpos_max)
/* Zero-width characters produce no glyphs. */
|| ((row->reversed_p || ((row->reversed_p
? glyph_after > glyphs_end ? glyph_after > glyphs_end
: glyph_after < glyphs_end) : glyph_after < glyphs_end)
......
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