Skip to content
Merged
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
10 changes: 7 additions & 3 deletions src/textual/widgets/_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ async def write(self, markdown_fragment: str) -> None:
# Append the new fragment, and set an event to tell the _run loop to wake up
self._pending.append(markdown_fragment)
self._new_markup.set()
# Allow the task to wake up and actually display the new markdown
await asyncio.sleep(0)

async def _run(self) -> None:
"""Run a task to append markdown fragments when available."""
Expand All @@ -99,9 +101,11 @@ async def _run(self) -> None:
await asyncio.shield(self.markdown_widget.append(new_markdown))
except asyncio.CancelledError:
# Task has been cancelled, add any outstanding markdown
new_markdown = "".join(self._pending)
if new_markdown:
await self.markdown_widget.append(new_markdown)
pass

new_markdown = "".join(self._pending)
if new_markdown:
await self.markdown_widget.append(new_markdown)


class Navigator:
Expand Down
Loading