- start_display (&it, w, start);
- move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
- preserve_y = it.current_y;
+ /* We preserve the goal pixel coordinate across consecutive
+ calls to scroll-up or scroll-down. This avoids the
+ possibility of point becoming "stuck" on a tall line when
+ scrolling by one line. */
+ if (window_scroll_pixel_based_preserve_y < 0
+ || (!EQ (current_kboard->Vlast_command, Qscroll_up)
+ && !EQ (current_kboard->Vlast_command, Qscroll_down)))
+ {
+ start_display (&it, w, start);
+ move_it_to (&it, PT, -1, -1, -1, MOVE_TO_POS);
+ window_scroll_pixel_based_preserve_y = it.current_y;
+ }