jesseduffield / jesseduffield/lazygit
Better keybinding support
- Dominant language
- Go
- Stars
- 82.4k
- Forks
- 3k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 19
Description
**Is your feature request related to a problem? Please describe.**
Tcell has support for a wide range of key combinations (e.g. ctrl+right-arrow) but our gocui package (which plugs into tcell) doesn't handle them properly. In `vendor/github.com/jesseduffield/gocui/tcell_driver.go` we currently set the modifier to 0 (ModNone) if it's set to Ctrl or Shift.
**Describe the solution you'd like**
We need to do the following:
1) don't swallow tcell modifiers in `vendor/github.com/jesseduffield/gocui/tcell_driver.go`
2) In `pkg/gui/keybindings.go`, instead of doing this:
```go
{
ViewName: "files",
Contexts: []string{string(FILES_CONTEXT_KEY)},
Key: gui.getKey(""),
Handler: gui.myHandler,
Description: gui.Tr.MyDescription,
Modifier: gocui.ModNone,
},
```
We should either have our `getKey` function also return a modifier, or have a separate `gui.getModifier("")` call which gives us the correct modifier from the key.
Because I was too lazy to do this in the past, I introduced a bit of tech debt by having tcell's `tcell.KeyF64` map to our `gocui.KeyAltEnter`. We should instead just have that as `gocui.KeyEnter` with the `ModAlt` modifier.
**Describe alternatives you've considered**
none
**Additional context**
* related PR that attempted to work on this problem when we were using termbox instead of tcell: https://github.com/jesseduffield/lazygit/pull/1142
* Addressing this issue will require changes both in this repo and in https://github.com/jesseduffield/gocui (but because we use a vendor directory you can make the changes locally there while you're hacking away)
* For some reason, tcell itself has some keys that seem to encode the fact that Ctrl is being held (see for example `KeyCtrlE` in `vendor/github.com/gdamore/tcell/v2/key.go`. I'm not sure why that's the case if tcell makes use of a ctrl modifier
Contributor guide
Assessment
This issue has not been assessed yet.