aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMoritz Poldrack <git@moritz.sh>2022-07-31 16:37:26 +0200
committerRobin Jarry <robin@jarry.cc>2022-07-31 19:53:13 +0200
commit27425c15c4b96f1e11db8cc496b48f3d0fc0d3f4 (patch)
treec88a6108c719d2717450873a0e7da86fb77c86d1 /lib
parentca90343850290c256430ad64daa3d809a7016299 (diff)
downloadaerc-27425c15c4b96f1e11db8cc496b48f3d0fc0d3f4.tar.gz
autocompletion: fix slice out of bounds access
Signed-off-by: Moritz Poldrack <git@moritz.sh> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib')
-rw-r--r--lib/ui/textinput.go3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go
index 8bc32b06..f09ebb43 100644
--- a/lib/ui/textinput.go
+++ b/lib/ui/textinput.go
@@ -70,6 +70,9 @@ func (ti *TextInput) String() string {
}
func (ti *TextInput) StringLeft() string {
+ for ti.index >= len(ti.text) {
+ ti.index = len(ti.text) - 1
+ }
return string(ti.text[:ti.index])
}