Skip to content

Commit db3fda9

Browse files
committed
markup in commands
1 parent 58e1551 commit db3fda9

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

src/textual/command.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -978,7 +978,7 @@ async def _gather_commands(self, search_value: str) -> None:
978978
# list of commands that have been gathered so far.
979979
prompt = hit.prompt
980980
if hit.help:
981-
help_text = Text(hit.help)
981+
help_text = Text.from_markup(hit.help)
982982
help_text.stylize(help_style)
983983
prompt = Group(prompt, help_text)
984984
gathered_commands.append(Command(prompt, hit, id=str(command_id)))

src/textual/fuzzy.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def highlight(self, candidate: str) -> Text:
103103
A [rich.text.Text][`Text`] object with highlighted matches.
104104
"""
105105
match = self._query_regex.search(candidate)
106-
text = Text(candidate)
106+
text = Text.from_markup(candidate)
107107
if match is None:
108108
return text
109109
assert match.lastindex is not None

src/textual/system_commands.py

+4-12
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,24 @@
1313

1414
from __future__ import annotations
1515

16-
from typing import TYPE_CHECKING
17-
1816
from .command import DiscoveryHit, Hit, Hits, Provider
1917

20-
if TYPE_CHECKING:
21-
from .app import SystemCommandsResult
22-
2318

2419
class SystemCommandsProvider(Provider):
2520
"""A [source][textual.command.Provider] of command palette commands that run app-wide tasks.
2621
2722
Used by default in [`App.COMMANDS`][textual.app.App.COMMANDS].
2823
"""
2924

30-
@property
31-
def _system_commands(self) -> SystemCommandsResult:
32-
"""The system commands to reveal to the command palette."""
33-
yield from self.app.get_system_commands(self.screen)
34-
3525
async def discover(self) -> Hits:
3626
"""Handle a request for the discovery commands for this provider.
3727
3828
Yields:
3929
Commands that can be discovered.
4030
"""
41-
commands = sorted(self._system_commands, key=lambda command: command[0])
31+
commands = sorted(
32+
self.app.get_system_commands(self.screen), key=lambda command: command[0]
33+
)
4234
for name, help_text, callback, discover in commands:
4335
if discover:
4436
yield DiscoveryHit(
@@ -62,7 +54,7 @@ async def search(self, query: str) -> Hits:
6254

6355
# Loop over all applicable commands, find those that match and offer
6456
# them up to the command palette.
65-
for name, help_text, callback, *_ in self._system_commands:
57+
for name, help_text, callback, *_ in self.app.get_system_commands(self.screen):
6658
if (match := matcher.match(name)) > 0:
6759
yield Hit(
6860
match,

0 commit comments

Comments
 (0)