20
850
Fork
You've already forked fuzzel
83

key-bindings: overwrite collision with a log warning (with test coverage) #432

Open
markstos wants to merge 4 commits from keybinds-overwrite into master
pull from: keybinds-overwrite
merge into: dnkl:master
dnkl:master
dnkl:gnome-support
dnkl:releases/1.14
dnkl:issue-319-window-switching
dnkl:issue-561-nord-theme-only
dnkl:resvg-filtering-take-2
dnkl:resvg-filtering
dnkl:releases/1.13
dnkl:rehanzo-dont-ignore-execute-648
dnkl:issue-561-refresh-theme
dnkl:ci-automated-testing
dnkl:reenable-legacy-icons
dnkl:releases/1.12
dnkl:test-coverage-for-fzf-caching
dnkl:releases/1.11
dnkl:releases/1.10
dnkl:releases/1.9
dnkl:releases/1.8
dnkl:releases/1.7
dnkl:releases/1.6
dnkl:releases/1.5
dnkl:releases/1.4
dnkl:releases/1.3
dnkl:releases/1.2
dnkl:releases/1.1
dnkl:releases/1.0
Collaborator
Copy link

Explicitly setting key bindings can collide with default key bindings and throw an error.

This code makes an update such that now defining a keybinding will succeed but print a warning, as this could indicate a mistake. If you don't want the warning, you can explicitly unmap and re-map the binding.

It can be tested by adding the same keybinding to your config file twice. The later one should succeed with a warning.

This is a continuation of #429, with test coverage added.

Behavior Before

  • Rebinding a key would not result an error

Behavior After

For example, with this in fuzzel.ini:

execute=y
execute=z

Could result in:

➤ fuzzel
warn: config.c:309: unmapping default keybinding: execute: was previously triggered by Return
warn: config.c:309: unmapping default keybinding: execute: was previously triggered by KP_Enter
warn: config.c:309: unmapping default keybinding: execute: was previously triggered by Control+y
warn: config.c:314: unmapping keybinding defined at /home/mark/.config/fuzzel/fuzzel.ini:2: execute: was previously triggered by y
Explicitly setting key bindings can collide with default key bindings and throw an error. This code makes an update such that now defining a keybinding will succeed but print a warning, as this could indicate a mistake. If you don't want the warning, you can explicitly unmap and re-map the binding. It can be tested by adding the same keybinding to your config file twice. The later one should succeed with a warning. This is a continuation of #429, with test coverage added. ## Behavior Before - Rebinding a key would not result an error ## Behavior After For example, with this in fuzzel.ini: ``` execute=y execute=z ``` Could result in: ``` ➤ fuzzel warn: config.c:309: unmapping default keybinding: execute: was previously triggered by Return warn: config.c:309: unmapping default keybinding: execute: was previously triggered by KP_Enter warn: config.c:309: unmapping default keybinding: execute: was previously triggered by Control+y warn: config.c:314: unmapping keybinding defined at /home/mark/.config/fuzzel/fuzzel.ini:2: execute: was previously triggered by y ```
config.c: warning on remap (TODO: cleanup)
All checks were successful
ci/woodpecker/pr/woodpecker Pipeline was successful
ci/woodpecker/push/woodpecker Pipeline was successful
c6985a536e
markstos force-pushed keybinds-overwrite from f2ce9bd927
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/pr/woodpecker Pipeline was successful
to 5e4edb58a9
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年06月14日 19:13:21 +02:00
Compare
Author
Collaborator
Copy link

@dnkl I've run the tests several times to make sure they reliably pass and they do.This is ready for final review/merge.

@dnkl I've run the tests several times to make sure they reliably pass and they do.This is ready for final review/merge.
markstos force-pushed keybinds-overwrite from 5e4edb58a9
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
to 05d2676587
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年06月21日 22:51:23 +02:00
Compare
Author
Collaborator
Copy link

Rebased and resolved conflict.

