diff options
author | Koni Marti <koni.marti@gmail.com> | 2023-05-10 23:56:27 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-05-16 13:41:18 +0200 |
commit | d31123fa1d68c8da39e4f0c394b935fefe4e4a6d (patch) | |
tree | c8dc869b16c7446767c5ed4c8e392234d7645872 /lib/ui | |
parent | 74c6544aec2b2d7da0ba80f2e62c1b0effb50d5d (diff) | |
download | aerc-d31123fa1d68c8da39e4f0c394b935fefe4e4a6d.tar.gz |
textinput: align completion popover
Align the completion popover with the actual completion location on the
textinput line.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/ui')
-rw-r--r-- | lib/ui/textinput.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go index 65570e8b..d76e9349 100644 --- a/lib/ui/textinput.go +++ b/lib/ui/textinput.go @@ -151,7 +151,16 @@ func (ti *TextInput) drawPopover(ctx *Context) { } width := maxLen(ti.completions) + 3 height := len(ti.completions) - ctx.Popover(0, 0, width, height, cmp) + + pos := len(ti.prefix) - ti.scroll + if pos+width > ctx.Width() { + pos = ctx.Width() - width + } + if pos < 0 { + pos = 0 + } + + ctx.Popover(pos, 0, width, height, cmp) } func (ti *TextInput) MouseEvent(localX int, localY int, event tcell.Event) { |