Skip to content

Commit

Permalink
Use Textual's TextArea.code_editor if available
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
godlygeek committed Feb 2, 2024
1 parent cc5463a commit d5fe572
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/memray/reporters/tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,9 @@ def compose(self) -> ComposeResult:
else:
lines = []

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

0 comments on commit d5fe572

Please sign in to comment.