Skip to content

Commit

Permalink
Deduplicate screen CSS errors.
Browse files Browse the repository at this point in the history
Related issue: #3581.
  • Loading branch information
rodrigogiraoserrao committed Oct 30, 2023
1 parent efbb655 commit 37aac01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Fixed `OptionList` event leakage from `CommandPalette` to `App`.
- Fixed crash in `LoadingIndicator` https://github.com/Textualize/textual/pull/3498
- Fixed crash when `Tabs` appeared as a descendant of `TabbedContent` in the DOM https://github.com/Textualize/textual/pull/3602
- Duplicate CSS errors when parsing CSS from a screen https://github.com/Textualize/textual/issues/3581

### Added

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 @@ -372,10 +372,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 37aac01

Please sign in to comment.