shithub: riscv

Download patch

ref: 303394314aa041cf52cbb02441aca04f12aafddf
parent: 7b4c8aac930b440ca2f4a877f0459f75c8f2fe70
author: cinap_lenrek <[email protected]>
date: Mon May 13 00:19:10 EDT 2013

rio: fix completion and readback and make it possible to complete history

--- a/sys/src/cmd/rio/wind.c
+++ b/sys/src/cmd/rio/wind.c
@@ -471,7 +471,7 @@
 	int i;
 	Fmt f;
 	Rune *rp;
-	uint nr, qline, q0;
+	uint nr, qline;
 	char *s;
 
 	runefmtstrinit(&f);
@@ -490,20 +490,21 @@
 		}
 		fmtprint(&f, "]\n");
 	}
-	/* place text at beginning of line before host point */
-	qline = w->qh;
-	while(qline>0 && w->r[qline-1] != '\n')
-		qline--;
-
 	rp = runefmtstrflush(&f);
 	nr = runestrlen(rp);
 
-	q0 = w->q0;
-	q0 += winsert(w, rp, nr, qline) - qline;
-	if(q0 >= w->qh)
-		w->qh += nr;
+	/* place text at beginning of line before cursor */
+	qline = w->q0;
+	while(qline>0 && w->r[qline-1] != '\n')
+		qline--;
+
+	if(qline == w->qh){
+		/* advance host point to avoid readback */
+		w->qh = winsert(w, rp, nr, qline)+nr;
+	} else {
+		winsert(w, rp, nr, qline);
+	}
 	free(rp);
-	wsetselect(w, q0+nr, q0+nr);
 }
 
 Rune*