]> code.delx.au - gnu-emacs/commitdiff
Fix bug #11653 with cursor positioning in a row that has only strings.
authorEli Zaretskii <eliz@gnu.org>
Sat, 16 Jun 2012 09:57:56 +0000 (12:57 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 16 Jun 2012 09:57:56 +0000 (12:57 +0300)
 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.

src/ChangeLog
src/xdisp.c

index b5a22a0ebcee1e05951dcd4cc75b904f04cd3df6..3138bea28fa31fe4c1a606a73455edb41c589f2a 100644 (file)
@@ -1,3 +1,10 @@
+2012-06-16  Eli Zaretskii  <eliz@gnu.org>
+
+       * 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  <schwab@linux-m68k.org>
 
        * category.h (CHAR_HAS_CATEGORY): Define as inline.
index 0eae25de54a039abbe2e1b8b0551325c7e008932..e09116fe0cadfec57878043263df9aa69f2fb943 100644 (file)
@@ -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;