Skip to content
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

Merged
merged 7 commits into from
Jul 19, 2023

Conversation

davep
Copy link
Contributor

@davep davep commented Jul 19, 2023

This fixes the issue raised in #2900 (and also #2969).

The PR adds a wrap property to OptionList (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 with SelectionList). When set to False, any prompt that is wider than the widget will be truncated, with ellipsis.

This is then set to False for SelectionList. Whereas before a SelectionList with over-long prompts would result in the crash in the related issue, it will now look like this:

Screenshot 2023-07-19 at 11 48 50

@davep davep marked this pull request as ready for review July 19, 2023 10:53
Copy link
Collaborator

@willmcgugan willmcgugan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just one request.

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(
Copy link
Collaborator

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.

Copy link
Contributor Author

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!

@davep davep merged commit 2f055f6 into Textualize:main Jul 19, 2023
@davep davep deleted the unbork-selection-list branch July 19, 2023 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Task
Projects
None yet
2 participants