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.master
parent
c888edf409
commit
c1f70185ba
|
@ -736,7 +736,7 @@ ssize_t do_replace_loop(const char *needle, bool whole_word_only,
|
||||||
void do_replace(void)
|
void do_replace(void)
|
||||||
{
|
{
|
||||||
filestruct *edittop_save, *begin;
|
filestruct *edittop_save, *begin;
|
||||||
size_t begin_x;
|
size_t firstcolumn_save, begin_x;
|
||||||
ssize_t numreplaced;
|
ssize_t numreplaced;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -780,6 +780,7 @@ void do_replace(void)
|
||||||
|
|
||||||
/* Save where we are. */
|
/* Save where we are. */
|
||||||
edittop_save = openfile->edittop;
|
edittop_save = openfile->edittop;
|
||||||
|
firstcolumn_save = openfile->firstcolumn;
|
||||||
begin = openfile->current;
|
begin = openfile->current;
|
||||||
begin_x = openfile->current_x;
|
begin_x = openfile->current_x;
|
||||||
|
|
||||||
|
@ -787,6 +788,7 @@ void do_replace(void)
|
||||||
|
|
||||||
/* Restore where we were. */
|
/* Restore where we were. */
|
||||||
openfile->edittop = edittop_save;
|
openfile->edittop = edittop_save;
|
||||||
|
openfile->firstcolumn = firstcolumn_save;
|
||||||
openfile->current = begin;
|
openfile->current = begin;
|
||||||
openfile->current_x = begin_x;
|
openfile->current_x = begin_x;
|
||||||
refresh_needed = TRUE;
|
refresh_needed = TRUE;
|
||||||
|
|
Loading…
Reference in New Issue