kyoheiu / felix

tui file manager with vim-like key mapping
https://kyoheiu.dev/felix/
MIT License
718 stars 26 forks source link

Enable Ctrl-h for Backspace Functionality #254

Closed 0x6b closed 10 months ago

0x6b commented 10 months ago

This PR will allow users to use Ctrl-h as an alternative for the backspace key for the following commands:

Closes #252

kyoheiu commented 10 months ago

Looks like this line disables the backspace key to work if Ctrl is not pressed in all cases:

KeyCode::Backspace | KeyCode::Char('h')
    if modifiers == KeyModifiers::CONTROL =>

To avoid this, we have to capture the modifiers like this:

                                        match (code, modifiers) {
                                            (KeyCode::Esc, KeyModifiers::NONE) => {
                                                go_to_info_line_and_reset();
                                                hide_cursor();
                                                state.move_cursor(state.layout.y);
                                                break 'zoxide;
                                            }
                                           ...
                                            (KeyCode::Backspace, KeyModifiers::NONE)
                                            | (KeyCode::Char('h'), KeyModifiers::CONTROL) => {

Could you fix this?

0x6b commented 10 months ago

Ah thanks @kyoheiu for catching that! I'll revisit the PR with your suggestion. Please note that it'll be next month as I'm far away from my laptop recently.

kyoheiu commented 10 months ago

I see. Thank you for your time, I will be waiting:smile:

0x6b commented 10 months ago

@kyoheiu I updated the branch with commits to address your comment. Can you please review the changes. Thanks!

kyoheiu commented 10 months ago

Thank you! There were some conflicts made by #255, so I resolved them and merged this PR.

kyoheiu commented 10 months ago

Realized that command line mode (:) did not implement this feature, so I added that in https://github.com/kyoheiu/felix/commit/1e2d0625343baae205cd7ec9675f0ce75975f3a3 .

0x6b commented 10 months ago

Good catch @kyoheiu. Thanks for you help and release a new!