Skip to content

Commit 88a8bd5

Browse files
committed
prevent error in constructor
1 parent c3e00ae commit 88a8bd5

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/textual/widgets/_text_area.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -464,9 +464,6 @@ def __init__(
464464

465465
self.tab_behavior = tab_behavior
466466

467-
# When `app.dark` is toggled, reset the theme (since it caches values).
468-
self.watch(self.app, "dark", self._app_dark_toggled, init=False)
469-
470467
if tooltip is not None:
471468
self.tooltip = tooltip
472469

@@ -610,6 +607,10 @@ def _watch_selection(
610607
) -> None:
611608
"""When the cursor moves, scroll it into view."""
612609
# Find the visual offset of the cursor in the document
610+
611+
if not self.is_mounted:
612+
return
613+
613614
cursor_location = selection.end
614615

615616
self.scroll_cursor_visible()
@@ -1519,6 +1520,9 @@ def gutter_width(self) -> int:
15191520
return gutter_width
15201521

15211522
def _on_mount(self, event: events.Mount) -> None:
1523+
# When `app.dark` is toggled, reset the theme (since it caches values).
1524+
self.watch(self.app, "dark", self._app_dark_toggled, init=False)
1525+
15221526
self.blink_timer = self.set_interval(
15231527
0.5,
15241528
self._toggle_cursor_blink_visible,

0 commit comments

Comments
 (0)