nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit 46ccc9ba6ae54e89ccf5f60c62b09a37236edaea
parent e09dbf18b15d6431c5edfce2de0fa695b7d88f83
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Thu, 17 Aug 2017 16:43:30 -0500

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.

Diffstat:
Msrc/move.c | 14++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/move.c b/src/move.c @@ -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; }