Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"Open editor" shortcut doesn't work (using vim bindings) #512

Closed
savchenko opened this issue Feb 9, 2021 · 14 comments · Fixed by #549
Closed

"Open editor" shortcut doesn't work (using vim bindings) #512

savchenko opened this issue Feb 9, 2021 · 14 comments · Fixed by #549
Milestone

Comments

@savchenko
Copy link

Describe the bug
When Commit dialog is open and custom hotkey for "Open editor" is defined, pressing the hotkey does nothing.

To Reproduce
Steps to reproduce the behavior:

  1. Stage something
  2. Commit
  3. Type some text, press corresponding shortcut to open an editor
  4. Nothing happens

Expected behavior
Editor opens.

Screenshots
image

Context (please complete the following information):

  • OS/Distro + Version: Debian Bullseye
  • GitUI Version: 0.11.0
  • Rust version: 1.48.0

Additional context
"Open editor" function within the main window works as expected. I have tried various key combinations for both.

@extrawurst
Copy link
Owner

Can you run gitui -l to enable logging and share your logfile to help diagnose?

@savchenko
Copy link
Author

savchenko commented Feb 9, 2021

Here we go:

11:33:25 [TRACE] (6) mio::poll: [/home/nsu/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.7.6/src/poll.rs:478] registering event source with poller: token=Token(0), interests=READABLE
11:33:25 [TRACE] (1) gitui::app: [src/app.rs:279] update
11:33:25 [TRACE] (6) mio::poll: [/home/nsu/.cargo/registry/src/github.com-1ecc6299db9ec823/mio-0.7.6/src/poll.rs:478] registering event source with poller: token=Token(1), interests=READABLE
11:33:25 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 8709286183238101472] (type: WorkingDir, untracked: true)
11:33:25 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 8105653504340632694] (type: Stage, untracked: true)
11:33:25 [TRACE] (2) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 8709286183238101472 (type: WorkingDir, untracked: true)
11:33:25 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:25 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:25 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 8105653504340632694 (type: Stage, untracked: true)
11:33:25 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:25 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:25 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Diff
11:33:28 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Enter, modifiers: NONE }))
11:33:28 [TRACE] (1) gitui::app: [src/app.rs:279] update
11:33:28 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:28 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 13589674619323867399] (type: WorkingDir, untracked: true)
11:33:28 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 17429299285792713100] (type: Stage, untracked: true)
11:33:28 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 17429299285792713100 (type: Stage, untracked: true)
11:33:28 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Diff
11:33:28 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 13589674619323867399 (type: WorkingDir, untracked: true)
11:33:28 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:28 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:28 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:28 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:28 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Diff
11:33:28 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:28 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('c'), modifiers: NONE }))
11:33:30 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('s'), modifiers: NONE }))
11:33:30 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:30 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Diff
11:33:30 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:30 [TRACE] (1) gitui::app: [src/app.rs:279] update
11:33:30 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:30 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 6478652179611671551] (type: WorkingDir, untracked: true)
11:33:30 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 9602472073373194543] (type: Stage, untracked: true)
11:33:30 [TRACE] (5) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 9602472073373194543 (type: Stage, untracked: true)
11:33:30 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Diff
11:33:30 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:30 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 6478652179611671551 (type: WorkingDir, untracked: true)
11:33:30 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:30 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('c'), modifiers: NONE }))
11:33:31 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('E'), modifiers: SHIFT }))
11:33:34 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('E'), modifiers: SHIFT }))
11:33:34 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('E'), modifiers: SHIFT }))
11:33:34 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('E'), modifiers: SHIFT }))
11:33:34 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('E'), modifiers: SHIFT }))
11:33:35 [TRACE] (1) gitui::app: [src/app.rs:279] update
11:33:35 [TRACE] (1) asyncgit::diff: [asyncgit/src/diff.rs:93] request
11:33:35 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 12155401842788164465] (type: WorkingDir, untracked: true)
11:33:35 [TRACE] (1) asyncgit::status: [asyncgit/src/status.rs:95] request: [hash: 15141232165738855276] (type: Stage, untracked: true)
11:33:35 [TRACE] (4) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 15141232165738855276 (type: Stage, untracked: true)
11:33:35 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Diff
11:33:35 [TRACE] (3) asyncgit::status: [asyncgit/src/status.rs:152] status fetched: 12155401842788164465 (type: WorkingDir, untracked: true)
11:33:35 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:35 [TRACE] (1) gitui::app: [src/app.rs:296] update_git: Status
11:33:37 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Esc, modifiers: NONE }))
11:33:39 [TRACE] (1) gitui::app: [src/app.rs:213] event: Input(Key(KeyEvent { code: Char('Q'), modifiers: SHIFT }))

