Skip to content

Commit

Permalink
Docstrings, and clear deferred renders queue on clear() call in RichLog
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenburns committed Sep 10, 2024
1 parent bcbcbb5 commit fd7081a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/textual/widgets/_rich_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ def __init__(
"""Maximum number of lines in the log or `None` for no maximum."""
self._start_line: int = 0
self.lines: list[Strip] = []
"""The lines currently visible in the log."""
self._line_cache: LRUCache[tuple[int, int, int, int], Strip]
self._line_cache = LRUCache(1024)
self._deferred_renders: deque[DeferredRender] = deque()
Expand All @@ -119,6 +120,8 @@ def __init__(
"""The width of the widest line currently in the log."""

self._size_known = False
"""Flag which is set to True when the size of the RichLog is known,
indicating we can proceed with rendering deferred writes."""

def notify_style_update(self) -> None:
self._line_cache.clear()
Expand Down Expand Up @@ -277,6 +280,7 @@ def clear(self) -> Self:
self._line_cache.clear()
self._start_line = 0
self._widest_line_width = 0
self._deferred_renders.clear()
self.virtual_size = Size(0, len(self.lines))
self.refresh()
return self
Expand Down

0 comments on commit fd7081a

Please sign in to comment.