diff --git a/doc/NEWS b/doc/NEWS index fc7c91eec..436420644 100644 --- a/doc/NEWS +++ b/doc/NEWS @@ -232,7 +232,7 @@ Version 4.7.0 * Incorrect mouse movement in editor when text scrolled to the right (#1792) * Newlines are lost when pasting multiline text in editor (#1710) * Mismatched hotkeys EditBeginRecordMacro, EditEndRecordMacro in editor - * ķismatched hotkeys EditBeginningOfText, EditEndOfText, EditBeginPage, EditEndPage (#1724) + * Mismatched hotkeys EditBeginningOfText, EditEndOfText, EditBeginPage, EditEndPage (#1724) * Some syntax files are not installable (#1779) * Date & time insertion in editor (#1759) * "Matches not found" message is not shown in viewer @@ -339,6 +339,7 @@ Version 4.7.0-pre3 - Viewer * Fixed showing Windows/Mac (CR LF/CR) line terminator + * Fixed jump to end of file - Misc diff --git a/src/viewer/move.c b/src/viewer/move.c index 024f09231..ae212dc85 100644 --- a/src/viewer/move.c +++ b/src/viewer/move.c @@ -154,13 +154,36 @@ mcview_move_down (mcview_t * view, off_t lines) else { off_t i; - for (i = 0; i < lines; i++) + off_t new_offset = 0; + + if (view->dpy_end - view->dpy_start > last_byte - view->dpy_end) { - off_t new_offset; - new_offset = mcview_eol (view, view->dpy_start); - if (view->text_wrap_mode) - new_offset = min (new_offset, view->dpy_start + view->data_area.width); - view->dpy_start = new_offset; + i = 0; + new_offset = view->dpy_end; + while (view->dpy_end < last_byte && lines-- > 0) + { + new_offset = mcview_eol (view, view->dpy_end); + if (view->text_wrap_mode) + new_offset = min (new_offset, view->dpy_end + view->data_area.width); + view->dpy_end = new_offset; + + new_offset = mcview_eol (view, view->dpy_start); + if (view->text_wrap_mode) + new_offset = min (new_offset, view->dpy_start + view->data_area.width); + view->dpy_start = new_offset; + } + view->dpy_end = last_byte; + } + else + { + + for (i = 0; i < lines && view->dpy_end < last_byte && new_offset < last_byte; i++) + { + new_offset = mcview_eol (view, view->dpy_start); + if (view->text_wrap_mode) + new_offset = min (new_offset, view->dpy_start + view->data_area.width); + view->dpy_start = new_offset; + } } } mcview_movement_fixups (view, TRUE); @@ -257,7 +280,8 @@ mcview_moveto_top (mcview_t * view) void mcview_moveto_bottom (mcview_t * view) { - off_t datalines, lines_up, filesize, last_offset; + const off_t datalines = view->data_area.height; + off_t filesize; mcview_update_filesize (view); @@ -265,11 +289,12 @@ mcview_moveto_bottom (mcview_t * view) mcview_growbuf_read_until (view, OFFSETTYPE_MAX); filesize = mcview_get_filesize (view); - datalines = view->data_area.height; - lines_up = mcview_offset_doz (datalines, 1); if (view->hex_mode) { + off_t lines_up, last_offset; + + lines_up = mcview_offset_doz (datalines, 1); last_offset = mcview_offset_doz (filesize, 1); view->hex_cursor = filesize; mcview_move_up (view, lines_up); @@ -278,7 +303,7 @@ mcview_moveto_bottom (mcview_t * view) else { view->dpy_start = filesize; - mcview_move_up (view, 1); + mcview_move_up (view, datalines); } } @@ -357,6 +382,7 @@ mcview_moveto_eol (mcview_t * view) } mcview_movement_fixups (view, FALSE); } + /* --------------------------------------------------------------------------------------------- */ void