-
Notifications
You must be signed in to change notification settings - Fork 827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a crash caused by a prompt being wider than a SelectionList
#2970
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one request.
src/textual/widgets/_option_list.py
Outdated
add_span = self._spans.append | ||
option_ids = self._option_ids | ||
add_lines = self._lines.extend | ||
|
||
# Adjust the options for our purposes. | ||
options = self.app.console.options.copy().update_width( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
update_width
does a copy()
internally, so you won't need the explicit copy.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh hah! That explains why it wasn't there before!
This fixes the issue raised in #2900 (and also #2969).
The PR adds a
wrap
property toOptionList
(True
by default), which tells the widget if it should auto-wrap prompts (which it was anyway and which was the source of the issue withSelectionList
). When set toFalse
, any prompt that is wider than the widget will be truncated, with ellipsis.This is then set to
False
forSelectionList
. Whereas before aSelectionList
with over-long prompts would result in the crash in the related issue, it will now look like this: