softwrap: remember the actual breaking point when wrapping at blanks

When softwrapping at blanks, the wrapping routine should, when called
again, continue searching from where the previous chunk ended, not from
the point it reached during that previous search, because this could be
*just* beyond the space that could be the next breaking point.

This fixes https://savannah.gnu.org/bugs/?64945.
Reported-by: Andreas Schamanek <schamane@fam.tuwien.ac.at>

Bug existed since version 6.4, commit 0e9bef34.
This commit is contained in:
Benno Schulenberg 2023-12-06 16:40:24 +01:00
parent 6a7a0c8f50
commit a76a6bf692
1 changed files with 5 additions and 2 deletions

View File

@ -3167,10 +3167,13 @@ size_t get_softwrap_breakpoint(const char *linedata, size_t leftedge,
/* If we're softwrapping at blanks and we found at least one blank, break
* after that blank -- if it doesn't overshoot the screen's edge. */
if (farthest_blank != NULL) {
advance_over(farthest_blank, &last_blank_col);
size_t onestep = advance_over(farthest_blank, &last_blank_col);
if (last_blank_col <= goal_column)
if (last_blank_col <= goal_column) {
text = farthest_blank + onestep;
column = last_blank_col;
return last_blank_col;
}
/* If it's a tab that overshoots, break at the screen's edge. */
if (*farthest_blank == '\t')