Skip to content
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

Deduplicate screen CSS errors. #3616

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Fixed

- Duplicate CSS errors when parsing CSS from a screen https://github.com/Textualize/textual/issues/3581

### Changed

- CSS error reporting will no longer provide links to the files in question https://github.com/Textualize/textual/pull/3582
Expand Down
17 changes: 13 additions & 4 deletions src/textual/css/stylesheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,19 @@ def reparse(self) -> None:
tie_breaker=tie_breaker,
scope=scope,
)
stylesheet.parse()
self._rules = stylesheet.rules
self._rules_map = None
self.source = stylesheet.source
try:
stylesheet.parse()
except Exception:
# If we don't update self's invalid CSS, we might end up reparsing this CSS
# before Textual quits application mode.
# See https://github.com/Textualize/textual/issues/3581.
self._invalid_css.update(stylesheet._invalid_css)
raise
else:
self._rules = stylesheet.rules
self._rules_map = None
self.source = stylesheet.source
self._require_parse = False

@classmethod
def _check_rule(
Expand Down
Loading