Relevant configs are here: https://github.com/savchenko/debian/tree/bullseye/roles/dotfiles/files/config/gitui

@extrawurst
Copy link
Owner

oh wow. now I finally see it. the problem is that the vim keybindings seem to be having a bug. cause the text editor will actually swallow regular characters but still it binds to a capital E: https://github.com/extrawurst/gitui/blob/master/assets/vim_style_key_config.ron#L31

can you try to alter this in your key bindings? the default would be CTRL + e.

@savchenko
Copy link
Author

the text editor will actually swallow regular characters but still it binds to a capital E

Not quite sure if I follow :) However switching to Ctrl does work:

open_commit_editor: ( code: Char('e'), modifiers: ( bits: 2,),),

Interestingly, Shift modifier works in the main window just fine.

@extrawurst
Copy link
Owner

the problem is simply that SHIFT+E is a character the text input will pick up and add to your commit message instead of considering it as a shortcut for opening the external editor

@extrawurst extrawurst changed the title "Open editor" shortcut doesn't work "Open editor" shortcut doesn't work (using vim bindings) Feb 9, 2021
@savchenko
Copy link
Author

Seems like other shortcuts are affected as well. For example, default "reset item" aka Shift+D also doesn't work with vim bindings from https://github.com/extrawurst/gitui/blob/master/assets/vim_style_key_config.ron

@extrawurst
Copy link
Owner

like I said its because shortcuts that are valid text characters will be picked up as such

@savchenko
Copy link
Author

Right... Is it possible to have a "priority" for a shortcut? Say there is something assigned to , then pressing Shift+g will execute the assigned action instead of entering capital "G".

@extrawurst
Copy link
Owner

If we give the open editor shortcut priority how do you want to allow people inserting a capital 'E'?

I think the way to go here is a different shortcut in the vim bindings.

@extrawurst
Copy link
Owner

maybe @yanganto the original contributor for the vim bindings can chime in, what would be a good alternative for shift+e to open the editor - would ctrl+e be good too? that is the default binding we have

@savchenko
Copy link
Author

If we give the open editor shortcut priority how do you want to allow people inserting a capital 'E'?

Valid point.

I think the way to go here is a different shortcut in the vim bindings.

Alternatively — provide an option to open an external editor by default?

@extrawurst extrawurst added this to the v0.12 milestone Feb 24, 2021
@yanganto
Copy link
Contributor

yanganto commented Feb 25, 2021

It may be good to use the Ctrl + e at the input box.
Because the input box only has one mode, the real vim editor has at least two modes to avoid this problem, command mode and insert mode.

@savchenko The default "reset item" is Shift + U, the issue is on the display keybinding incorrectly. It displays the keybinding for dropping stash item.
@extrawurst How do you think about Gitui with multiple modes?

Thanks.

@extrawurst
Copy link
Owner

ctrl+e in the vim bindings then.

Regarding two modes: I don’t see the point. It makes sense when text input is the primary purpose of a tool but this is not the case here and makes things only more complicated.

@yanganto
Copy link
Contributor

Yes, I agree with you. ctrl + e is good enough for the current scenario.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants