Skip to content

Commit

Permalink
Merge pull request #3616 from Textualize/duplicate-screen-css-errors
Browse files Browse the repository at this point in the history
Deduplicate screen CSS errors.
  • Loading branch information
rodrigogiraoserrao authored Nov 1, 2023
2 parents ad83e91 + 8818f12 commit da70d83
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
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

0 comments on commit da70d83

Please sign in to comment.