Short-circuit text style parsing when unnecessary.

This commit is contained in:
Rodrigo Girão Serrão
2023-01-12 10:59:55 +00:00
parent c2f289e472
commit 4a893b5169
2 changed files with 4 additions and 1 deletions

View File

@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- The styles `scrollbar-background-active` and `scrollbar-color-hover` are no longer ignored https://github.com/Textualize/textual/pull/1480
- The widget `Placeholder` can now have its width set to `auto` https://github.com/Textualize/textual/pull/1508
- The style `text-style` option `none` can also be mixed with other options https://github.com/Textualize/textual/issues/1420
## [0.9.1] - 2022-12-30

View File

@@ -891,6 +891,7 @@ class StyleFlagsProperty:
Raises:
StyleValueError: If the value is an invalid style flag
"""
print(repr(style_flags))
_rich_traceback_omit = True
if style_flags is None:
if obj.clear_rule(self.name):
@@ -909,7 +910,8 @@ class StyleFlagsProperty:
self.name, word, context="inline"
),
)
style = Style.parse(style_flags)
# rich doesn't like "none" mixed with other styles, so short-circuit here.
style = Style() if "none" in words else Style.parse(style_flags)
if obj.set_rule(self.name, style):
obj.refresh()