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

fix(help panel): prevent duplicated key displays #5066

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

TomJGooding
Copy link
Contributor

Fixes #5037

Please review the following checklist.

  • Docstrings on all new or modified functions / classes
  • Updated documentation
  • Updated CHANGELOG.md (where appropriate)

@willmcgugan
Copy link
Collaborator

I don't think this will de-duplicate the key displays, except where we have identical keys to the same action.

i.e something like this:

BINDINGS = [
    ("foo", "do_foo"),
    ("foo", "do_foo"),
    ("bar", "do_foo")
]

Should display foo bar for the key display.

@TomJGooding
Copy link
Contributor Author

Sorry @willmcgugan, I'm not sure I understand what you mean.

Currently if you define a binding with a comma-separated list of keys along with a key_display, the help panel will duplicate that key display for each key as described in the linked issue #5037.

I don't see any issues with duplicated keys with your example bindings above, but perhaps I'm missing something?

@willmcgugan
Copy link
Collaborator

Consider the following:

from textual.app import App, ComposeResult

from textual.binding import Binding
from textual.widgets import Footer


class HelpPanelApp(App):
    BINDINGS = [
        Binding("a", "bell", "Ring the bell", key_display="bar"),
        Binding("b,e,l", "bell", "Ring the bell", key_display="foo"),
    ]

    def compose(self) -> ComposeResult:
        yield Footer()


HelpPanelApp().run()

This will only display a single key, when there are multiple that would apply.

A contrived example perhaps, but even more likely now we have keymaps.

@TomJGooding
Copy link
Contributor Author

Thanks Will for clarifying. I see your point about this edge case, but why would you define multiple bindings like this? The key panel also wouldn't account for these bindings having different descriptions, so why should the key display be different?

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 this pull request may close these issues.

Binding.key_display and help panel interact poorly for comma-separated Binding definitions
2 participants