mirror of https://github.com/Textualize/rich.git
Merge pull request #3480 from Textualize/fix-infinite-append
fix infinite loop in append
This commit is contained in:
commit
22c2cffd8e
|
@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
|
||||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed infinite loop when appending Text to same instance https://github.com/Textualize/rich/pull/3480
|
||||||
|
|
||||||
## [13.8.0] - 2024-08-26
|
## [13.8.0] - 2024-08-26
|
||||||
|
|
||||||
|
|
|
@ -998,7 +998,7 @@ class Text(JupyterMixin):
|
||||||
self._text.append(text.plain)
|
self._text.append(text.plain)
|
||||||
self._spans.extend(
|
self._spans.extend(
|
||||||
_Span(start + text_length, end + text_length, style)
|
_Span(start + text_length, end + text_length, style)
|
||||||
for start, end, style in text._spans
|
for start, end, style in text._spans.copy()
|
||||||
)
|
)
|
||||||
self._length += len(text)
|
self._length += len(text)
|
||||||
return self
|
return self
|
||||||
|
@ -1020,7 +1020,7 @@ class Text(JupyterMixin):
|
||||||
self._text.append(text.plain)
|
self._text.append(text.plain)
|
||||||
self._spans.extend(
|
self._spans.extend(
|
||||||
_Span(start + text_length, end + text_length, style)
|
_Span(start + text_length, end + text_length, style)
|
||||||
for start, end, style in text._spans
|
for start, end, style in text._spans.copy()
|
||||||
)
|
)
|
||||||
self._length += len(text)
|
self._length += len(text)
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -1001,3 +1001,14 @@ def test_append_tokens() -> None:
|
||||||
output = capture.get()
|
output = capture.get()
|
||||||
print(repr(output))
|
print(repr(output))
|
||||||
assert output == "long text that will be wrapped with a \ncontrol code \n\n"
|
assert output == "long text that will be wrapped with a \ncontrol code \n\n"
|
||||||
|
|
||||||
|
|
||||||
|
def test_append_loop_regression() -> None:
|
||||||
|
"""Regression text for https://github.com/Textualize/rich/issues/3479"""
|
||||||
|
a = Text("one", "blue")
|
||||||
|
a.append(a)
|
||||||
|
assert a.plain == "oneone"
|
||||||
|
|
||||||
|
b = Text("two", "blue")
|
||||||
|
b.append_text(b)
|
||||||
|
assert b.plain == "twotwo"
|
||||||
|
|
Loading…
Reference in New Issue