From e50a24a249e1bfd69af7e48ea5076cac78bf7224 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sun, 18 Mar 2012 18:57:39 +0200 Subject: [PATCH] Fix bug #11035 with cursor positioning on overlay strings with newlines. src/xdisp.c (cursor_row_p): Even if the glyph row ends in a string that is not from display property, accept the row as a "cursor row" if one of the string's character has a non-nil `cursor' property. Fixes cursor positioning when there are newlines in overlay strings, e.g. in icomplete.el. --- src/ChangeLog | 8 ++++++++ src/xdisp.c | 25 +++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 1ec148b30c..adfa363e25 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,11 @@ +2012-03-18 Eli Zaretskii + + * xdisp.c (cursor_row_p): Even if the glyph row ends in a string + that is not from display property, accept the row as a "cursor + row" if one of the string's character has a non-nil `cursor' + property. Fixes cursor positioning when there are newlines in + overlay strings, e.g. in icomplete.el. (Bug#11035) + 2012-03-12 Paul Eggert * buffer.c (compare_overlays): Don't assume args differ (Bug#6830). diff --git a/src/xdisp.c b/src/xdisp.c index 62d0d187a1..71162960fa 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -18456,9 +18456,11 @@ cursor_row_p (struct glyph_row *row) /* Suppose the row ends on a string. Unless the row is continued, that means it ends on a newline in the string. If it's anything other than a display string - (e.g. a before-string from an overlay), we don't want the + (e.g., a before-string from an overlay), we don't want the cursor there. (This heuristic seems to give the optimal - behavior for the various types of multi-line strings.) */ + behavior for the various types of multi-line strings.) + One exception: if the string has `cursor' property on one of + its characters, we _do_ want the cursor there. */ if (CHARPOS (row->end.string_pos) >= 0) { if (row->continued_p) @@ -18480,6 +18482,25 @@ cursor_row_p (struct glyph_row *row) result = (!NILP (prop) && display_prop_string_p (prop, glyph->object)); + /* If there's a `cursor' property on one of the + string's characters, this row is a cursor row, + even though this is not a display string. */ + if (!result) + { + Lisp_Object s = glyph->object; + + for ( ; glyph >= beg && EQ (glyph->object, s); --glyph) + { + EMACS_INT gpos = glyph->charpos; + + if (!NILP (Fget_char_property (make_number (gpos), + Qcursor, s))) + { + result = 1; + break; + } + } + } break; } } -- 2.20.1