Rebased and resolved conflict.
Author
Collaborator
Copy link

@Cyclic4179 The goal of this PR was deal with key collision -- different actions mapping to the same key-- but it also affects a second case, generating new warnings which can't be turned off. That's Action rebinding. For example, if you want to replace all execute= bindings with execute=y, that was going to cause new warnings that can't be disabled.

I'm going to push a new commit to narrow the scope to what was stated in the title: "Key Collision". I'll illustrate some different keybindings and how they will work after this PR:

execute-or-next=KP_Enter

This will generate an warning, because KP_Error is bound to execute by default:

fuzzel.ini:3: [key-bindings].execute-or-next: KP_Enter previously mapped to 'execute', overwriting

This warning can be eliminated by clarifying the intent by specificing exactly what you would like bind execute to:

# KP_Enter from the list-- no more conflict with KP_Enter and no error
execute=Return Control+y
execute-or-next=KP_Enter

Now here's a a case of Action Rebindings, which generated several warnings original that couldn't be disabled, but now generates no warnings. What's happening here is that the default bindings of execute have been replaced with y:

execute=y

This is also less clearly a mistake. You have explicitly declared what you want to map execute= to in this case, which expresses a much clearer intent than the key-collision case, which could be a well-intentioned accident to bind the actions to the same key.

@Cyclic4179 The goal of this PR was deal with *key collision* -- different actions mapping to the same key-- but it also affects a second case, generating new warnings which can't be turned off. That's *Action rebinding*. For example, if you want to replace all `execute=` bindings with `execute=y`, that was going to cause new warnings that can't be disabled. I'm going to push a new commit to narrow the scope to what was stated in the title: "Key Collision". I'll illustrate some different keybindings and how they will work after this PR: ``` execute-or-next=KP_Enter ``` This will generate an warning, because KP_Error is bound to `execute` by default: > fuzzel.ini:3: [key-bindings].execute-or-next: KP_Enter previously mapped to 'execute', overwriting This warning can be eliminated by clarifying the intent by specificing exactly what you would like bind `execute` to: ``` # KP_Enter from the list-- no more conflict with KP_Enter and no error execute=Return Control+y execute-or-next=KP_Enter ``` Now here's a a case of Action Rebindings, which generated several warnings original that couldn't be disabled, but now generates no warnings. What's happening here is that the default bindings of `execute` have been replaced with `y`: ``` execute=y ``` This is also less clearly a mistake. You have explicitly declared what you want to map `execute=` to in this case, which expresses a much clearer intent than the key-collision case, which could be a well-intentioned accident to bind the actions to the same key.
markstos force-pushed keybinds-overwrite from b02eb8ee69
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
to 0fe3a767d3
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
2025年08月15日 03:22:28 +02:00
Compare
Author
Collaborator
Copy link

@dnkl I've rebased this, I believe it's good to merge and ready for a final review.

@dnkl I've rebased this, I believe it's good to merge and ready for a final review.
Owner
Copy link

I'll need to think about this, and review after the upcoming release.

I'll need to think about this, and review after the upcoming release.
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
builds.sr.ht/freebsd-x64 Job completed
ci/woodpecker/pr/woodpecker Pipeline was successful
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin keybinds-overwrite:keybinds-overwrite
git switch keybinds-overwrite

Merge

Merge the changes and update on Forgejo.
git switch master
git merge --no-ff keybinds-overwrite
git switch keybinds-overwrite
git rebase master
git switch master
git merge --ff-only keybinds-overwrite
git switch keybinds-overwrite
git rebase master
git switch master
git merge --no-ff keybinds-overwrite
git switch master
git merge --squash keybinds-overwrite
git switch master
git merge --ff-only keybinds-overwrite
git switch master
git merge keybinds-overwrite
git push origin master
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
dnkl/fuzzel!432
Reference in a new issue
dnkl/fuzzel
No description provided.
Delete branch "keybinds-overwrite"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?