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

Don't sort "discover" items in the command palette #4720

Merged
merged 6 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Changed

- "Discover" hits in the command palette are no longer sorted alphabetically https://github.com/Textualize/textual/pull/4720

### Fixed

- Fixed scroll_visible with margin https://github.com/Textualize/textual/pull/4719
Expand Down
1 change: 0 additions & 1 deletion docs/guide/command_palette.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ this is to aid in command discoverability.

- `discover` accepts no parameters (instead of the search value)
- `discover` yields instances of [`DiscoveryHit`][textual.command.DiscoveryHit] (instead of instances of [`Hit`][textual.command.Hit])
- discovery hits are sorted in ascending alphabetical order because there is no matching and no match score is generated

Instances of [`DiscoveryHit`][textual.command.DiscoveryHit] contain information about how the hit should be displayed, an optional help string, and a callback which will be run if the user selects that command.

Expand Down
4 changes: 2 additions & 2 deletions src/textual/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ def _refresh_command_list(
clear_current: Should the current content of the list be cleared first?
"""
# For the moment, this is a fairly naive approach to populating the
# command list with a sorted list of commands. Every time we add a
# command list with a list of commands. Every time we add a
# new one we're nuking the list of options and populating them
# again. If this turns out to not be a great approach, we may try
# and get a lot smarter with this (ideally OptionList will grow a
Expand All @@ -876,7 +876,7 @@ def _refresh_command_list(
if command_list.highlighted is not None and not clear_current
else None
)
command_list.clear_options().add_options(sorted(commands, reverse=True))
command_list.clear_options().add_options(commands)
if highlighted is not None and highlighted.id:
command_list.highlighted = command_list.get_option_index(highlighted.id)
self._list_visible = bool(command_list.option_count)
Expand Down
Loading
Loading