Skip to content

Commit 4653f30

Browse files
committed
fix(text area): set attributes before calling _set_document
Ensure `TextArea.__init__()` assigns attributes like `soft_wrap` *before* calling the `_set_document()` method. Currently if you create a `TextArea` with `soft_wrap=False`, the document is first wrapped with the default `soft_wrap=True`, causing an initial flicker.
1 parent 6e36e9e commit 4653f30

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/textual/widgets/_text_area.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -500,6 +500,11 @@ def __init__(
500500
self._cursor_offset = (0, 0)
501501
"""The virtual offset of the cursor (not screen-space offset)."""
502502

503+
self.set_reactive(TextArea.soft_wrap, soft_wrap)
504+
self.set_reactive(TextArea.read_only, read_only)
505+
self.set_reactive(TextArea.show_line_numbers, show_line_numbers)
506+
self.set_reactive(TextArea.line_number_start, line_number_start)
507+
503508
self._set_document(text, language)
504509

505510
self.language = language
@@ -510,11 +515,6 @@ def __init__(
510515
reactive is set as a string, the watcher will update this attribute to the
511516
corresponding `TextAreaTheme` object."""
512517

513-
self.set_reactive(TextArea.soft_wrap, soft_wrap)
514-
self.set_reactive(TextArea.read_only, read_only)
515-
self.set_reactive(TextArea.show_line_numbers, show_line_numbers)
516-
self.set_reactive(TextArea.line_number_start, line_number_start)
517-
518518
self.tab_behavior = tab_behavior
519519

520520
if tooltip is not None:

0 commit comments

Comments
 (0)