summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-08-14 15:07:39 -0400
committerJune McEnroe <june@causal.agency>2019-08-14 15:07:39 -0400
commit703f73365b55911b51203315ea12aca69814408c (patch)
tree4dbd15d22d05a95eac1c77ad329d182e1699865f
parentAdjust bounds checks again (diff)
downloadstream-703f73365b55911b51203315ea12aca69814408c.tar.gz
stream-703f73365b55911b51203315ea12aca69814408c.zip
Fix wrapping, maybe?
It's enough for nvim to not be totally broken, anyway.
-rw-r--r--term.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/term.c b/term.c
index 418fdf6..178e613 100644
--- a/term.c
+++ b/term.c
@@ -326,28 +326,22 @@ ACTION(add) {
 		unhandled("\\u%02X", ch);
 		return;
 	}
-	if (X + width > t->cols) {
-		unhandled("'%lc' too wide", ch);
-		return;
-	}
 
 	if (t->mode & Insert) {
 		move(C(Y, X + width), C(Y, X), t->cols - X - width);
 	}
+	if (t->mode & Wrap && X + width > t->cols) {
+		cr(t, ch);
+		nl(t, ch);
+	}
 
 	C(Y, X)->style = t->style;
 	C(Y, X)->ch = ch;
-	for (int i = 1; i < width; ++i) {
+	for (int i = 1; i < width && X + i < t->cols; ++i) {
 		C(Y, X + i)->style = t->style;
 		C(Y, X + i)->ch = L'\0';
 	}
-
-	if (t->mode & Wrap && X + width >= t->cols) {
-		cr(t, 0);
-		nl(t, 0);
-	} else {
-		X = MIN(X + width, R);
-	}
+	X = MIN(X + width, (t->mode & Wrap ? t->cols : R));
 }
 
 enum {