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

Remap / rebind keymap to action #523

Closed
arouene opened this issue Jul 29, 2024 · 7 comments · Fixed by #524
Closed

Remap / rebind keymap to action #523

arouene opened this issue Jul 29, 2024 · 7 comments · Fixed by #524
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@arouene
Copy link
Contributor

arouene commented Jul 29, 2024

Describe the bug
It does not seem possible to remap a kemap (like C-p which is bind to "SelectPreviousOrScrollUp") to an action (like "AddToPlaylist").

To Reproduce
I have this keymap.toml

[[keymaps]]
command = "SelectPreviousOrScrollUp"
key_sequence = "k"

[[actions]]
action = "AddToPlaylist"
key_sequence = "C-p"

Expected behaviour
SelectPreviousOrScrollUp is k
AddToPlaylist is C-p

Environment

  • OS: Linux Fedora 40
  • Application version: 0.19.1
@arouene arouene added the bug Something isn't working label Jul 29, 2024
@arouene
Copy link
Contributor Author

arouene commented Jul 29, 2024

Besides, why do we make a difference between a keymap and an action?

@aome510
Copy link
Owner

aome510 commented Jul 29, 2024

Besides, why do we make a difference between a keymap and an action?

I think you mean command and action. The difference is that action performs on a specific item (input) while command is supposed to be a general operation w/o input.

@arouene
Copy link
Contributor Author

arouene commented Jul 29, 2024

Oh ok, I see, thank you !

@aome510
Copy link
Owner

aome510 commented Jul 29, 2024

You can bind C-p to an action by binding C-p to command = "None" to allow re-use the key.

@arouene
Copy link
Contributor Author

arouene commented Jul 29, 2024

I did try that, but then C-p is just not bind to anything

[[keymaps]]
command = "SelectPreviousOrScrollUp"
key_sequence = "k"

[[keymaps]]
command = "None"
key_sequence = "C-p"

[[actions]]
action = "AddToPlaylist"
key_sequence = "C-p"

@aome510
Copy link
Owner

aome510 commented Jul 29, 2024

I see, then it's bug that doesn't allow to re-use None command. It should be easy to update

if let Some(command) = self.find_command_from_key_sequence(key_sequence) {
to ignore None command.

@arouene
Copy link
Contributor Author

arouene commented Jul 29, 2024

Fixed in PR

@arouene arouene closed this as completed Jul 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants