nano

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

commit 244a503ddc614edf7b4a7bf88edc6b26ebbb23a0
parent c277cd6e5b22d97063f1fef05f79db551986ef67
Author: Benno Schulenberg <bensberg@justemail.net>
Date:   Mon, 27 Mar 2017 17:34:13 +0200

moving: the current chunk cannot be beyond the last chunk of a line

When determining the leftedge of the current chunk, it is not simply
the leftedge that corresponds to the placewewant, but the leftedge that
corresponds to the minimum of the placewewant and the full line span.

This fixes https://savannah.gnu.org/bugs/?50653.

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

diff --git a/src/move.c b/src/move.c @@ -463,7 +463,12 @@ void do_up(bool scroll_only) #ifndef NANO_TINY if (ISSET(SOFTWRAP)) { - leftedge = (openfile->placewewant / editwincols) * editwincols; + size_t realspan = strlenpt(openfile->current->data); + + if (openfile->placewewant < realspan) + realspan = openfile->placewewant; + + leftedge = (realspan / editwincols) * editwincols; target_column = openfile->placewewant % editwincols; } #endif @@ -514,7 +519,12 @@ void do_down(bool scroll_only) #ifndef NANO_TINY if (ISSET(SOFTWRAP)) { - leftedge = (openfile->placewewant / editwincols) * editwincols; + size_t realspan = strlenpt(openfile->current->data); + + if (openfile->placewewant < realspan) + realspan = openfile->placewewant; + + leftedge = (realspan / editwincols) * editwincols; target_column = openfile->placewewant % editwincols; } #endif