Commit Diff


commit - bd644709daa2a689b354c7aa326d329f2e4adc3b
commit + a050710848507bea37366b9db701f184efa7e25c
blob - 9c8e763cda7dbd381e15afd454c5e52cc7d5bd4e
blob + c852e4dd43b13cacbb8d2352acab3f93d8cd00bd
--- ChangeLog
+++ ChangeLog
@@ -1,5 +1,7 @@
 2021-07-18  Omar Polo  <op@omarpolo.com>
 
+	* wrap.c (push_line): visually drop trailing spaces when formatting a page
+
 	* minibuffer.c (populate_compl_buffer): add an optional description to completion items.
 	(recompute_completions): filter completion results using the description too (if available)
 
blob - 134e93189917b4e80892236b4330d9873f3fb903
blob + 4ec33c07dfb40be69a31c609b11a1aa3866f0476
--- wrap.c
+++ wrap.c
@@ -14,6 +14,7 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
+#include <ctype.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -82,7 +83,16 @@ static int
 push_line(struct buffer *buffer, struct line *l, const char *buf, size_t len, int flags)
 {
 	struct vline *vl;
+	const char *end;
 
+	/* omit trailing spaces */
+	if (len != 0) {
+		for (end = buf + len - 1;
+		     end > buf && isspace(*end);
+		     end--, len--)
+			;	/* nop */
+	}
+
 	if (!(l->flags & L_HIDDEN))
 		buffer->line_max++;