aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ui/textinput.go
diff options
context:
space:
mode:
authorOskar Sharipov <oskargit@riseup.net>2023-07-26 16:52:55 +0700
committerRobin Jarry <robin@jarry.cc>2023-07-28 21:18:09 +0200
commitcb57cd20e99c29391031a0bb27d1d3e099b21157 (patch)
tree8d286b9ec16120c958d2ef5b8a405bc0a0e473fd /lib/ui/textinput.go
parent8971f6edaeb5a6f3c08a3b00354ea15eb0707359 (diff)
downloadaerc-cb57cd20e99c29391031a0bb27d1d3e099b21157.tar.gz
textinput: fix deleteWord with an only whitespace
Fix a panic in the textinput.deleteWord when text is a whitespace symbol. Add tests for textinput. Fixes: https://todo.sr.ht/~rjarry/aerc/183 Signed-off-by: Oskar Sharipov <oskargit@riseup.net> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'lib/ui/textinput.go')
-rw-r--r--lib/ui/textinput.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/ui/textinput.go b/lib/ui/textinput.go
index e41cff75..dd946aec 100644
--- a/lib/ui/textinput.go
+++ b/lib/ui/textinput.go
@@ -220,7 +220,7 @@ func (ti *TextInput) deleteWord() {
for i >= 0 && ti.text[i] == ' ' {
i--
}
- if strings.ContainsRune(separators, ti.text[i]) {
+ if i >= 0 && strings.ContainsRune(separators, ti.text[i]) {
for i >= 0 && strings.ContainsRune(separators, ti.text[i]) {
i--
}