Skip to content

Commit

Permalink
Only show the command palette command list when it's needed
Browse files Browse the repository at this point in the history
Rather than open the command palette the moment we start looking for hits,
only show it when a hit comes in, or when we need to say that no matches
were found.

Fixes #3277.
  • Loading branch information
davep committed Sep 28, 2023
1 parent 7658bca commit f339cb5
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/textual/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,7 @@ def _show_no_matches() -> None:
id=self._NO_MATCHES,
)
)
self._list_visible = True

self._no_matches_timer = self.set_timer(
self._NO_MATCHES_COUNTDOWN,
Expand Down Expand Up @@ -765,6 +766,7 @@ def _refresh_command_list(
command_list.clear_options().add_options(sorted(commands, reverse=True))
if highlighted is not None:
command_list.highlighted = command_list.get_option_index(highlighted.id)
self._list_visible = bool(command_list.option_count)

_RESULT_BATCH_TIME: Final[float] = 0.25
"""How long to wait before adding commands to the command list."""
Expand Down Expand Up @@ -813,9 +815,6 @@ async def _gather_commands(self, search_value: str) -> None:
# grab a reference to that.
worker = get_current_worker()

# We're ready to show results, ensure the list is visible.
self._list_visible = True

# Reset busy mode.
self._show_busy = False

Expand Down

0 comments on commit f339cb5

Please sign in to comment.