From 58652a7bafcdbbe89be71d265e5e2c8970dcf2f2 Mon Sep 17 00:00:00 2001 From: erroneousboat Date: Sat, 19 Aug 2017 12:47:35 +0200 Subject: [PATCH] Fix insert key When moving the cursor to to insert a new key. It was not correctly inserted at the right location. This fix will solve this. --- components/input.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/input.go b/components/input.go index db1e61f..38bb38d 100644 --- a/components/input.go +++ b/components/input.go @@ -74,8 +74,11 @@ func (i *Input) SendMessage(svc *service.SlackService, channel string, message s func (i *Input) Insert(key rune) { if len(i.Text) < i.Par.InnerBounds().Dx()-1 { - first := append(i.Text[0:i.CursorPosition], key) - i.Text = append(first, i.Text[i.CursorPosition:]...) + left := make([]rune, len(i.Text[0:i.CursorPosition])) + copy(left, i.Text[0:i.CursorPosition]) + left = append(left, key) + + i.Text = append(left, i.Text[i.CursorPosition:]...) i.Par.Text = string(i.Text) i.MoveCursorRight()