From: Eli Zaretskii Date: Sat, 16 Jun 2012 09:57:56 +0000 (+0300) Subject: Fix bug #11653 with cursor positioning in a row that has only strings. X-Git-Tag: emacs-24.2.90~1199^2~463 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=2f07e6afc932d0be7256c7700e9c11d61075aeaf;p=emacs.git Fix bug #11653 with cursor positioning in a row that has only strings. src/xdisp.c (set_cursor_from_row): Don't dereference glyphs_end. If all the glyphs of the glyph row came from strings, and we have no cursor positioning clues, put the cursor on the first glyph of the row. --- diff --git a/src/ChangeLog b/src/ChangeLog index b5a22a0ebce..3138bea28fa 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,10 @@ +2012-06-16 Eli Zaretskii + + * xdisp.c (set_cursor_from_row): Don't dereference glyphs_end. If + all the glyphs of the glyph row came from strings, and we have no + cursor positioning clues, put the cursor on the first glyph of the + row. (Bug#11653) + 2012-06-16 Andreas Schwab * category.h (CHAR_HAS_CATEGORY): Define as inline. diff --git a/src/xdisp.c b/src/xdisp.c index 0eae25de54a..e09116fe0ca 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -14260,6 +14260,7 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, the cursor is not on this line. */ if (cursor == NULL && (row->reversed_p ? glyph <= end : glyph >= end) + && (row->reversed_p ? end > glyphs_end : end < glyphs_end) && STRINGP (end->object) && row->continued_p) return 0; @@ -14289,6 +14290,21 @@ set_cursor_from_row (struct window *w, struct glyph_row *row, compute_x: if (cursor != NULL) glyph = cursor; + else if (glyph == glyphs_end + && pos_before == pos_after + && STRINGP ((row->reversed_p + ? row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1 + : row->glyphs[TEXT_AREA])->object)) + { + /* If all the glyphs of this row came from strings, put the + cursor on the first glyph of the row. This avoids having the + cursor outside of the text area in this very rare and hard + use case. */ + glyph = + row->reversed_p + ? row->glyphs[TEXT_AREA] + row->used[TEXT_AREA] - 1 + : row->glyphs[TEXT_AREA]; + } if (x < 0) { struct glyph *g;