nano

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

commit c1f70185ba9a4d38e5c982d6e0e89d8f847565a6
parent c888edf409e399363159b356a27c10db545ad5f7
Author: David Lawrence Ramsey <pooka109@gmail.com>
Date:   Wed, 25 Jan 2017 00:35:01 -0600

softwrap: save and restore firstcolumn when replacing text

In do_replace(), replacing text may change firstcolumn if the next match
is offscreen, and replacing text after that will not change it back.  In
order to keep the viewport unchanged, we have to save and restore not
just edittop, but firstcolumn as well.

Diffstat:
Msrc/search.c | 4+++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/search.c b/src/search.c @@ -736,7 +736,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only, void do_replace(void) { filestruct *edittop_save, *begin; - size_t begin_x; + size_t firstcolumn_save, begin_x; ssize_t numreplaced; int i; @@ -780,6 +780,7 @@ void do_replace(void) /* Save where we are. */ edittop_save = openfile->edittop; + firstcolumn_save = openfile->firstcolumn; begin = openfile->current; begin_x = openfile->current_x; @@ -787,6 +788,7 @@ void do_replace(void) /* Restore where we were. */ openfile->edittop = edittop_save; + openfile->firstcolumn = firstcolumn_save; openfile->current = begin; openfile->current_x = begin_x; refresh_needed = TRUE;