diff options
author | Jesse Duffield <jessedduffield@gmail.com> | 2021-02-18 19:39:33 +1100 |
---|---|---|
committer | Jesse Duffield <jessedduffield@gmail.com> | 2021-04-06 19:34:32 +1000 |
commit | 5d0cf3d9197b66cfc12c61691a9b242584778d1d (patch) | |
tree | 5857f11e01bb5abdae0cd8abb3920e7774a0fb29 /pkg | |
parent | 4b1da0cf3c3f0e172ec87c49c28d946a96229967 (diff) |
prioritise keybindings on editors
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/gui/editors.go | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/pkg/gui/editors.go b/pkg/gui/editors.go index 5561fb0ce..ffd9116d3 100644 --- a/pkg/gui/editors.go +++ b/pkg/gui/editors.go @@ -8,16 +8,17 @@ import ( // we've just copy+pasted the editor from gocui to here so that we can also re- // render the commit message length on each keypress -func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) { +func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool { newlineKey, ok := gui.getKey(gui.Config.GetUserConfig().Keybinding.Universal.AppendNewline).(gocui.Key) if !ok { newlineKey = gocui.KeyTab } + matched := true switch { case key == gocui.KeyBackspace || key == gocui.KeyBackspace2: v.EditDelete(true) - case key == gocui.KeyDelete: + case key == gocui.KeyCtrlD || key == gocui.KeyDelete: v.EditDelete(false) case key == gocui.KeyArrowDown: v.MoveCursor(0, 1, false) @@ -44,13 +45,16 @@ func (gui *Gui) commitMessageEditor(v *gocui.View, key gocui.Key, ch rune, mod g } gui.RenderCommitLength() + + return matched } -func (gui *Gui) defaultEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) { +func (gui *Gui) defaultEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.Modifier) bool { + matched := true switch { case key == gocui.KeyBackspace || key == gocui.KeyBackspace2: v.EditDelete(true) - case key == gocui.KeyDelete: + case key == gocui.KeyCtrlD || key == gocui.KeyDelete: v.EditDelete(false) case key == gocui.KeyArrowDown: v.MoveCursor(0, 1, false) @@ -79,4 +83,6 @@ func (gui *Gui) defaultEditor(v *gocui.View, key gocui.Key, ch rune, mod gocui.M suggestions := gui.findSuggestions(input) gui.setSuggestions(suggestions) } + + return matched } |