summaryrefslogtreecommitdiffstats
path: root/pkg/gui/editors.go
diff options
context:
space:
mode:
authorFrancisco Miamoto <fsmiamoto@gmail.com>2021-03-20 20:12:17 -0300
committerJesse Duffield <jessedduffield@gmail.com>2021-03-21 11:24:36 +1100
commit7e0d48c2a12fa11d499c32a36ff654e920557be2 (patch)
treec2f848352a8463903bf35cae7df265b2b81a0dc9 /pkg/gui/editors.go
parentad1468f66f8af1724a99bc4c1a653ac71c6cadcb (diff)
fix panic for unprintable key presses
Checking is the associated rune of a key is printable solves our problem of having panics whenever keys like `Home` or `Ctrl-W` are pressed. Fixes #1175
Diffstat (limited to 'pkg/gui/editors.go')
-rw-r--r--pkg/gui/editors.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go
index e55ad58d4..5561fb0ce 100644
--- a/pkg/gui/editors.go
+++ b/pkg/gui/editors.go
@@ -1,6 +1,8 @@
package gui
import (
+ "unicode"
+
"github.com/jesseduffield/gocui"
)
@@ -37,7 +39,7 @@ func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod g
v.EditGotoToStartOfLine()
case key == gocui.KeyCtrlE:
v.EditGotoToEndOfLine()
- default:
+ case unicode.IsPrint(ch):
v.EditWrite(ch)
}
@@ -68,7 +70,7 @@ func (gui *Gui) defaultEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.M
v.EditGotoToStartOfLine()
case key == gocui.KeyCtrlE:
v.EditGotoToEndOfLine()
- default:
+ case unicode.IsPrint(ch):
v.EditWrite(ch)
}