Remove anything to do with CommandPalette.current_screen

It was for the older approach to command palette isolation; it's not really
needed any more.
This commit is contained in:
Dave Pearson
2023-11-08 11:47:26 +00:00
parent 869e04617e
commit dc19558ef8
2 changed files with 3 additions and 18 deletions

View File

@@ -475,21 +475,6 @@ class CommandPalette(_SystemModalScreen[CallbackType]):
"""
return app.screen.id == CommandPalette._PALETTE_ID
@staticmethod
def current_screen(app: App) -> Screen:
"""Get the current screen.
This method gets the current screen for the app, ignoring the
command palette.
Args:
app: The app to get the screen for.
Returns:
The current screen for the application, excluding the command palette.
"""
return app.screen_stack[-2] if CommandPalette.is_open(app) else app.screen
@property
def _provider_classes(self) -> set[type[Provider]]:
"""The currently available command providers.
@@ -535,7 +520,7 @@ class CommandPalette(_SystemModalScreen[CallbackType]):
def on_mount(self, _: Mount) -> None:
"""Configure the command palette once the DOM is ready."""
self._calling_screen = self.current_screen(self.app)
self._calling_screen = self.app.screen_stack[-2]
match_style = self.get_component_rich_style(
"command-palette--highlight", partial=True

View File

@@ -1,7 +1,7 @@
from __future__ import annotations
from textual.app import App, ComposeResult
from textual.command import CommandPalette, Hit, Hits, Provider
from textual.command import Hit, Hits, Provider
from textual.screen import Screen
from textual.widget import Widget
from textual.widgets import Input
@@ -31,7 +31,7 @@ class CommandPaletteApp(App[None]):
async def test_command_source_environment() -> None:
"""The command source should see the app and default screen."""
async with CommandPaletteApp().run_test() as pilot:
base_screen = CommandPalette.current_screen(pilot.app)
base_screen, *_ = pilot.app.children
assert base_screen is not None
await pilot.press(*"test")
assert len(SimpleSource.environment) == 1