From c1f70185ba9a4d38e5c982d6e0e89d8f847565a6 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey <pooka109@gmail.com> Date: Wed, 25 Jan 2017 00:35:01 -0600 Subject: [PATCH] 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. --- src/search.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/search.c b/src/search.c index 22474ede..359dbe0d 100644 --- 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; -- GitLab