shithub: mongrel

Download patch

ref: d89778bebd8de5942141b9d8db5510e23f9885e2
parent: a7a1e47ffd01ad61516da5e6d1a10e5b02dd4999
author: phil9 <telephil9@gmail.com>
date: Tue Feb 8 02:55:50 EST 2022

ensure text selection does not include newlines

	this caused an issue when trying to plumb text as the selection included
	a newline which the plumber does not like.

--- a/text.c
+++ b/text.c
@@ -72,9 +72,10 @@
 	if(line+1 >= t->nlines)
 		e = t->ndata;
 	else
-		e = t->lines[line+1];
+		e = t->lines[line+1] - 2; /* make sure we exclude the newline */
+	c = 0;
 	x = t->textr.min.x;
-	for(i = s; i <= e; ){
+	for(i = s; i < e; ){
 		c = chartorune(&r, &t->data[i]);
 		if(r == '\t')
 			l = stringwidth(t->font, "    ");
@@ -85,6 +86,8 @@
 		i += c;
 		x += l;
 	}
+	if(r == '\n')
+		i -= c;
 	return i;
 }