softwrap: improve left/right navigation across line boundaries

Using do_up() and do_end() when the user types <Left> at the start of
a line, and do_down() and do_home() when typing <Right> at line's end
can be problematic when tabs are wider than the screen, because those
functions convert indexes to columns and back again twice, thus causing
inaccuracies.  Therefore, simply adjust current and current_x directly,
and then redraw the screen.

This fixes https://savannah.gnu.org/bugs/index.php?51778.
master
David Lawrence Ramsey 2017-08-17 16:43:30 -05:00 committed by Benno Schulenberg
parent e09dbf18b1
commit 46ccc9ba6a
1 changed files with 10 additions and 4 deletions

View File

@ -582,8 +582,11 @@ void do_left(void)
openfile->current_x = move_mbleft(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->fileage) {
do_up_void();
do_end(FALSE);
openfile->current = openfile->current->prev;
openfile->current_x = strlen(openfile->current->data);
focusing = FALSE;
edit_redraw(openfile->current->next);
return;
}
@ -619,8 +622,11 @@ void do_right(void)
openfile->current_x = move_mbright(openfile->current->data,
openfile->current_x);
else if (openfile->current != openfile->filebot) {
do_home(FALSE);
do_down_void();
openfile->current = openfile->current->next;
openfile->current_x = 0;
focusing = FALSE;
edit_redraw(openfile->current->prev);
return;
}