aboutsummaryrefslogtreecommitdiffstats
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 e96499a9..d179bce1 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
}
}