init_to_row_start (&it, w, cursor_row);
it.last_visible_x = INFINITY;
move_it_in_display_line_to (&it, pt, -1, MOVE_TO_POS);
+ /* If the line ends in an overlay string with a newline,
+ we might infloop, because displaying the window will
+ want to put the cursor after the overlay, i.e. at X
+ coordinate of zero on the next screen line. So we
+ use the buffer position prior to the overlay string
+ instead. */
+ if (it.method == GET_FROM_STRING && pt > 1)
+ {
+ init_to_row_start (&it, w, cursor_row);
+ move_it_in_display_line_to (&it, pt - 1, -1, MOVE_TO_POS);
+ }
current_buffer = saved_current_buffer;
/* Position cursor in window. */