File tree 3 files changed +18
-2
lines changed
3 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
5
5
The format is based on [ Keep a Changelog] ( https://keepachangelog.com/en/1.0.0/ ) ,
6
6
and this project adheres to [ Semantic Versioning] ( https://semver.org/spec/v2.0.0.html ) .
7
7
8
+ ## Unreleased
9
+
10
+ ### Fixed
11
+
12
+ - Fixed infinite loop when appending Text to same instance https://github.com/Textualize/rich/pull/3480
8
13
9
14
## [ 13.8.0] - 2024-08-26
10
15
Original file line number Diff line number Diff line change @@ -998,7 +998,7 @@ def append(
998
998
self ._text .append (text .plain )
999
999
self ._spans .extend (
1000
1000
_Span (start + text_length , end + text_length , style )
1001
- for start , end , style in text ._spans
1001
+ for start , end , style in text ._spans . copy ()
1002
1002
)
1003
1003
self ._length += len (text )
1004
1004
return self
@@ -1020,7 +1020,7 @@ def append_text(self, text: "Text") -> "Text":
1020
1020
self ._text .append (text .plain )
1021
1021
self ._spans .extend (
1022
1022
_Span (start + text_length , end + text_length , style )
1023
- for start , end , style in text ._spans
1023
+ for start , end , style in text ._spans . copy ()
1024
1024
)
1025
1025
self ._length += len (text )
1026
1026
return self
Original file line number Diff line number Diff line change @@ -1001,3 +1001,14 @@ def test_append_tokens() -> None:
1001
1001
output = capture .get ()
1002
1002
print (repr (output ))
1003
1003
assert output == "long text that will be wrapped with a \n control code \n \n "
1004
+
1005
+
1006
+ def test_append_loop_regression () -> None :
1007
+ """Regression text for https://github.com/Textualize/rich/issues/3479"""
1008
+ a = Text ("one" , "blue" )
1009
+ a .append (a )
1010
+ assert a .plain == "oneone"
1011
+
1012
+ b = Text ("two" , "blue" )
1013
+ b .append_text (b )
1014
+ assert b .plain == "twotwo"
You can’t perform that action at this time.
0 commit comments