~sircmpwn/aerc

lib/ui/textinput: Optimize ensureScroll v1 PROPOSED

Adnan Maolood: 1
 lib/ui/textinput: Optimize ensureScroll

 1 files changed, 5 insertions(+), 5 deletions(-)
Looks like this patch was applied.
You are correct, it was.
Export patchset (mbox)
How do I use this?

Copy & paste the following snippet into your terminal to import this patchset into git:

curl -s https://lists.sr.ht/~sircmpwn/aerc/patches/24603/mbox | git am -3
Learn more about email & git
View this thread in the archives

[PATCH] lib/ui/textinput: Optimize ensureScroll Export this patch

---
 lib/ui/textinput.go | 10 +++++-----
 1 file 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
	}
}

-- 
2.33.0
Thanks for this refactoring. I think it should be merged.

Testing didn't show changed behavior.