lib/ui/textinput: Optimize ensureScroll
This commit is contained in:
parent
d39c6b449e
commit
0b19b5e70e
1 changed files with 5 additions and 5 deletions
|
@ -167,12 +167,12 @@ func (ti *TextInput) ensureScroll() {
|
||||||
if ti.ctx == nil {
|
if ti.ctx == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// God why am I this lazy
|
w := ti.ctx.Width() - len(ti.prompt)
|
||||||
for ti.index-ti.scroll >= ti.ctx.Width() {
|
if ti.index >= ti.scroll+w {
|
||||||
ti.scroll++
|
ti.scroll = ti.index - w + 1
|
||||||
}
|
}
|
||||||
for ti.index-ti.scroll < 0 {
|
if ti.index < ti.scroll {
|
||||||
ti.scroll--
|
ti.scroll = ti.index
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue