Skip to content

fix(MarkdownFence): gracefully handle missing Static child in _retheme callback #5525

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 6 additions & 2 deletions src/textual/widgets/_markdown.py
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
from textual.app import ComposeResult
from textual.await_complete import AwaitComplete
from textual.containers import Horizontal, Vertical, VerticalScroll
from textual.css.query import NoMatches
from textual.events import Mount
from textual.message import Message
from textual.reactive import reactive, var
@@ -425,7 +426,7 @@ class MarkdownOrderedList(MarkdownList):

MarkdownOrderedList Vertical {
height: auto;
width: 1fr;
width: 1fr;
}
"""

@@ -651,7 +652,10 @@ def _retheme(self) -> None:
if self.app.current_theme.dark
else self._markdown.code_light_theme
)
self.get_child_by_type(Static).update(self._block())
try:
self.get_child_by_type(Static).update(self._block())
except NoMatches:
pass

def compose(self) -> ComposeResult:
yield Static(
Loading