diff options
-rw-r--r-- | libview/ev-view.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libview/ev-view.c b/libview/ev-view.c index 61505728..2db3eb2b 100644 --- a/libview/ev-view.c +++ b/libview/ev-view.c @@ -5406,6 +5406,7 @@ ev_view_move_cursor (EvView *view, gint prev_page; cairo_region_t *damage_region; gboolean clear_selections = FALSE; + const gboolean forward = count >= 0; if (!view->caret_enabled || view->rotation != 0) return FALSE; @@ -5475,9 +5476,18 @@ ev_view_move_cursor (EvView *view, return TRUE; if (step == GTK_MOVEMENT_DISPLAY_LINES) { + const gint prev_cursor_offset = view->cursor_offset; + position_caret_cursor_at_location (view, MAX (rect.x, view->cursor_line_offset), rect.y + (rect.height / 2)); + /* Make sure we didn't move the cursor in the wrong direction + * in case the visual order isn't the same as the logical one, + * in order to avoid cursor movement loops */ + if ((forward && prev_cursor_offset > view->cursor_offset) || + (!forward && prev_cursor_offset < view->cursor_offset)) { + view->cursor_offset = prev_cursor_offset; + } if (!clear_selections && prev_offset == view->cursor_offset && prev_page == view->cursor_page) { gtk_widget_error_bell (GTK_WIDGET (view)); |