From: Eli Zaretskii Date: Wed, 8 May 2013 17:59:38 +0000 (+0300) Subject: Fix vertical cursor motion when there's a display string with newline at EOL. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~243 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=07525f7737602af36afe40f85f229fee9887f232;p=emacs.git Fix vertical cursor motion when there's a display string with newline at EOL. src/xdisp.c (row_for_charpos_p): New function, with code of cursor_row_p, but accepts an additional argument CHARPOS instead of using a hardcoded PT. (cursor_row_p): Call row_for_charpos_p with 2nd argument PT. (row_containing_pos): Call row_for_charpos_p instead of partially doing the same. Fixes cursor positioning under longlines-mode when longlines-show-effect includes more than one newline, when moving the cursor vertically up. --- diff --git a/src/ChangeLog b/src/ChangeLog index 64b76af0b85..c8e2abf3bec 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,14 @@ +2013-05-08 Eli Zaretskii + + * xdisp.c (row_for_charpos_p): New function, with code of + cursor_row_p, but accepts an additional argument CHARPOS instead + of using a hardcoded PT. + (cursor_row_p): Call row_for_charpos_p with 2nd argument PT. + (row_containing_pos): Call row_for_charpos_p instead of partially + doing the same. Fixes cursor positioning under longlines-mode + when longlines-show-effect includes more than one newline, when + moving the cursor vertically up. + 2013-05-08 Juanma Barranquero * makefile.w32-in (ACL_H): New macro. diff --git a/src/xdisp.c b/src/xdisp.c index c7a25873272..0a79e6fd891 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -794,6 +794,7 @@ static void set_iterator_to_next (struct it *, int); static void mark_window_display_accurate_1 (struct window *, int); static int single_display_spec_string_p (Lisp_Object, Lisp_Object); static int display_prop_string_p (Lisp_Object, Lisp_Object); +static int row_for_charpos_p (struct glyph_row *, ptrdiff_t); static int cursor_row_p (struct glyph_row *); static int redisplay_mode_lines (Lisp_Object, int); static char *decode_mode_spec_coding (Lisp_Object, char *, int); @@ -16909,10 +16910,9 @@ row_containing_pos (struct window *w, ptrdiff_t charpos, || (MATRIX_ROW_END_CHARPOS (row) == charpos /* The end position of a row equals the start position of the next row. If CHARPOS is there, we - would rather display it in the next line, except - when this line ends in ZV. */ - && !row->ends_at_zv_p - && !MATRIX_ROW_ENDS_IN_MIDDLE_OF_CHAR_P (row))) + would rather consider it displayed in the next + line, except when this line ends in ZV. */ + && !row_for_charpos_p (row, charpos))) && charpos >= MATRIX_ROW_START_CHARPOS (row)) { struct glyph *g; @@ -16920,10 +16920,10 @@ row_containing_pos (struct window *w, ptrdiff_t charpos, if (NILP (BVAR (XBUFFER (w->contents), bidi_display_reordering)) || (!best_row && !row->continued_p)) return row; - /* In bidi-reordered rows, there could be several rows - occluding point, all of them belonging to the same - continued line. We need to find the row which fits - CHARPOS the best. */ + /* In bidi-reordered rows, there could be several rows whose + edges surround CHARPOS, all of these rows belonging to + the same continued line. We need to find the row which + fits CHARPOS the best. */ for (g = row->glyphs[TEXT_AREA]; g < row->glyphs[TEXT_AREA] + row->used[TEXT_AREA]; g++) @@ -18727,15 +18727,15 @@ highlight_trailing_whitespace (struct frame *f, struct glyph_row *row) /* Value is non-zero if glyph row ROW should be - used to hold the cursor. */ + considered to hold the buffer position CHARPOS. */ static int -cursor_row_p (struct glyph_row *row) +row_for_charpos_p (struct glyph_row *row, ptrdiff_t charpos) { int result = 1; - if (PT == CHARPOS (row->end.pos) - || PT == MATRIX_ROW_END_CHARPOS (row)) + if (charpos == CHARPOS (row->end.pos) + || charpos == MATRIX_ROW_END_CHARPOS (row)) { /* Suppose the row ends on a string. Unless the row is continued, that means it ends on a newline @@ -18761,7 +18761,7 @@ cursor_row_p (struct glyph_row *row) if (STRINGP (glyph->object)) { Lisp_Object prop - = Fget_char_property (make_number (PT), + = Fget_char_property (make_number (charpos), Qdisplay, Qnil); result = (!NILP (prop) @@ -18815,6 +18815,15 @@ cursor_row_p (struct glyph_row *row) return result; } +/* Value is non-zero if glyph row ROW should be + used to hold the cursor. */ + +static int +cursor_row_p (struct glyph_row *row) +{ + return row_for_charpos_p (row, PT); +} + /* Push the property PROP so that it will be rendered at the current