aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEli Zaretskii2011-08-06 13:59:36 +0300
committerEli Zaretskii2011-08-06 13:59:36 +0300
commitd1410150345acdf2d7693fe00b8169312fe40d14 (patch)
treeaccd9d7c414485e00d9fe30e1d1c28c7e3ea5c60 /src
parentd747b53feb3e403571c724cc5add1e5e354f4408 (diff)
downloademacs-d1410150345acdf2d7693fe00b8169312fe40d14.tar.gz
emacs-d1410150345acdf2d7693fe00b8169312fe40d14.zip
Fix bug #9254 with crash and cursor positioning under longlines-mode.
src/xdisp.c (set_cursor_from_row): Fix cursor positioning when a display property strides EOL and includes a newline, as in longlines-mode. src/bidi.c (bidi_unshelve_cache): Don't reset the cache if JUST_FREE is non-zero, even if the data buffer is NULL. Fixes a crash in vertical-motion with longlines-mode.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog10
-rw-r--r--src/bidi.c17
-rw-r--r--src/xdisp.c28
3 files changed, 46 insertions, 9 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 60c835cb100..efe542e37d0 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
12011-08-06 Eli Zaretskii <eliz@gnu.org>
2
3 * xdisp.c (set_cursor_from_row): Fix cursor positioning when a
4 display property strides EOL and includes a newline, as in
5 longlines-mode. (Bug#9254)
6
7 * bidi.c (bidi_unshelve_cache): Don't reset the cache if JUST_FREE
8 is non-zero, even if the data buffer is NULL. Fixes a crash in
9 vertical-motion with longlines-mode. (Bug#9254)
10
12011-08-05 Eli Zaretskii <eliz@gnu.org> 112011-08-05 Eli Zaretskii <eliz@gnu.org>
2 12
3 * bidi.c <bidi_cache_total_alloc>: Now static. 13 * bidi.c <bidi_cache_total_alloc>: Now static.
diff --git a/src/bidi.c b/src/bidi.c
index 0db144bea6c..2879198ce31 100644
--- a/src/bidi.c
+++ b/src/bidi.c
@@ -666,7 +666,11 @@ bidi_shelve_cache (void)
666 return databuf; 666 return databuf;
667} 667}
668 668
669/* Restore the cache state from a copy stashed away by bidi_shelve_cache. */ 669/* Restore the cache state from a copy stashed away by
670 bidi_shelve_cache, and free the buffer used to stash that copy.
671 JUST_FREE non-zero means free the buffer, but don't restore the
672 cache; used when the corresponding iterator is discarded instead of
673 being restored. */
670void 674void
671bidi_unshelve_cache (void *databuf, int just_free) 675bidi_unshelve_cache (void *databuf, int just_free)
672{ 676{
@@ -674,10 +678,13 @@ bidi_unshelve_cache (void *databuf, int just_free)
674 678
675 if (!p) 679 if (!p)
676 { 680 {
677 /* A NULL pointer means an empty cache. */ 681 if (!just_free)
678 bidi_cache_start = 0; 682 {
679 bidi_cache_sp = 0; 683 /* A NULL pointer means an empty cache. */
680 bidi_cache_reset (); 684 bidi_cache_start = 0;
685 bidi_cache_sp = 0;
686 bidi_cache_reset ();
687 }
681 } 688 }
682 else 689 else
683 { 690 {
diff --git a/src/xdisp.c b/src/xdisp.c
index 69baea95b9c..9c281c6736b 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -13285,6 +13285,9 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13285 /* Last buffer position covered by an overlay string with an integer 13285 /* Last buffer position covered by an overlay string with an integer
13286 `cursor' property. */ 13286 `cursor' property. */
13287 EMACS_INT bpos_covered = 0; 13287 EMACS_INT bpos_covered = 0;
13288 /* Non-zero means the display string on which to display the cursor
13289 comes from a text property, not from an overlay. */
13290 int string_from_text_prop = 0;
13288 13291
13289 /* Skip over glyphs not having an object at the start and the end of 13292 /* Skip over glyphs not having an object at the start and the end of
13290 the row. These are special glyphs like truncation marks on 13293 the row. These are special glyphs like truncation marks on
@@ -13603,9 +13606,14 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13603 { 13606 {
13604 Lisp_Object str; 13607 Lisp_Object str;
13605 EMACS_INT tem; 13608 EMACS_INT tem;
13609 /* If the display property covers the newline, we
13610 need to search for it one position farther. */
13611 EMACS_INT lim = pos_after
13612 + (pos_after == MATRIX_ROW_END_CHARPOS (row) + delta);
13606 13613
13614 string_from_text_prop = 0;
13607 str = glyph->object; 13615 str = glyph->object;
13608 tem = string_buffer_position_lim (str, pos, pos_after, 0); 13616 tem = string_buffer_position_lim (str, pos, lim, 0);
13609 if (tem == 0 /* from overlay */ 13617 if (tem == 0 /* from overlay */
13610 || pos <= tem) 13618 || pos <= tem)
13611 { 13619 {
@@ -13629,7 +13637,10 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13629 EMACS_INT strpos = glyph->charpos; 13637 EMACS_INT strpos = glyph->charpos;
13630 13638
13631 if (tem) 13639 if (tem)
13632 cursor = glyph; 13640 {
13641 cursor = glyph;
13642 string_from_text_prop = 1;
13643 }
13633 for ( ; 13644 for ( ;
13634 (row->reversed_p ? glyph > stop : glyph < stop) 13645 (row->reversed_p ? glyph > stop : glyph < stop)
13635 && EQ (glyph->object, str); 13646 && EQ (glyph->object, str);
@@ -13730,8 +13741,17 @@ set_cursor_from_row (struct window *w, struct glyph_row *row,
13730 /* previous candidate is a glyph from a string that has 13741 /* previous candidate is a glyph from a string that has
13731 a non-nil `cursor' property */ 13742 a non-nil `cursor' property */
13732 || (STRINGP (g1->object) 13743 || (STRINGP (g1->object)
13733 && !NILP (Fget_char_property (make_number (g1->charpos), 13744 && (!NILP (Fget_char_property (make_number (g1->charpos),
13734 Qcursor, g1->object))))) 13745 Qcursor, g1->object))
13746 /* pevious candidate is from the same display
13747 string as this one, and the display string
13748 came from a text property */
13749 || (EQ (g1->object, glyph->object)
13750 && string_from_text_prop)
13751 /* this candidate is from newline and its
13752 position is not an exact match */
13753 || (INTEGERP (glyph->object)
13754 && glyph->charpos != pt_old)))))
13735 return 0; 13755 return 0;
13736 /* If this candidate gives an exact match, use that. */ 13756 /* If this candidate gives an exact match, use that. */
13737 if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old) 13757 if (!(BUFFERP (glyph->object) && glyph->charpos == pt_old)