Skip to content

Commit d5fe572

Browse files
committed
Use Textual's TextArea.code_editor if available
Textual 0.48 introduces a breaking change for the `TextArea` widget: line wrapping is now enabled by default. Since we don't want line wrapping, we need to disable that. Fortunately, a new alternative constructor called `TextArea.code_editor` is introduced, and constructing the `TextArea` using it retains the old behavior. Unfortunately, that alternative constructor didn't exist prior to Textual 0.48, so we need to conditionally fall back to simply using the `TextArea` constructor when `TextArea.code_editor` doesn't exist. Signed-off-by: Matt Wozniski <mwozniski@bloomberg.net>
1 parent cc5463a commit d5fe572

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/memray/reporters/tree.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ def compose(self) -> ComposeResult:
174174
else:
175175
lines = []
176176

177-
text = TextArea(
177+
# For Textual 0.48 and up, use the TextArea.code_editor() constructor.
178+
# This used to be the default, so fall back to the main constructor.
179+
text = getattr(TextArea, "code_editor", TextArea)(
178180
"\n".join(lines), language="python", theme="dracula", id="textarea"
179181
)
180182
text.select_line(delta + 1)

0 commit comments

Comments
 (0)