softwrap: when possible, go back a whole bunch of chunks at a time
This improves https://savannah.gnu.org/bugs/?51479 for the +-1 case.master
parent
ce68f81b2b
commit
0e4cbd4bfd
20
src/winio.c
20
src/winio.c
|
@ -2805,25 +2805,25 @@ int go_back_chunks(int nrows, filestruct **line, size_t *leftedge)
|
||||||
|
|
||||||
#ifndef NANO_TINY
|
#ifndef NANO_TINY
|
||||||
if (ISSET(SOFTWRAP)) {
|
if (ISSET(SOFTWRAP)) {
|
||||||
size_t current_leftedge = *leftedge;
|
|
||||||
|
|
||||||
/* Recede through the requested number of chunks. */
|
/* Recede through the requested number of chunks. */
|
||||||
for (i = nrows; i > 0; i--) {
|
for (i = nrows; i > 0; i--) {
|
||||||
if (current_leftedge > 0) {
|
size_t chunk = chunk_for(*leftedge, *line);
|
||||||
current_leftedge = leftedge_for(current_leftedge - 1, *line);
|
|
||||||
continue;
|
*leftedge = 0;
|
||||||
}
|
|
||||||
|
if (chunk >= i)
|
||||||
|
return go_forward_chunks(chunk - i, line, leftedge);
|
||||||
|
|
||||||
if (*line == openfile->fileage)
|
if (*line == openfile->fileage)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
i -= chunk;
|
||||||
*line = (*line)->prev;
|
*line = (*line)->prev;
|
||||||
current_leftedge = leftedge_for((size_t)-1, *line);
|
*leftedge = HIGHEST_POSITIVE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Only change leftedge when we actually could move. */
|
if (*leftedge == HIGHEST_POSITIVE)
|
||||||
if (i < nrows)
|
*leftedge = leftedge_for(*leftedge, *line);
|
||||||
*leftedge = current_leftedge;
|
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
for (i = nrows; i > 0 && (*line)->prev != NULL; i--)
|
for (i = nrows; i > 0 && (*line)->prev != NULL; i--)
|
||||||
|
|
Loading…
Reference in New Issue