Skip to content

Fix outline repeated on padding rows from simple strip cache#6572

Open
ShubhamPhapale wants to merge 1 commit into
Textualize:mainfrom
ShubhamPhapale:ShubhamPhapale/fix/outline-padding-strip-cache
Open

Fix outline repeated on padding rows from simple strip cache#6572
ShubhamPhapale wants to merge 1 commit into
Textualize:mainfrom
ShubhamPhapale:ShubhamPhapale/fix/outline-padding-strip-cache

Conversation

@ShubhamPhapale

Copy link
Copy Markdown

Fixes #6558

The "optimize styles cache render" change (8ae3b5f) caches a "simple" padding
strip and reuses it for every padding row. It's cached after outline
processing, so for a widget with an outline and padding, the first padding
row — which carries the outline's top edge — gets cached and repeated on all
padding rows, while the bottom edge is dropped.

A top or bottom outline lands on a single padding row, so those rows aren't
uniform. This disables the simple-strip cache when outline_top or
outline_bottom is set. The no-outline and left/right-only-outline cases keep
uniform padding rows, so the optimization still applies there.

Added a snapshot regression test (fails on main without this change).

LinkedIn: https://www.linkedin.com/in/shubham-phapale/

Copilot AI review requested due to automatic review settings June 8, 2026 17:59

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a regression test and accompanying rendering fix to prevent top/bottom outlines from being incorrectly repeated across padding rows, and documents the fix in the changelog.

Changes:

  • Added a snapshot regression test covering outline + vertical padding rendering (issue #6558).
  • Updated the styles cache logic to avoid reusing the “simple strip” cache when top/bottom outlines are involved.
  • Added a changelog entry under “Unreleased” for the fix.

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.

File Description
tests/snapshot_tests/test_snapshots.py Adds a regression snapshot test to catch outline duplication across padding rows.
tests/snapshot_tests/snapshots/test_snapshots/test_outline_with_padding.svg Adds the expected rendered output snapshot for the new regression test.
src/textual/_styles_cache.py Adjusts simple-strip caching behavior to prevent incorrect reuse with top/bottom outlines.
CHANGELOG.md Documents the fix in the Unreleased changelog section.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/textual/_styles_cache.py Outdated
Comment on lines +325 to +328
# The simple-strip cache assumes every padding row is identical. A top
# or bottom outline is drawn on a single padding row (the first or
# last), so the cache must not be used when either is present.
reuse_simple_strip = not (outline_top or outline_bottom)
Comment on lines +435 to +438
if reuse_simple_strip:
if self._simple_strip is not None:
return self._simple_strip
cache_simple_strip = True
Comment thread CHANGELOG.md
Comment on lines +8 to +12
## Unreleased

### Fixed

- Fixed top/bottom `outline` being repeated on padding rows due to the simple strip cache https://github.com/Textualize/textual/issues/6558
The styles cache reuses a cached padding strip for all padding rows, but it
was cached after outline processing. With a top/bottom outline, the first
padding row carries the outline's top edge, which was then repeated on every
padding row (and the bottom edge was lost). Disable the simple-strip cache
when a top or bottom outline is present; rows with no outline or only
left/right outlines stay uniform and keep the optimization.

Fixes Textualize#6558
@ShubhamPhapale ShubhamPhapale force-pushed the ShubhamPhapale/fix/outline-padding-strip-cache branch from 22a5aaa to 03d11c9 Compare June 8, 2026 18:05
@ShubhamPhapale

Copy link
Copy Markdown
Author

Thanks for the review.

  • Narrowed the condition to (outline_top and pad_top) or (outline_bottom and pad_bottom),
    so the cache is only disabled when an outline actually coincides with padding —
    good call, this keeps the optimization for outlines without padding on that side.
  • Kept it a single guard rather than role-based caching (middle vs first/last strips).
    Padding rows only differ at the first/last row when a top/bottom outline is present, and
    the recompute cost is limited to outline+padding widgets; given how subtle this cache is
    (and that the issue notes the optimization may be reverted if the win is minimal), I'd
    favor the simpler, clearly-correct guard. Happy to revisit if you'd prefer the split.
  • Left the changelog as a bare URL to match the existing entries in CHANGELOG.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Widget outlines are subtly broken by the simple strip cache

2 participants