From 7e0d48c2a12fa11d499c32a36ff654e920557be2 Mon Sep 17 00:00:00 2001 From: Francisco Miamoto Date: Sat, 20 Mar 2021 20:12:17 -0300 Subject: [PATCH] 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 --- pkg/gui/editors.go | 6 ++++-- 1 file 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) }