(handle_single_display_spec): If the display spec is of the form
`(space ...)', and specifies display in the text area, return 2
rather than 1.
+ (try_cursor_movement): Check for the need to scroll more
+ accurately, and prefer exact match for point under bidi.
* dispextern.h (struct bidi_it): Rename the disp_prop_p member
into disp_prop; all users changed.
do
{
+ int at_zv_p = 0, exact_match_p = 0;
+
if (MATRIX_ROW_START_CHARPOS (row) <= PT
&& PT <= MATRIX_ROW_END_CHARPOS (row)
&& cursor_row_p (row))
rv |= set_cursor_from_row (w, row, w->current_matrix,
0, 0, 0, 0);
- /* As soon as we've found the first suitable row
- whose ends_at_zv_p flag is set, we are done. */
- if (rv
- && MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p)
+ /* As soon as we've found the exact match for point,
+ or the first suitable row whose ends_at_zv_p flag
+ is set, we are done. */
+ at_zv_p =
+ MATRIX_ROW (w->current_matrix, w->cursor.vpos)->ends_at_zv_p;
+ if (!at_zv_p)
+ {
+ struct glyph_row *candidate =
+ MATRIX_ROW (w->current_matrix, w->cursor.vpos);
+ struct glyph *g =
+ candidate->glyphs[TEXT_AREA] + w->cursor.hpos;
+ EMACS_INT endpos = MATRIX_ROW_END_CHARPOS (candidate);
+
+ exact_match_p =
+ (BUFFERP (g->object) && g->charpos == PT)
+ || (INTEGERP (g->object)
+ && (g->charpos == PT
+ || (g->charpos == 0 && endpos - 1 == PT)));
+ }
+ if (rv && (at_zv_p || exact_match_p))
{
rc = CURSOR_MOVEMENT_SUCCESS;
break;
loop before all the candidates were examined, signal
to the caller that this method failed. */
if (rc != CURSOR_MOVEMENT_SUCCESS
- && (!rv || MATRIX_ROW_CONTINUATION_LINE_P (row)))
+ && !(rv
+ && !MATRIX_ROW_CONTINUATION_LINE_P (row)
+ && !row->continued_p))
rc = CURSOR_MOVEMENT_MUST_SCROLL;
else if (rv)
rc = CURSOR_MOVEMENT_SUCCESS;