Commit Diff


commit - 437adc9d5be73b4b89441362ec89de754374a5a6
commit + 3f670bfb38a502b7309f7db354b9d4f767ea12fc
blob - 457fcc6885530f6eb53c478998fd277562f91f45
blob + ee044a71602208bed395a517f0354d580be3407f
--- tog/tog.c
+++ tog/tog.c
@@ -1164,6 +1164,15 @@ format_line(wchar_t **wlinep, int *widthp, const char 
 	if (err)
 		return err;
 
+	if (wlen > 0 && wline[wlen - 1] == L'\n') {
+		wline[wlen - 1] = L'\0';
+		wlen--;
+	}
+	if (wlen > 0 && wline[wlen - 1] == L'\r') {
+		wline[wlen - 1] = L'\0';
+		wlen--;
+	}
+
 	i = 0;
 	while (i < wlen) {
 		int width = wcwidth(wline[i]);