about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/ui/textinput.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go
index e96499a..d179bce 100644
--- a/lib/ui/textinput.go
+++ b/lib/ui/textinput.go
@@ -167,12 +167,12 @@ func (ti *TextInput) ensureScroll() {
 	if ti.ctx == nil {
 		return
 	}
-	// God why am I this lazy
-	for ti.index-ti.scroll >= ti.ctx.Width() {
-		ti.scroll++
+	w := ti.ctx.Width() - len(ti.prompt)
+	if ti.index >= ti.scroll+w {
+		ti.scroll = ti.index - w + 1
 	}
-	for ti.index-ti.scroll < 0 {
-		ti.scroll--
+	if ti.index < ti.scroll {
+		ti.scroll = ti.index
 	}
 }
 
='#n24'>24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
45
46
47
48
49
50
51
52
53
54
55
56
57