From 918f41599dfab54071920441d86c306ced83b550 Mon Sep 17 00:00:00 2001 From: Eli Zaretskii Date: Sat, 20 Feb 2010 11:22:07 -0500 Subject: [PATCH] Continue work on continuation lines. xdisp.c (set_cursor_from_row): Compare candidate cursor positions only in rows whose buffer positions occlude point. (display_line): Fix computation of row->start and row->end for empty lines. dispnew.c (row_equal_p): Compare the reversed_p attributes as well. --- src/ChangeLog.bidi | 10 +++++++++ src/dispnew.c | 1 + src/xdisp.c | 52 +++++++++++++++++++++++++++++++++------------- 3 files changed, 48 insertions(+), 15 deletions(-) diff --git a/src/ChangeLog.bidi b/src/ChangeLog.bidi index 22a19c6630..234723bf6f 100644 --- a/src/ChangeLog.bidi +++ b/src/ChangeLog.bidi @@ -1,3 +1,13 @@ +2010-02-20 Eli Zaretskii + + * xdisp.c (set_cursor_from_row): Compare candidate cursor + positions only in rows whose buffer positions occlude point. + (display_line): Fix computation of row->start and row->end for + empty lines. + + * dispnew.c (row_equal_p): Compare the reversed_p attributes as + well. + 2010-02-13 Eli Zaretskii * xdisp.c (set_cursor_from_row): Don't overwrite cursor position diff --git a/src/dispnew.c b/src/dispnew.c index 897d38e48f..fd470491f7 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -1543,6 +1543,7 @@ row_equal_p (w, a, b, mouse_face_p) || a->overlapped_p != b->overlapped_p || (MATRIX_ROW_CONTINUATION_LINE_P (a) != MATRIX_ROW_CONTINUATION_LINE_P (b)) + || a->reversed_p != b->reversed_p /* Different partially visible characters on left margin. */ || a->x != b->x /* Different height. */ diff --git a/src/xdisp.c b/src/xdisp.c index e8a77af893..f27d99fa5f 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -13012,7 +13012,13 @@ set_cursor_from_row (w, row, matrix, delta, delta_bytes, dy, dvpos) rows whose start and end charpos occlude point. Only set w->cursor if we found a better approximation to the cursor position than we have from previously examined rows. */ - if (w->cursor.vpos >= 0) + if (w->cursor.vpos >= 0 + /* Make sure cursor.vpos specifies a row whose start and end + charpos occlude point. This is because some callers of this + function leave cursor.vpos at the row where the cursor was + displayed during the last redisplay cycle. */ + && MATRIX_ROW_START_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos)) <= pt_old + && pt_old < MATRIX_ROW_END_CHARPOS (MATRIX_ROW (matrix, w->cursor.vpos))) { struct glyph *g1 = MATRIX_ROW_GLYPH_START (matrix, w->cursor.vpos) + w->cursor.hpos; @@ -17597,7 +17603,7 @@ display_line (it) row->end = row_end = it->current; else { - EMACS_INT min_pos = ZV, max_pos = BEGV; + EMACS_INT min_pos = row->start.pos.charpos, max_pos = 0; struct glyph *g; struct it save_it; struct text_pos tpos; @@ -17612,24 +17618,40 @@ display_line (it) { if (BUFFERP (g->object)) { - if (g->charpos < min_pos) + if (g->charpos && g->charpos < min_pos) min_pos = g->charpos; if (g->charpos > max_pos) max_pos = g->charpos; } } - row->start.pos.charpos = min_pos; - row->start.pos.bytepos = CHAR_TO_BYTE (min_pos); - /* For ROW->end, we need the display element that is _after_ - max_pos, in the logical order. Note that this may be after - skipping some invisible text. */ - save_it = *it; - it->bidi_p = 0; - SET_TEXT_POS (tpos, max_pos, CHAR_TO_BYTE (max_pos)); - reseat_1 (it, tpos, 0); - set_iterator_to_next (it, 1); - row->end = row_end = it->current; - *it = save_it; + if (min_pos < row->start.pos.charpos) + { + row->start.pos.charpos = min_pos; + row->start.pos.bytepos = CHAR_TO_BYTE (min_pos); + } + if (max_pos == 0) + max_pos = min_pos; + /* For ROW->end, we need the position that is _after_ max_pos, + in the logical order. */ + SET_TEXT_POS (tpos, max_pos + 1, CHAR_TO_BYTE (max_pos + 1)); + /* If the character at max_pos+1 is a newline, skip that as + well. Note that this may skip some invisible text. */ + if (FETCH_CHAR (tpos.bytepos) == '\n' + || (FETCH_CHAR (tpos.bytepos) == '\r' && it->selective)) + { + save_it = *it; + it->bidi_p = 0; + reseat_1 (it, tpos, 0); + set_iterator_to_next (it, 1); + row_end = it->current; + *it = save_it; + } + else + { + row_end = it->current; + row_end.pos = tpos; + } + row->end = row_end; } /* Record whether this row ends inside an ellipsis. */ -- 2.20.1