shithub: sam

Download patch

ref: 3d9770542ffa679e6da304bc0d9141682f0592bf
parent: f284cb0c80b6d73d4147c6e65ba259bfa440487d
author: Aidan K. Wiggins <akw@oneiri.one>
date: Fri Feb 28 14:26:47 EST 2025

Missing condition: don't center unecessarily in cmd.

--- a/samterm/main.c
+++ b/samterm/main.c
@@ -571,9 +571,9 @@
 		l->p0 = a;
 		l->p1 = a;
 		typeend = a;
-		if(c == '\n' || typeend-typestart > 100)
+		if(c == '\n' || typeend-typestart > nelem(buf))
 			flushtyping(0);
-		if(a < l->origin || a > l->origin+l->f.nchars)
+		if(!t->lock && a < l->origin || a > l->origin+l->f.nchars)
 			center(l, a, -(l->f.maxlines/3), 0);
 	}
 
@@ -594,7 +594,6 @@
 		flushtyping(0);
 		center(l, l->origin, -l->f.maxlines, 1);
 		break;
-	/* these two need a second */
 	case Kleft:
 		flushtyping(0);
 		a0 = l->p0;
--- a/samterm/mesg.c
+++ b/samterm/mesg.c
@@ -220,13 +220,12 @@
 			w = chartorune(r++, (char*)indata+i);
 		l += hdata(m, l, buf, r-buf);
 	Checkscroll:
-		if(m == cmd.tag){
+		if(m == cmd.tag)
 			for(i = 0; i < NL; i++){
 				lp = &cmd.l[i];
-				if(lp->textfn)
+				if(lp->textfn && l > lp->origin+lp->f.nchars)
 					center(lp, l >= 0? l: lp->p1, 0, 0);
 			}
-		}
 		break;
 
 	case Hunlockfile: