@@ -845,7 +845,10 @@ def _set_theme(self, theme: str) -> None:
845845 if background :
846846 self .styles .background = Color .from_rich_color (background )
847847
848- theme_object .apply_css (self )
848+ def apply_theme () -> None :
849+ self ._theme .apply_css (self )
850+
851+ self .call_later (apply_theme )
849852
850853 @property
851854 def available_themes (self ) -> set [str ]:
@@ -1045,6 +1048,7 @@ def wrap_width(self) -> int:
10451048
10461049 def _rewrap_and_refresh_virtual_size (self ) -> None :
10471050 self .wrapped_document .wrap (self .wrap_width , tab_width = self .indent_width )
1051+ self ._line_cache .clear ()
10481052 self ._refresh_size ()
10491053
10501054 @property
@@ -1115,7 +1119,7 @@ def get_line(self, line_index: int) -> Text:
11151119 A `rich.Text` object containing the requested line.
11161120 """
11171121 line_string = self .document .get_line (line_index )
1118- return Text (line_string , end = "" )
1122+ return Text (line_string , end = "" , no_wrap = True )
11191123
11201124 def render_line (self , y : int ) -> Strip :
11211125 """Render a single line of the TextArea. Called by Textual.
@@ -1138,11 +1142,20 @@ def render_line(self, y: int) -> Strip:
11381142 if selection .contains_line (absolute_y )
11391143 else selection .end [0 ] == absolute_y
11401144 ),
1141- self ._cursor_visible ,
1142- self .cursor_blink ,
1145+ (
1146+ selection .end
1147+ if (
1148+ self ._cursor_visible
1149+ and self .cursor_blink
1150+ and absolute_y == selection .end [0 ]
1151+ )
1152+ else None
1153+ ),
11431154 self .theme ,
11441155 self ._matching_bracket_location ,
11451156 self .match_cursor_bracket ,
1157+ self .soft_wrap ,
1158+ self .show_line_numbers ,
11461159 )
11471160 if (cached_line := self ._line_cache .get (cache_key )) is not None :
11481161 return cached_line
@@ -1214,7 +1227,8 @@ def _render_line(self, y: int) -> Strip:
12141227 if selection_style :
12151228 if line_character_count == 0 and line_index != cursor_row :
12161229 # A simple highlight to show empty lines are included in the selection
1217- line = Text ("▌" , end = "" , style = Style (color = selection_style .bgcolor ))
1230+ line .plain = "▌"
1231+ line .stylize (Style (color = selection_style .bgcolor ))
12181232 else :
12191233 if line_index == selection_top_row == selection_bottom_row :
12201234 # Selection within a single line
@@ -1346,10 +1360,7 @@ def _render_line(self, y: int) -> Strip:
13461360
13471361 # Crop the line to show only the visible part (some may be scrolled out of view)
13481362 console = self .app .console
1349- text_strip = Strip (
1350- console .render (line , options = console .options .update_width (line .cell_len )),
1351- cell_length = line .cell_len ,
1352- )
1363+ text_strip = Strip (line .render (console ), cell_length = line .cell_len )
13531364 if not self .soft_wrap :
13541365 text_strip = text_strip .crop (scroll_x , scroll_x + virtual_width )
13551366
0 commit comments