commit a76a6bf69232cc08e704c5e64214bf34311233f4
parent 6a7a0c8f50e1596072951dbfc02065e228630f30
Author: Benno Schulenberg <bensberg@telfort.nl>
Date: Wed, 6 Dec 2023 16:40:24 +0100
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.
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/winio.c b/src/winio.c
@@ -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')